From 80834f571fe08871d43eb6d0298161139e83ef2c Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Thu, 12 Dec 2024 01:28:02 +0400 Subject: [PATCH] Repo structure --- cadence/transactions/mint_nft.cdc | 51 ++++++++++++------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/cadence/transactions/mint_nft.cdc b/cadence/transactions/mint_nft.cdc index 85b2684..0f57d70 100644 --- a/cadence/transactions/mint_nft.cdc +++ b/cadence/transactions/mint_nft.cdc @@ -1,40 +1,29 @@ -import NonFungibleToken from 0x03 -import NewExampleNFT from 0x02 - -// This transaction uses the NFTMinter resource to mint a new NFT -// It must be run with the account that has the minter resource -// stored in /storage/NFTMinter +import "MetadataViews" +import "ExampleNFT" transaction { - // Local variable for storing the minter reference - let minter: auth(MinterEntitlement) &NewExampleNFT.NFTMinter - prepare(signer: auth(Storage, Capabilities) &Account) { - // Borrow a reference to the NFTMinter resource in storage - self.minter = signer.capabilities.storage.borrow<&NewExampleNFT.NFTMinter>( - from: NewExampleNFT.MinterStoragePath - ) ?? panic("Could not borrow a reference to the NFT minter") - } + // Use the caller's address + let address: Address = signer.address - execute { - // Borrow the recipient's public NFT collection reference - let receiver = getAccount(0x02) - .capabilities - .borrow<&{NonFungibleToken.CollectionPublic}>(NewExampleNFT.CollectionPublicPath) - ?? panic("Could not get receiver reference to the NFT Collection") + // Borrow the NFTMinter from the caller's storage + let minter = signer.storage.borrow<&ExampleNFT.NFTMinter>( + from: /storage/exampleNFTMinter + ) ?? panic("Could not borrow the NFT minter reference.") - // Mint the NFT and deposit it to the recipient's collection - self.minter.mintNFT( - recipient: receiver, - name: "Second NFT", - description: "The Best NFT", - thumbnail: "NFT: Thumbnail", - power: "The best", - will: "The strongest", - determination: "unbeatable" + // Mint a new NFT with metadata + let nft <- minter.mintNFT( + name: "Example NFT", + description: "Minting a sample NFT", + thumbnail: "https://example.com/thumbnail.png", + royalties: [], + metadata: { + "Power": "100", + "Will": "Strong", + "Determination": "Unyielding" + }, + ) - - log("Minted an NFT") } }