πΊNFT
Non Fungible Tokens
NFT is not stored in the user's wallet, instead, each NFT exists in the NFT contract and is unique.
The role of the NFT contract is to keep accounts, that is, it is responsible for processing the creation, storage and transfer of NFT. This makes NFTs ideal for representing ownership of an asset, such as a piece of digital content or event tickets.
Transferring an NFTβ
Transferring an NFT can happen in two scenarios: (1) you ask to transfer an NFT, and (2) an authorized account asks to transfer the NFT.
Track real-time events (such as money transfers) by implementing the NFT event standard. Events are simple to use because they are just login messages formatted in a standardized way. Since these records are on-chain data, this is public information.
Mint NFTs with the matmo SDKs
Mint NFT
This #SDK provides a directory.
This tutorial covers the simple-nft example.
Clone the matmo-core repository.
How Does it Work?β
Assume you want to attach an NFT to a call on the receiver contract. The workflow is as follows:
You call
nft_transfer_call
in the NFT-contract passing: the receiver, a message, and the token-id of .The NFT contract transfers the NFT to the receiver.
The NFT contract calls
receiver.nft_on_transfer(sender, token-owner, token-id, msg)
.The NFT contract handles errors in the
nft_resolve_transfer
callback.The NFT contract returns
true
if it succeeded.
The following is the access code, buried when casting NFT
The sender may first ask the receiver to acknowledge pending transfers off-chain.
This comes in the form of a multi-agent transaction request.
A multi-agent transaction contains multiple signatures, and each signature corresponds to an account on the chain.
The nft_on_transfer methodβ
From the workflow above it follows that the receiver we want to call needs to implement the nft_on_transfer
method. When executed, such method will know:
Who is sending the NFT, since it is a parameter
Who is the current owner, since it is a parameter
Which NFT was transferred, since it is a parameter.
If there are any parameters encoded as a message
The nft_on_transfer
must return true if the NFT has to be returned to the sender.
Last updated