VRC-721
VRC-721 Non-Fungible Token Standard
VRC-721 is a set of standard interfaces, for issuing non-fungible tokens (NFT) on the Vision network. VRC-721 is fully compatible with ERC-721.
VRC-721 Specification
Every VRC-721 compliant contract must implement the VRC721 and VRC-165 interfaces (subject to “caveats” below).
VRC-721
pragma solidity ^0.4.20;
interface VRC721 {
//This emits when ownership of any NFT changes by any mechanism
event Transfer(address indexed _from, address indexed _to,uint256 indexed _tokenId);
//This emits when the approved address for an NFT is changed or reaffirmed
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
//This emits when an operator is enabled or disabled for an owner
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
//The number of NFTs owned by `_owner`, possibly zero
function balanceOf(address _owner) external view returns (uint256);
//The address of the owner of the NFT
function ownerOf(uint256 _tokenId) external view returns (address);
//Transfers the ownership of an NFT from one address to another address
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
//Transfers the ownership of an NFT from one address to another address
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
//Transfer ownership of an NFT
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
//Change or reaffirm the approved address for an NFT
function approve(address _approved, uint256 _tokenId) external payable;
//Enable or disable approval for a third party ("operator") to manage all of `msg.sender`'s assets
function setApprovalForAll(address _operator, bool _approved) external;
//Get the approved address for a single NFT
function getApproved(uint256 _tokenId) external view returns (address);
//Query if an address is an authorized operator for another address
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
VRC-165
interface VRC165 {
//Query if a contract implements an interface
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
VRC721TokenReceiver
A wallet/broker/auction application MUST implement the wallet interface if it will accept safe transfers.
interface VRC721TokenReceiver {
//Handle the receipt of an NFT
function onVRC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4);
}
metadata extension
The metadata extension is OPTIONAL for VRC-721 smart contracts. This allows your smart contract to be interrogated for its name and for details about the assets which your NFTs represent.
interface VRC721Metadata {
//A descriptive name for a collection of NFTs in this contract
function name() external view returns (string _name);
//An abbreviated name for NFTs in this contract
function symbol() external view returns (string _symbol);
//A distinct Uniform Resource Identifier (URI) for a given asset
function tokenURI(uint256 _tokenId) external view returns (string);
}
This is the “VRC721 Metadata JSON Schema” referenced above.
{
"title": "Asset Metadata",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents"
},
"description": {
"type": "string",
"description": "Describes the asset to which this NFT represents"
},
"image": {
"type": "string",
"description": "A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
}
}
}
enumeration extension
The enumeration extension is OPTIONAL for VRC-721 smart contracts. This allows your contract to publish its full list of NFTs and make them discoverable.
interface VRC721Enumerable {
//Count NFTs tracked by this contract
function totalSupply() external view returns (uint256);
//Enumerate valid NFTs
function tokenByIndex(uint256 _index) external view returns (uint256);
//Enumerate NFTs assigned to an owner
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
}
Updated almost 3 years ago