Smart Contract

Flowmap

A.483f0fe77f0d59fb.Flowmap

Deployed

2h ago
Feb 28, 2026, 03:07:36 PM UTC

Dependents

0 imports
1import NonFungibleToken from 0x1d7e57aa55817448
2import FungibleToken from 0xf233dcee88fe0abe
3import FlowToken from 0x1654653399040a61
4
5access(all)
6contract Flowmap: NonFungibleToken{ 
7	access(all)
8	event ContractInitialized()
9	
10	access(all)
11	event Withdraw(id: UInt64, from: Address?)
12	
13	access(all)
14	event Deposit(id: UInt64, to: Address?)
15	
16	access(all)
17	let CollectionStoragePath: StoragePath
18	
19	access(all)
20	let CollectionPublicPath: PublicPath
21	
22	access(all)
23	var totalSupply: UInt64
24	
25	access(all)
26	let inscriptionFee: UFix64
27	
28	access(all)
29	resource NFT: NonFungibleToken.NFT{ 
30		access(all)
31		let id: UInt64
32		
33		access(all)
34		let inscription: String
35		
36		access(all)
37		fun createEmptyCollection(): @{NonFungibleToken.Collection}{ 
38			return <-create Collection()
39		}
40
41		access(all) view fun getViews(): [Type] { 
42			return []
43		}
44		
45		access(all) view fun resolveView(_ view: Type): AnyStruct? { 
46			return nil
47		}
48		
49		init(){ 
50			self.id = Flowmap.totalSupply
51			self.inscription = Flowmap.totalSupply.toString().concat(".flowmap")
52			Flowmap.totalSupply = Flowmap.totalSupply + 1
53		}
54	}
55	
56	access(all)
57	resource interface CollectionPublic{ 
58		access(all)
59		fun getIDs(): [UInt64]
60		
61		access(all)
62		fun deposit(token: @{NonFungibleToken.NFT})
63		
64		access(all)
65		view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}?
66		
67		access(all)
68		fun borrowFlowmap(id: UInt64): &Flowmap.NFT?{ 
69			post{ 
70				result == nil || result?.id == id:
71					"Cannot borrow Flowmap reference: the ID of the returned reference is incorrect"
72			}
73		}
74	}
75	
76	access(all)
77	resource Collection: CollectionPublic, NonFungibleToken.Provider, NonFungibleToken.Receiver, NonFungibleToken.Collection, NonFungibleToken.CollectionPublic{ 
78		access(all)
79		var ownedNFTs: @{UInt64:{ NonFungibleToken.NFT}}
80		
81		init(){ 
82			self.ownedNFTs <-{} 
83		}
84		
85		access(all)
86		view fun getIDs(): [UInt64]{ 
87			return self.ownedNFTs.keys
88		}
89		
90		access(NonFungibleToken.Withdraw)
91		fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT}{ 
92			let token <- self.ownedNFTs.remove(key: withdrawID) ?? panic("missing Flowmap")
93			emit Withdraw(id: token.id, from: self.owner?.address)
94			return <-token
95		}
96		
97		access(all)
98		fun deposit(token: @{NonFungibleToken.NFT}){ 
99			let token <- token as! @Flowmap.NFT
100			let id: UInt64 = token.id
101			let oldToken <- self.ownedNFTs[id] <- token
102			emit Deposit(id: id, to: self.owner?.address)
103			destroy oldToken
104		}
105		
106		access(all)
107		view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}?{ 
108			return (&self.ownedNFTs[id] as &{NonFungibleToken.NFT}?)!
109		}
110		
111		access(all)
112		fun borrowFlowmap(id: UInt64): &Flowmap.NFT?{ 
113			if self.ownedNFTs[id] != nil{ 
114				let ref = (&self.ownedNFTs[id] as &{NonFungibleToken.NFT}?)!
115				return ref as! &Flowmap.NFT
116			}
117			return nil
118		}
119		
120		access(all)
121		view fun getSupportedNFTTypes():{ Type: Bool}{ 
122			panic("implement me")
123		}
124		
125		access(all)
126		view fun isSupportedNFTType(type: Type): Bool{ 
127			panic("implement me")
128		}
129		
130		access(all)
131		fun createEmptyCollection(): @{NonFungibleToken.Collection}{ 
132			return <-create Collection()
133		}
134	}
135	
136	access(all)
137	fun createEmptyCollection(nftType: Type): @{NonFungibleToken.Collection}{ 
138		return <-create Collection()
139	}
140	
141	access(all)
142	fun inscribe(inscriptionFee: @FlowToken.Vault): @Flowmap.NFT{ 
143		pre{ 
144			Flowmap.totalSupply <= getCurrentBlock().height:
145				"Cannot inscribe more than the current block height"
146			inscriptionFee.balance >= Flowmap.inscriptionFee:
147				"Insufficient inscription fee"
148		}
149		(Flowmap.account.capabilities.get<&FlowToken.Vault>(/public/flowTokenReceiver).borrow<>()!).deposit(from: <-inscriptionFee)
150		return <-create Flowmap.NFT()
151	}
152	
153	access(all)
154	fun batchInscribe(inscriptionFee: @FlowToken.Vault, quantity: UFix64, receiver: Address){ 
155		pre{ 
156			Flowmap.totalSupply <= getCurrentBlock().height:
157				"Cannot inscribe more than the current block height"
158			inscriptionFee.balance >= Flowmap.inscriptionFee * quantity:
159				"Insufficient inscription fee"
160		}
161		(Flowmap.account.capabilities.get<&FlowToken.Vault>(/public/flowTokenReceiver).borrow<>()!).deposit(from: <-inscriptionFee)
162		let receiverRef = getAccount(receiver).capabilities.get<&{Flowmap.CollectionPublic}>(Flowmap.CollectionPublicPath).borrow<>() ?? panic("Could not borrow reference to the owner's Collection!")
163		var i = 0
164		while i < Int(quantity){ 
165			receiverRef.deposit(token: <-create Flowmap.NFT())
166			i = i + 1
167		}
168	}
169
170	access(all) fun resolveContractView(resourceType: Type?, viewType: Type): AnyStruct? {
171        return nil
172    }
173
174    access(all) view fun getContractViews(resourceType: Type?): [Type] {
175        return []
176    }
177	
178	init(){ 
179		self.totalSupply = 0
180		self.inscriptionFee = 0.025
181		self.CollectionStoragePath = /storage/flowmapCollection
182		self.CollectionPublicPath = /public/flowmapCollection
183		emit ContractInitialized()
184	}
185}
186