Skip to content
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

Closed
wants to merge 35 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
db5fe38
Create nep-10.mediawiki
hal0x2328 Apr 19, 2018
a5123cf
Merge pull request #1 from Splyse/NFT
hal0x2328 Apr 19, 2018
d70627c
resolves conflicts
May 22, 2018
7315094
formatting changes and a few text modifications
May 22, 2018
fb3adde
amend
May 22, 2018
43dd18a
add events
May 22, 2018
84dbfb0
change state to accepted
erikzhang Oct 27, 2018
22b3a26
Amend `Transfer` event
erikzhang May 20, 2019
8dfa5e7
Ament `tokenURI()` method
erikzhang May 20, 2019
ee7a803
Support data URI scheme
erikzhang May 21, 2019
4947667
Restrictions on JSON file
erikzhang May 22, 2019
d0a10d9
Merge remote-tracking branch 'upstream/master' into nft
Jul 11, 2019
ec6125d
Initial rework
Jul 12, 2019
b3891af
Moved tokenURI to end. Added properties for immutable onchain properties
Jul 12, 2019
094c65b
Removed rationale section
Jul 12, 2019
4bda135
No reason for name to be required in tokenURI
Jul 12, 2019
4ea348b
Move metadata schema to its own section
Jul 12, 2019
46e2854
Fix formatting
Jul 12, 2019
77f078f
Change title for metadata schema
Jul 12, 2019
034a9b2
Added word optionally
Jul 12, 2019
052d4c9
Finish tokensOf
Jul 12, 2019
9b838e4
Merge pull request #2 from WyattMufson/nft
hal0x2328 Jul 18, 2019
208d630
Remove tokenURI
Jul 29, 2019
f1ff9f5
Merge pull request #3 from WyattMufson/nft
hal0x2328 Jul 29, 2019
dc0a4c2
Remove uri
Jul 30, 2019
3eebf67
Merge remote-tracking branch 'upstream/master' into nft
Jul 30, 2019
74c6b42
Merge pull request #4 from WyattMufson/nft
hal0x2328 Jul 30, 2019
982f6a6
Update tokensOf and the metadata schema
Aug 2, 2019
f0c7e99
Merge pull request #5 from WyattMufson/nft
hal0x2328 Aug 2, 2019
aab08d8
Add examples to json sschema
corollari Aug 7, 2019
cbfd0a7
Fix minor grammar issues
corollari Aug 7, 2019
57ec7ea
Merge pull request #6 from corollari/patch-2
hal0x2328 Aug 7, 2019
61e53a0
Merge pull request #7 from corollari/patch-3
hal0x2328 Aug 7, 2019
471aaf0
Merge branch 'master' into master
erikzhang Jan 14, 2021
5c68859
Merge branch 'master' into master
erikzhang Jan 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
amend
  • Loading branch information
erikzhang committed May 22, 2018
commit fb3addec69a4ba3c258da1ea1866b9f8bbcc6ccb
151 changes: 96 additions & 55 deletions nft.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -19,104 +19,145 @@ NFTs are required to track, exchange and enforce ownership of digital assets. A

===Methods===

====balanceOf====
====name====

<pre>
public static BigInteger balanceOf(byte[] owner)
public static string name()
</pre>
Returns current total tokens owned by <code>owner</code>.

====circulation====
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 BigInteger circulation()
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 of tokens in the system.

====mintToken====
<pre>
public static bool mintToken(byte[] owner, byte[] ROData, byte[] RWData, string URI)
</pre>
Creates a new non-fungible token. This fails and returns <code>False</code> if <code>owner</code> is not the contract owner.
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>.

====modifyRWData====
<pre>
public static bool modifyRWData(byte[] tokenid, byte[] RWData)
</pre>
Modifies a token's read/write data. This fails and returns <code>False</code> if <code>owner</code> is not the contract owner. Read-write data represents data that can be changed in the token, i.e., the owner of a property or work of art.
If the function returns a non-zero value, all of the ''OPTIONAL'' methods in this standard MUST be implemented.

====modifyURI====
<pre>
public static bool modifyURI(byte[] tokenid, string URI)
</pre>
Modifies a token's URI. This fails and returns <code>False</code> if <code>owner</code> is not the contract owner. The URI data of a token supplies a reference to get more information about a specific token or its data.
This method MUST always return the same value every time it is invoked.

====name====
<pre>
public static string name()
</pre>
Returns the name of the token.
====tokens====

====ownerOf====
<pre>
public static byte[] ownerOf(byte[] tokenid)
public static enumerator tokens()
</pre>
Returns the owner of token with id <code>tokenid</code>.

====symbol====
<pre>
public static string symbol()
</pre>
Returns the token symbol.
Returns an <code>enumerator</code> that contains all the tokens that have been issued in this contract.

====transfer====

====tokenOfOwnerByIndex====
<pre>
public static byte[] tokenOfOwnerByIndex(byte[] owner, int idx)
public static bool transfer(byte[] to, byte[] tokenid)
</pre>
Returns the token owned by <code>owner</code> at index <code>idx</code>.

====tokenROData====
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 byte[] tokenROData(byte[] tokenid)
public static bool transfer(byte[] from, byte[] to, BigInteger amount, byte[] tokenid)
</pre>
Returns the read-only data for token with id <code>tokenid</code>. Read-only data represents immutable data contained in the token, i.e., a property address for a property or the artist's name for a work of art.

====tokenRWData====
''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 byte[] tokenRWData(byte[] tokenid)
public static enumerator ownerOf(byte[] tokenid)
</pre>
Returns the read-write data for token with id <code>tokenid</code>. Read-write data represents data that can be changed in the token, i.e., the owner of a property or work of art.

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 the URI of token with id <code>tokenid</code>. The URI data of a token supplies a reference to get more information about a specific token or its data.

====transfer====
<pre>
public static bool transfer(byte[] from, byte[] to, byte[] tokenid)
</pre>
Transfers token with id <code>tokenid</code> from address <code>from</code> to address <code>to</code>. If the <code>from</code> address does not equal the sender of the transaction this returns <code>False</code>, <code>True</code> otherwise.
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====

====transferFrom====
<pre>
public static bool transferFrom(byte[] from, byte[] to, byte[] tokenid)
public static BigInteger balanceOf(byte[] owner, byte[] tokenid)
</pre>
Transfers a token with id <code>tokenid</code> from address <code>from</code> to address <code>to</code> if the from address has been approved by the <code>approve()</code> method. If the <code>from</code> address is not the owner of the token or if there is no approval this returns <code>False</code>, <code>True</code> otherwise.

====approve====
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 bool approve(byte[] owner, byte[] spender, byte[] tokenid, bool revoke)
public static enumerator tokensOfOwner(byte[] owner)
</pre>
Approves token <code>tokenid</code> owned by <code>owner</code> to be spent by <code>spender</code> using the <code>transferFrom()</code> method. If <code>revoke</code> is set to <code>1</code> the approval is revoked. A value of <code>True</code> is returned if the operation is approved. <code>False</code> is returned if the approval is denied because of incorrect permissions (owner is not in fact the owner, for example).

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.

==Rationale==

Expand Down