VIP | Title | Category | Author | Status | CreatedAt |
---|---|---|---|---|---|
181 |
Non-fungible Token Standard |
Application |
Vechain Foundation |
Superseded |
2018-09-01 |
This standard (VIP-181) has been superseded in favour of the ERC721 standard on Ethereum. Development and usage of VIP-181 are strongly discouraged, and existing implementations are advised to migrate to ERC721.
For detailed guidelines on utilizing ERC721 for non-fungible tokens on the VechainThor Network, please refer to the documentation here.
The VIP-181 Standard outlines a set of common methods that all NFT tokens can follow on the VechainThor Network to transfer tokens, as well as allow tokens to be approved so they can be spent by another on-chain thrid party safely.
function name() public view returns(string)
Gets the name of the token.
Return: the name of the token
function symbol() public view returns(string)
Gets the symbol of the token.
Return: the symbol of the token
function totalSupply() public view returns(uint256)
Gets the total token supply.
Return: the total token supply
function balanceOf(address _owner) public view returns(uint256)
Gets the amount of NTFs the _owner
possesses.
Params:
- _owner: the address of owner
Return: the balance of owner
function ownerOf(uint256 _tokenId) public view returns(address)
Gets the owner of _tokenId
.
Params:
- _tokenId: the token id
Return: the owner address
function transferFrom(address _from, address _to, uint256 _tokenId) public
Transfer ownership of an NFT from address _from
to address _to
, and MUST emit the Transfer
event. The function MUST throw if the transaction failed.
Params:
- _from: the payment address
- _to: the receiver address
- _tokenId: the token id
function approve(address _spender, uint256 _tokenId) public
Allows _spender
to control your token with _tokenId
, and MUST emit the Approval
event. If this function is called again it overwrites the current allowance with _tokenId
.
Params:
- _spender: the spender address
- _tokenId: the token id
function getApproved(uint256 _tokenId) public view returns(address)
Get the approved address for _tokenId
Return: the approved address
function setApprovalForAll(address _operator, bool _approved) public
Enable or disable approval for _operator
address to manage all your assets, and MUST emit the ApprovalForAll
event.
Params:
- _operator: the approved address
- _approved: True if the operator is approved, false to revoke approval
function isApprovedForAll(address _owner, address _operator) public view returns(bool)
Check if an address is an authorized operator for another address
Params:
- _owner: the address of owner
- _operator: the address that acts on behalf of the owner
Return: the result of authorization
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)
MUST trigger when the following scenario occurs:
- when transferring tokens
- when minting tokens
- when burning tokens
event Approval(address indexed _owner, address indexed _spender, uint256 indexed _tokenId)
MUST trigger when call the approve
method successfully.
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)
MUST trigger when call the setApprovalForAll
method successfully.