New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEP: Non-fungible Token Standard #41
Open
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
db5fe38
Create nep-10.mediawiki
hal0x2328 a5123cf
Merge pull request #1 from Splyse/NFT
hal0x2328 d70627c
resolves conflicts
7315094
formatting changes and a few text modifications
fb3adde
amend
43dd18a
add events
84dbfb0
change state to accepted
erikzhang File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
Diff settings
176
nep-11.mediawiki
@@ -0,0 +1,176 @@ | |||
<pre> | |||
NEP: 11 | |||
Title: Non-Fungible Token Standard | |||
Author: Joe Stewart <hal0x2328@splyse.tech>, Shane Mann <fetter@splyse.tech> | |||
Type: Standard | |||
Status: Accepted | |||
Created: 2018-04-18 | |||
</pre> | |||
|
|||
==Abstract== | |||
|
|||
This NEP defines a standard non-fungible token system for the NEO Smart Economy. | |||
|
|||
==Motivation== | |||
|
|||
NFTs are required to track, exchange and enforce ownership of digital assets. A non-fungible token (NFT) can be thought of like a property deed - each one is unique and carries some non-mutable information (e.g. the physical address of the property). Other information, such as the owner of the property, can be changed. Also, we provide a built-in optional divisibility within each non-fungible asset. This allows for high value objects to be tokenized more effectively. | |||
|
|||
==Specification== | |||
|
|||
===Methods=== | |||
|
|||
====name==== | |||
|
|||
<pre> | |||
public static string name() | |||
</pre> | |||
|
|||
Returns the name of the token. e.g. <code>"MyNFT"</code>. | |||
|
|||
This method MUST always return the same value every time it is invoked. | |||
|
|||
====symbol==== | |||
|
|||
<pre> | |||
public static string symbol() | |||
</pre> | |||
|
|||
Returns a short string symbol of the token managed in this contract. e.g. <code>"MNFT"</code>. This symbol SHOULD be short (3-8 characters is recommended), with no whitespace characters or new-lines and SHOULD be limited to the uppercase latin alphabet (i.e. the 26 letters used in English). | |||
|
|||
This method MUST always return the same value every time it is invoked. | |||
|
|||
====totalSupply==== | |||
|
|||
<pre> | |||
public static BigInteger totalSupply() | |||
</pre> | |||
|
|||
Returns the total token supply deployed in the system. | |||
|
|||
====decimals==== | |||
|
|||
<pre> | |||
public static byte decimals() | |||
</pre> | |||
|
|||
Returns the number of decimals used by the token - e.g. <code>8</code>, means to divide the token amount by <code>100,000,000</code> to get its user representation. | |||
|
|||
If the token managed in this contract is indivisible, the function SHOULD return <code>0</code>. | |||
|
|||
If the function returns a non-zero value, all of the ''OPTIONAL'' methods in this standard MUST be implemented. | |||
|
|||
This method MUST always return the same value every time it is invoked. | |||
|
|||
====tokens==== | |||
|
|||
<pre> | |||
public static enumerator tokens() | |||
</pre> | |||
|
|||
Returns an <code>enumerator</code> that contains all the tokens that have been issued in this contract. | |||
|
|||
====transfer==== | |||
|
|||
<pre> | |||
public static bool transfer(byte[] to, byte[] tokenid) | |||
</pre> | |||
|
|||
Transfers token with id <code>tokenid</code> to address <code>to</code>. | |||
|
|||
The parameter <code>tokenid</code> SHOULD be a valid NFT. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
The parameter <code>to</code> SHOULD be a 20-byte address. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
The function SHOULD return <code>false</code> if the token that will be transferred has more than one owner. | |||
|
|||
If the method succeeds, it MUST fire the <code>transfer</code> event, and MUST return <code>true</code>, even if the token is sent to the owner himself. | |||
|
|||
The function SHOULD check whether the owner address equals the caller contract hash. If so, the transfer SHOULD be processed; If not, the function SHOULD use the SYSCALL <code>Neo.Runtime.CheckWitness</code> to verify the transfer. | |||
|
|||
If the <code>to</code> address is a deployed contract, the function SHOULD check the <code>payable</code> flag of this contract to decide whether it should transfer the tokens to this contract. | |||
|
|||
If the transfer is not processed, the function SHOULD return <code>false</code>. | |||
|
|||
<pre> | |||
public static bool transfer(byte[] from, byte[] to, BigInteger amount, byte[] tokenid) | |||
</pre> | |||
|
|||
''OPTIONAL'': This method MUST be implemented if <code>decimals() > 0</code>. | |||
|
|||
Transfers an <code>amount</code> of tokens with id <code>tokenid</code> from address <code>from</code> to address <code>to</code>. | |||
|
|||
The parameter <code>tokenid</code> SHOULD be a valid NFT. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
The parameters <code>from</code> and <code>to</code> SHOULD be 20-byte addresses. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
The parameter <code>amount</code> SHOULD be greater than or equal to <code>0</code> and SHOULD be less than or equal to <code>pow(10, decimals())</code>. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
The function SHOULD return <code>false</code> if the <code>from</code> account balance does not have enough tokens to spend. | |||
|
|||
If the method succeeds, it MUST fire the <code>transfer</code> event, and MUST return <code>true</code>, even if the <code>amount</code> is <code>0</code>, or the token is sent to the owner himself. | |||
|
|||
The function SHOULD check whether the <code>from</code> address equals the caller contract hash. If so, the transfer SHOULD be processed; If not, the function SHOULD use the SYSCALL <code>Neo.Runtime.CheckWitness</code> to verify the transfer. | |||
|
|||
If the <code>to</code> address is a deployed contract, the function SHOULD check the <code>payable</code> flag of this contract to decide whether it should transfer the tokens to this contract. | |||
|
|||
If the transfer is not processed, the function SHOULD return <code>false</code>. | |||
|
|||
====ownerOf==== | |||
|
|||
<pre> | |||
public static enumerator ownerOf(byte[] tokenid) | |||
</pre> | |||
|
|||
Returns an <code>enumerator</code> that contains all the co-owners that own the specified token. | |||
|
|||
The parameter <code>tokenid</code> SHOULD be a valid NFT. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
====tokenURI==== | |||
|
|||
<pre> | |||
public static string tokenURI(byte[] tokenid) | |||
</pre> | |||
|
|||
Returns a distinct Uniform Resource Identifier (URI) for a given asset. The URI data of a token supplies a reference to get more information about a specific token or its data. | |||
|
|||
The parameter <code>tokenid</code> SHOULD be a valid NFT. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
====balanceOf==== | |||
|
|||
<pre> | |||
public static BigInteger balanceOf(byte[] owner, byte[] tokenid) | |||
</pre> | |||
|
|||
Returns the balance of the specified token for the specified owner's account. | |||
|
|||
The parameter <code>tokenid</code> SHOULD be a valid NFT. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
The parameter <code>owner</code> SHOULD be a 20-byte address. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
If the <code>owner</code> is an unused address, or it's not the owner of the specified token, this method SHOULD return <code>0</code>. | |||
|
|||
====tokensOfOwner==== | |||
|
|||
<pre> | |||
public static enumerator tokensOfOwner(byte[] owner) | |||
</pre> | |||
|
|||
Returns an <code>enumerator</code> that contains all the tokens owned by the specified address. | |||
|
|||
The parameter <code>owner</code> SHOULD be a 20-byte address. If not, this method SHOULD <code>throw</code> an exception. | |||
|
|||
===Events=== | |||
|
|||
====transfer==== | |||
|
|||
<pre> | |||
public static event transfer(byte[] from, byte[] to, BigInteger amount, byte[] tokenid) | |||
</pre> | |||
|
|||
MUST trigger when tokens are transferred, including zero value transfers. | |||
|
|||
A token contract which creates new tokens SHOULD trigger a <code>transfer</code> event with the <code>from</code> address set to <code>null</code> when tokens are created. | |||
|
|||
==Rationale== | |||
|
|||
==Implementation== |
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.