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-5 Amendment #44

Merged
merged 5 commits into from
Jun 25, 2018
Merged
Changes from all commits
Commits
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
74 changes: 56 additions & 18 deletions nep-5.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,93 @@ As the NEO blockchain scales, Smart Contract deployment and invocation will beco

In the method definitions below, we provide both the definitions of the functions as they are defined in the contract as well as the invoke parameters.

This standard defines two method types:

* '''(Required)''' : methods that are present on all NEP5 tokens.

===Methods===

====totalSupply====

* Syntax: <code>public static BigInteger totalSupply()</code>
<pre>
public static BigInteger totalSupply()
</pre>

* Remarks: "totalSupply" returns the total token supply deployed in the system.
Returns the total token supply deployed in the system.

====name====

* Syntax: <code>public static string name()</code>
<pre>
public static string name()
</pre>

* Remarks: "name" returns the token name.
Returns the name of the token. e.g. <code>"MyToken"</code>.

This method MUST always return the same value every time it is invoked.

====symbol====

* Syntax: <code>public static string symbol()</code>
<pre>
public static string symbol()
</pre>

Returns a short string symbol of the token managed in this contract. e.g. <code>"MYT"</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).

* Remarks: "symbol" returns the token symbol.
This method MUST always return the same value every time it is invoked.

====decimals====

* Syntax: <code>public static byte decimals()</code>
<pre>
public static byte decimals()
</pre>

* Remarks: "decimals" returns the number of decimals used by the token.
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.

This method MUST always return the same value every time it is invoked.

====balanceOf====

* Syntax: <code>public static BigInteger balanceOf(byte[] account)</code>
<pre>
public static BigInteger balanceOf(byte[] account)
</pre>

Returns the token balance of the <code>account</code>.

The parameter <code>account</code> SHOULD be a 20-byte address. If not, this method SHOULD <code>throw</code> an exception.

* Remarks: "balanceOf" returns the token balance of the '''account'''.
If the <code>account</code> is an unused address, this method MUST return <code>0</code>.

====transfer====

* Syntax: <code>public static bool transfer(byte[] from, byte[] to, BigInteger amount)</code>
<pre>
public static bool transfer(byte[] from, byte[] to, BigInteger amount)
</pre>

Transfers an <code>amount</code> of tokens from the <code>from</code> account to the <code>to</code> account.

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> MUST be greater than or equal to <code>0</code>. If not, this method SHOULD <code>throw</code> an exception.

The function MUST return <code>false</code> if the <code>from</code> account balance does not have enough tokens to spend.

* Remarks: "transfer" will transfer an '''amount''' of tokens from the '''from''' account to the '''to''' account. Contract '''MUST''' check the <code>payable</code> flag of the receiver contracts to decide whether it should transfer the tokens to those contracts.
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 <code>from</code> and <code>to</code> are the same address.

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>.

===Events===

====transfer====

* Syntax: <code>public static event Action<byte[], byte[], BigInteger> transfer</code>
<pre>
public static event transfer(byte[] from, byte[] to, BigInteger amount)
</pre>

MUST trigger when tokens are transferred, including zero value transfers.

A token contract which creates new tokens MUST trigger a <code>transfer</code> event with the <code>from</code> address set to <code>null</code> when tokens are created.

* Remarks: The "transfer" event is raised after a successful execution of the "transfer" method.
A token contract which burns tokens MUST trigger a <code>transfer</code> event with the <code>to</code> address set to <code>null</code> when tokens are burned.

==Implementation==

Expand Down