Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
750d292
commit 5666224
Showing
5 changed files
with
866 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
ForgeScript, | ||
Transaction, | ||
AppWallet, | ||
BlockfrostProvider, | ||
} from '@meshsdk/core'; | ||
import type { AssetMetadata, Mint } from '@meshsdk/core'; | ||
import { demoMnemonic } from '../../configs/demo'; | ||
|
||
export default async function mintMeshToken({setLoading, setResponse, wallet}) { | ||
setLoading(true); | ||
try { | ||
const blockchainProvider = new BlockfrostProvider( | ||
process.env.NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD! | ||
); | ||
|
||
const mintingWallet = new AppWallet({ | ||
networkId: 0, | ||
fetcher: blockchainProvider, | ||
submitter: blockchainProvider, | ||
key: { | ||
type: 'mnemonic', | ||
words: demoMnemonic, | ||
}, | ||
}); | ||
|
||
const usedAddress = await wallet.getUsedAddresses(); | ||
const address = usedAddress[0]; | ||
const forgingScript = ForgeScript.withOneSignature( | ||
mintingWallet.getPaymentAddress() | ||
); | ||
|
||
const tx = new Transaction({ initiator: wallet }); | ||
|
||
const assetMetadata: AssetMetadata = { | ||
name: 'Mesh Token', | ||
image: 'ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua', | ||
mediaType: 'image/jpg', | ||
description: 'This NFT is minted by Mesh (https://meshjs.dev/).', | ||
}; | ||
const asset: Mint = { | ||
assetName: 'MeshToken', | ||
assetQuantity: '1', | ||
metadata: assetMetadata, | ||
label: '721', | ||
recipient: address, | ||
}; | ||
tx.mintAsset(forgingScript, asset); | ||
|
||
const unsignedTx = await tx.build(); | ||
const signedTx = await wallet.signTx(unsignedTx, true); | ||
const signedTx2 = await mintingWallet.signTx(signedTx, true); | ||
const txHash = await wallet.submitTx(signedTx2); | ||
setResponse(txHash); | ||
} catch (error) {} | ||
setLoading(false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ChevronUpIcon, ChevronDownIcon } from '@heroicons/react/24/solid'; | ||
import { useState } from 'react'; | ||
|
||
export default function ShowMoreDetails({ children, label = 'Show details' }) { | ||
const [show, setShow] = useState<boolean>(false); | ||
return ( | ||
<> | ||
<div className='mb-8'> | ||
<button | ||
type="button" | ||
className="flex justify-between items-center py-5 w-full font-medium text-left text-gray-500 border-b border-gray-200 dark:border-gray-700 dark:text-gray-400" | ||
onClick={() => setShow(!show)} | ||
> | ||
<span>{label}</span> | ||
{show ? ( | ||
<ChevronDownIcon className="w-6 h-6 shrink-0" /> | ||
) : ( | ||
<ChevronUpIcon className="w-6 h-6 shrink-0" /> | ||
)} | ||
</button> | ||
</div> | ||
<div | ||
id="accordion-flush-body-3" | ||
className={!show ? 'hidden' : ''} | ||
aria-labelledby="accordion-flush-heading-3" | ||
> | ||
<div className="py-5 border-b border-gray-200 dark:border-gray-700"> | ||
{children} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.