-
Notifications
You must be signed in to change notification settings - Fork 0
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
588eeef
commit 80834f5
Showing
1 changed file
with
20 additions
and
31 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 |
---|---|---|
@@ -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") | ||
} | ||
} |