This is the complete reference implementation of the ERC-721 non-fungible token standard for the Ethereum and Wanchain blockchains. This is an open source project, complete with Specron testing.
Purpose of this implementation is to provide a good starting point for anyone who wants to use and develop non-fungible tokens on the Ethereum and Wanchain blockchains. Instead of re-implementing the ERC-721 yourself you can use this code which has gone through multiple audits and we hope it will be extensively used by the community in the future.
If you are looking for a more feature-rich and advanced ERC721 implementation, then check out the 0xcert Framework.
All contracts and tests are in the src folder. There are multiple implementations and you can select between:
nf-token.sol
: This is the base ERC-721 token implementation (with support for ERC-165).nf-token-metadata.sol
: This implements optional ERC-721 metadata features for the token contract. It implements a token name, a symbol and a distinct URI pointing to a publicly exposed ERC-721 JSON metadata file.nf-token-enumerable.sol
: This implements optional ERC-721 support for enumeration. It is useful if you want to know the total supply of tokens, to query a token by index, etc.
Other files in the tokens and utils directories named like erc*.sol
are interfaces and define the respective standards.
Mock contract showing basic contract usage are available in mocks folder.
There are also test mocks which can be seen here. These are specifically made to test different edge cases and behaviours and should NOT be used as a reference for implementation.
- NodeJS 9.0+ is supported
- Windows, Linux or macOS
This is the recommended installation method if you want to use this package in your own JavaScript project.
This project is released as an npm module. You must install it using the npm
command:
$ npm install @0xcert/[email protected]
This is the recommended installation method if you want to improve the 0xcert/ethereum-erc721
project.
Clone this repository and install the required npm
dependencies:
$ git clone [email protected]:0xcert/ethereum-erc721.git
$ cd ethereum-erc721
$ npm install
Make sure that everything has been set up correctly:
$ npm run test
To interact with this package's contracts within JavaScript code, you simply need to require this package's .json
files:
const contract = require("@0xcert/ethereum-erc721/build/nf-token-enumerable.json");
console.log(contract);
You can quickly deploy a contract with this library using Remix IDE. Here is one example.
You have created and have possession of unique glass-blown artwork (each having a serial number / lot number) which you would like to sell using the Ethereum or Wanchain mainnet. You will sell non-fungible tokens and the buyers would be able to trade those to other people. One token per piece of artwork. You commit to anybody holding these tokens that they may redeem their token and take physical posession of the art.
To do this, simply paste the code belowe into Remix and deploy the smart contract. You will "mint" a token for each new piece of artwork you want to see. Then you will "burn" that token when you surrender physical possession of the piece.
pragma solidity 0.5.6;
import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";
/**
* @dev This is an example contract implementation of NFToken with metadata extension.
*/
contract MyArtSale is
NFTokenMetadata,
Ownable
{
/**
* @dev Contract constructor. Sets metadata extension `name` and `symbol`.
*/
constructor()
public
{
nftName = "Frank's Art Sale";
nftSymbol = "FAS";
}
/**
* @dev Mints a new NFT.
* @param _to The address that will own the minted NFT.
* @param _tokenId of the NFT to be minted by the msg.sender.
* @param _uri String representing RFC 3986 URI.
*/
function mint(
address _to,
uint256 _tokenId,
string calldata _uri
)
external
onlyOwner
{
super._mint(_to, _tokenId);
super._setTokenUri(_tokenId, _uri);
}
}
You should contact a lawyer before holding an auction, or selling anything really. Specifically, laws for auctions vary wildly by jurisdiction. This application is provided only as an example of the technology and is not legal advice.
We already deployed some contracts to Ropsten network. You can play with them RIGHT NOW. No need to install software. In this test version of the contract, anybody can mint
or burn
tokens, so don't use it for anything important.
We already deployed some contracts to testnet network. You can play with them RIGHT NOW. No need to install software. In this test version of the contract, anybody can mint
or burn
tokens, so don't use it for anything important.
See CONTRIBUTING.md for how to help out.
You are somebody that reads documentation on smart contracts and understands how the ERC-721 Token Reference Implementation works. So you have unique skills and your time is valuable. We will pay you for your contributions to this project in the form of bug reports.
If your project depends on ERC-721 or you want to help improve the assuarance of this project then you can pledge a bounty. This means you will commit to pay researchers that demonstrate a problem. Contact us at [email protected] if interested. Thank you.
Read the full bug bounty program.
See LICENSE for details.