TransactionSEALED

□◆○●▫#●●●▓█▒~╱◇◆#■╳□╱●~▫▫~░#╲^◇??~░░▓□╱#▪@▒▓#▓*$░◇~▓?!▒!~▫╳▒?■▓●

Transaction ID

Timestamp

Jun 02, 2025, 12:26:32 PM UTC
9mo ago

Block Height

115,090,916

Computation

0

Execution Fee

0.00002374 FLOW

Transaction Summary

Contract Call

Called NonFungibleToken, TitStakingX0X, CourtiersX +1 more

Script Arguments

Copy:
0nftIds[UInt64]
[
  "8"
]
1nftTypes[String]
[
  "pages"
]
2nftNames[String]
[
  "Colette"
]
3levels[UInt64]
[
  "1"
]

Cadence Script

1import NonFungibleToken from 0x1d7e57aa55817448
2import TitStakingX0X from 0xfdfe39186c5e3b90
3import CourtiersX from 0xfdfe39186c5e3b90
4import PagesX from 0xfdfe39186c5e3b90
5
6transaction(nftIds: [UInt64], nftTypes: [String], nftNames: [String], levels: [UInt64]) {
7let nfts: @{Int: {NonFungibleToken.NFT}}
8let address: Address
9let stakingRef: &{TitStakingX0X.TitStakePublic}
10
11    prepare(signer: auth(Storage, BorrowValue, Capabilities) &Account) {
12        // Ensure the user has a staking resource; if not, create one.
13        if signer.storage.borrow<&TitStakingX0X.TitStake>(from: TitStakingX0X.StakingStoragePath) == nil {
14            let staking <- TitStakingX0X.createTitStaking(owner: signer.address)
15            signer.storage.save(<-staking, to: TitStakingX0X.StakingStoragePath)
16            signer.capabilities.publish(
17                signer.capabilities.storage.issue<&{TitStakingX0X.TitStakePublic}>(TitStakingX0X.StakingStoragePath),
18                at: TitStakingX0X.StakingPublicPath
19            )
20        }
21
22        self.address = signer.address
23        self.nfts <- {}
24
25        // Ensure that an assets dictionary exists for this owner.
26        if !TitStakingX0X.hasAssets(owner: signer.address) {
27            TitStakingX0X.createAssetsDictionary(owner: signer.address)
28        }
29
30        // Borrow the staking resource.
31        self.stakingRef = signer.storage.borrow<&TitStakingX0X.TitStake>(from: TitStakingX0X.StakingStoragePath)
32            ?? panic("Staking resource not found!")
33
34        // Borrow the user's NFT collection (must implement NonFungibleToken.Provider).
35        let collectionRefCourtiers = signer.storage.borrow<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Provider}>(from: /storage/courtiersXCollection)
36            ?? panic("Could not borrow a reference to the NFT collection")
37
38        // Borrow the user's NFT collection (must implement NonFungibleToken.Provider).
39        let collectionRefPages = signer.storage.borrow<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Provider}>(from: /storage/pagesXCollection)
40            ?? panic("Could not borrow a reference to the NFT collection")
41
42        // Ensure all input arrays are of equal length.
43        if nftIds.length != nftTypes.length || nftIds.length != nftNames.length {
44            panic("Input arrays must be of equal length")
45        }
46
47        for i in [nftTypes.length -1] {
48            // if the type is pages, the we'll use the pages collection ref and if the type is courtiers, then we'll use the courtiers collection ref
49            // Withdraw the NFT from the user's collection.
50            if nftTypes[i] == "pages" {
51                self.nfts[i] <-! collectionRefPages.withdraw(withdrawID: nftIds[i])
52            } else if nftTypes[i] == "courtiers" {
53                self.nfts[i] <-! collectionRefCourtiers.withdraw(withdrawID: nftIds[i]) 
54            } else {
55                panic("Unsupported NFT type") 
56            }
57        }
58
59
60
61        
62
63    }
64
65    execute {
66
67        // Loop over each NFT to stake.
68        for i in [nftIds.length - 1] {
69            let id = nftIds[i]
70            let type = nftTypes[i]
71            let name = nftNames[i]
72            let level = levels[i]
73
74            let nft <- self.nfts.remove(key: i)
75                ?? panic("NFT not found in dictionary")
76
77                // Stake the NFT with its level.
78                self.stakingRef.stakeNFT(
79                    nft: <- nft,
80                    nftID: id,
81                    nftType: type,
82                    nftName: name,
83                    level: level,
84                    owner: self.address
85                )
86
87        }
88
89        destroy self.nfts
90    }
91}