TransactionSEALED
╲!░●!!!▒◇█▒$╲□●?◆?!░▫!╳●◇▓■#██░$■?$%*□▫▪#▫■%▪◇???□$%*░●$~$○*▓▪◇░
Transaction ID
Execution Fee
0.00003349 FLOWTransaction Summary
Contract Call
Called NonFungibleToken, MetadataViews
Contracts
Script Arguments
Copy:
0toAddress
1idUInt64
1147881180
2contractAddressAddress
3contractNameString
Doodles
Cadence Script
1import NonFungibleToken from 0x1d7e57aa55817448
2import MetadataViews from 0x1d7e57aa55817448
3
4/// Can pass in any contract address and name
5/// This lets you choose the token you want to send because
6/// the transaction gets the metadata from the provided contract.
7///
8transaction(to: Address, id: UInt64, contractAddress: Address, contractName: String) {
9
10 // The NFT resource to be transferred
11 let tempNFT: @{NonFungibleToken.NFT}
12
13 // NFTCollectionData struct to get paths from
14 let collectionData: MetadataViews.NFTCollectionData
15
16 prepare(signer: auth(BorrowValue) &Account) {
17
18 // Borrow a reference to the nft contract deployed to the passed account
19 let resolverRef = getAccount(contractAddress)
20 .contracts.borrow<&{NonFungibleToken}>(name: contractName)
21 ?? panic("Could not borrow a reference to the non-fungible token contract")
22
23 // Use that reference to retrieve the NFTCollectionData view
24 self.collectionData = resolverRef.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
25 ?? panic("Could not resolve the NFTCollectionData view for the given non-fungible token contract")
26
27
28 // borrow a reference to the signer's NFT collection
29 let withdrawRef = signer.storage.borrow<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>(
30 from: self.collectionData.storagePath
31 ) ?? panic("Account does not store a collection object at the specified path")
32
33 self.tempNFT <- withdrawRef.withdraw(withdrawID: id)
34 }
35
36 execute {
37 // get the recipients public account object
38 let recipient = getAccount(to)
39
40 // borrow a public reference to the receivers collection
41 let receiverRef = recipient.capabilities.borrow<&{NonFungibleToken.Receiver}>(self.collectionData.publicPath)
42 ?? panic("Could not borrow reference to the recipient's receiver")
43
44 // Deposit the NFT to the receiver
45 receiverRef.deposit(token: <-self.tempNFT)
46 }
47}