For Cadence 0.42 go to Legacy Docs
The NonFungibleToken
contract interface implements the Fungible Token Standard.
All NFT contracts are encouraged to import and implement this standard.
Source: NonFungibleToken.cdc
Network | Contract Address |
---|---|
Emulator | 0xf8d6e0586b0a20c7 |
Cadence Testing Framework | 0x0000000000000001 |
Testnet | 0x631e88ae7f1d7c20 |
Mainnet | 0x1d7e57aa55817448 |
Transactions
All NonFungibleToken
projects are encouraged to use
the generic token transactions and scripts in the flow-nft
repo.
They can be used for any token that implements the non-fungible token standard properly
without changing any code besides import addresses on different networks.
Events
Events emitted from all contracts follow a standard format:
_10A.{contract address}.{contract name}.{event name}
The components of the format are:
contract address
- the address of the account the contract has been deployed tocontract name
- the name of the contract in the source codeevent name
- the name of the event as declared in the source code
NonFungibleToken Events​
Contracts that implement the Non-Fungible Token standard get access to standard events that are emitted every time a relevant action occurs, like depositing and withdrawing tokens.
This means that projects do not have to implement their own custom events unless the standard events do not satisfy requirements they have for events.
The NonFungibleToken
events will have the following format:
_10A.{contract address}.NonFungibleToken.Deposited_10A.{contract address}.NonFungibleToken.Withdrawn
Where the contract address
is the NonFungibleToken
address on the network being queried.
The addresses on the various networks are shown above.
NonFungibleToken.Deposited​
_10access(all) event Deposited (_10 type: String,_10 id: UInt64,_10 uuid: UInt64,_10 to: Address?,_10 collectionUUID: UInt64_10)
Whenever deposit()
is called on a resource type that implements
NonFungibleToken.Collection
, the NonFungibleToken.Deposited
event is emitted
with the following arguments:
type: String
: The type identifier of the token being deposited.- Example:
A.4445e7ad11568276.TopShot.NFT
- Example:
id: UInt64
: The ID of the token that was deposited. Note: This may or may not be the UUID.- Example:
173838
- Example:
uuid: UInt64
: The UUID of the token that was deposited.- Example:
177021372071991
- Example:
to: Address?
: The address of the account that owns the Collection that received the token. If the collection is not stored in an account,to
will benil
.- Example:
0x4445e7ad11568276
- Example:
collectionUUID: UInt64
: The UUID of the Collection that received the token.- Example:
177021372071991
- Example:
NonFungibleToken.Withdrawn​
_10access(all) event Withdrawn (_10 type: String,_10 id: UInt64,_10 uuid: UInt64,_10 from: Address?,_10 providerUUID: UInt64_10)
Whenever withdraw()
is called on a resource type that implements
NonFungibleToken.Collection
, the NonFungibleToken.Withdrawn
event is emitted
with the following arguments:
type: String
: The type identifier of the token being withdrawn.- Example:
A.4445e7ad11568276.TopShot.NFT
- Example:
id: UInt64
: The id of the token that was withdrawn. Note: May or may not be the UUID.- Example:
113838
- Example:
uuid: UInt64
: The UUID of the token that was withdrawn.- Example:
177021372071991
- Example:
from: Address?
: The address of the account that owns the Collection that the token was withdrawn from. If the collection is not stored in an account,to
will benil
.- Example:
0x4445e7ad11568276
- Example:
providerUUID: UInt64
: The UUID of the Collection that the token was withdrawn from.- Example:
177021372071991
- Example:
NonFungibleToken.Updated​
_10access(all) event Updated(_10 type: String,_10 id: UInt64,_10 uuid: UInt64,_10 owner: Address?_10)
Whenever a non-fungible token is updated for whatever reason,
projects should call the NonFungibleToken.emitNFTUpdated()
function
to emit this event. It indicates to event listeners that they should query
the NFT to update any stored information they have about the NFT in their database.
type: String
: The type identifier of the token that was updated.- Example:
A.4445e7ad11568276.TopShot.NFT
- Example:
id: UInt64
: The ID of the token that was updated. Note: This may or may not be the UUID.- Example:
173838
- Example:
uuid: UInt64
: The UUID of the token that was updated.- Example:
177021372071991
- Example:
owner: Address?
: The address of the account that owns the Collection that owns the token. If the collection is not stored in an account,to
will benil
.- Example:
0x4445e7ad11568276
- Example: