-
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
a66e64e
commit def0ba0
Showing
1 changed file
with
14 additions
and
10 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,31 +1,35 @@ | ||
import "NonFungibleToken" | ||
import "Recipe" | ||
import "ExampleNFT" | ||
|
||
transaction { | ||
let minter: &Recipe | ||
let minter: &ExampleNFT.NFTMinter | ||
let receiver: &{NonFungibleToken.CollectionPublic} | ||
|
||
prepare(signer: auth(Storage, Capabilities) &Account) { | ||
// Borrow the Recipe contract as a reference | ||
self.minter = signer.capabilities.storage.borrow<&Recipe>( | ||
// Borrow the ExampleNFT.NFTMinter reference | ||
self.minter = signer.storage.borrow<&ExampleNFT.NFTMinter>( | ||
from: Recipe.ExampleNFTMinterPath | ||
) ?? panic("Could not borrow a reference to the Recipe contract") | ||
) ?? panic("Could not borrow a reference to the ExampleNFT NFTMinter") | ||
|
||
// Borrow the signer's NFT collection reference | ||
self.receiver = signer.capabilities.storage.borrow<&{NonFungibleToken.CollectionPublic}>( | ||
from: Recipe.CollectionPublicPath | ||
self.receiver = signer.storage.borrow<&{NonFungibleToken.CollectionPublic}>( | ||
from: /storage/exampleNFTCollection | ||
) ?? panic("Could not borrow a reference to the signer's NFT collection") | ||
} | ||
|
||
execute { | ||
// Call mintNFT from the Recipe contract | ||
self.minter.mintNFT( | ||
recipient: self.receiver, | ||
// Call the mintNFT function from the ExampleNFT.NFTMinter | ||
let newNFT <- self.minter.mintNFT( | ||
name: "Hardcoded NFT Name", | ||
description: "This is a hardcoded description of the NFT.", | ||
thumbnail: "https://example.com/hardcoded-thumbnail.png" | ||
thumbnail: "https://example.com/hardcoded-thumbnail.png", | ||
royalties: [] | ||
) | ||
|
||
// Deposit the minted NFT into the recipient's collection | ||
self.receiver.deposit(token: <-newNFT) | ||
|
||
log("Minted and deposited an NFT into the signer's collection.") | ||
} | ||
} |