TransactionSEALED
█^◇&▪#▫╲╲▪#@@▓▒■╱^●◇@?▪╱○○●&▓!○╱▪▒$#□●◆*%╲◇^█░◆○@╲$!□?◇~~$●#▒?▪▫
Transaction ID
Execution Fee
0.00001224 FLOWTransaction Summary
Contract Call
Called NonFungibleToken, Burner, HybridCustody
Contracts
Script Arguments
Copy:
0addresses[Address]
1nftIDs[[UInt64]]
[
[
"19791210295266"
]
]2collectionStoragePath[StoragePath]
[ "storage/cadenceExampleNFTCollection" ]
Cadence Script
1import NonFungibleToken from 0x1d7e57aa55817448
2import Burner from 0xf233dcee88fe0abe
3import HybridCustody from 0xd8a7e05a7ac670c0
4
5/// Transaction to burn multiple NFTs from a collection (supports both main account and child accounts)
6/// Uses the Burner contract for secure NFT burning
7transaction(addresses: [Address], nftIDs: [[UInt64]], collectionStoragePath: [StoragePath]) {
8 /// Collection access info for each burn operation
9 let burnOperations: [{String: AnyStruct}]
10
11 prepare(signer: auth(Storage) &Account) {
12 // Validate input
13 pre {
14 nftIDs.length > 0: "Must provide at least one NFT ID to burn"
15 nftIDs.length == addresses.length: "Must provide the same number of addresses as NFT ID arrays"
16 nftIDs.length == collectionStoragePath.length: "Must provide the same number of NFT IDs as collection storage paths"
17 }
18
19 self.burnOperations = []
20
21 // Get HybridCustody manager if available
22 let manager = signer.storage.borrow<auth(HybridCustody.Manage) &HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath)
23
24 var i = 0
25 while i < addresses.length {
26 let targetAddress = addresses[i]!
27 let path = collectionStoragePath[i]!
28 let nftIDsForAddress = nftIDs[i]!
29
30 // Determine if this is a child account or main account
31 let isChildAccount = targetAddress != signer.address
32 var collectionRef: auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}? = nil
33
34 if isChildAccount {
35 // Handle child account burning
36 if let managerRef = manager {
37 // Get child account access
38 if let childAccount = managerRef.borrowAccount(addr: targetAddress) {
39 let capType = Type<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Provider}>()
40 let controller = childAccount.getControllerIDForType(type: capType, forPath: path)
41 ?? panic("no controller found for capType")
42 let cap = childAccount.getCapability(controllerID: controller, type: capType) ?? panic("no capability found for capType")
43 collectionRef = cap.borrow<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>()
44 }
45 } else {
46 panic("Cannot access child account: HybridCustody manager not found")
47 }
48 } else {
49 // Handle main account burning
50 collectionRef = signer.storage.borrow<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>(from: path)
51 }
52
53 // Validate collection was found
54 assert(collectionRef != nil, message: "NFT collection not found at ".concat(path.toString()).concat(" for address ").concat(targetAddress.toString()))
55
56 // Pre-validate that all NFTs exist in this collection
57 let currentIDs = collectionRef!.getIDs()
58 for nftID in nftIDsForAddress {
59 assert(currentIDs.contains(nftID), message: "NFT with ID ".concat(nftID.toString()).concat(" does not exist in collection at ").concat(targetAddress.toString()))
60 }
61
62 // Store operation info
63 self.burnOperations.append({
64 "collectionRef": collectionRef!,
65 "nftIDs": nftIDsForAddress,
66 "address": targetAddress.toString(),
67 "isChild": isChildAccount
68 })
69
70 i = i + 1
71 }
72 }
73
74 execute {
75 // Burn each NFT using the Burner contract
76 var i = 0
77 while i < self.burnOperations.length {
78 let operation = self.burnOperations[i]!
79 let collectionRef = operation["collectionRef"]! as! auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}
80 let nftIDsForOperation = operation["nftIDs"]! as! [UInt64]
81
82 for nftId in nftIDsForOperation {
83 // Withdraw the NFT from the collection
84 let nft <- collectionRef.withdraw(withdrawID: nftId)
85
86 // Burn the NFT using the Burner contract
87 Burner.burn(<-nft)
88 }
89 i = i + 1
90 }
91 }
92}