Smart Contract

MarketplaceBlacklistV2

A.88dd257fcf26d3cc.MarketplaceBlacklistV2

Deployed

2h ago
Feb 28, 2026, 06:38:56 PM UTC

Dependents

0 imports
1pub contract MarketplaceBlacklistV2 {
2
3    pub let AdminStoragePath: StoragePath
4
5    // listingId : nftId
6    priv let blacklist: {UInt64: UInt64}
7
8    pub event MarketplaceBlacklistAdd(listingId: UInt64, nftId: UInt64)
9
10    pub event MarketplaceBlacklistRemove(listingId: UInt64, nftId: UInt64)
11
12    pub resource Administrator {
13        
14        pub fun add(listingId: UInt64, nftId: UInt64) {
15            MarketplaceBlacklistV2.blacklist[listingId] = nftId
16            emit MarketplaceBlacklistAdd(listingId: listingId, nftId: nftId)
17        }
18
19        pub fun remove(listingId: UInt64) {
20            pre {
21                MarketplaceBlacklistV2.blacklist[listingId] != nil: "listingId not exist"
22            }
23            let nftId = MarketplaceBlacklistV2.blacklist.remove(key: listingId)
24            if let unwrappedNftId = nftId {
25                emit MarketplaceBlacklistRemove(listingId: listingId, nftId: unwrappedNftId)
26            }
27            assert(nftId != nil, message: "Not been removed successfully!")
28        }
29        
30    }
31
32    init () {
33        self.blacklist = {}
34        self.AdminStoragePath = /storage/marketplaceBlacklistV2
35
36        let admin <- create Administrator()
37        self.account.save(<-admin, to: self.AdminStoragePath)
38    }
39
40    pub fun exist(listingId: UInt64): Bool {
41        return self.blacklist.containsKey(listingId)
42    }
43
44    pub fun getKeysAmount(): Int {
45        return self.blacklist.keys.length
46    }
47
48}
49