Skip to content

Commit

Permalink
Repo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Dec 11, 2024
1 parent 588eeef commit 80834f5
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions cadence/transactions/mint_nft.cdc
Original file line number Diff line number Diff line change
@@ -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")
}
}

0 comments on commit 80834f5

Please sign in to comment.