Adding Symbol and Decimals to the NEP-17 Smart Contract
What are the Symbol and Decimal methods?
decimals methods are part of the
standard. They are used to define the
’s symbol and the number of decimals it uses. The
symbol method returns a string, while the
decimals method returns an integer. Both methods are mandatory and should not change after the token is deployed.
Adding the Symbol and Decimals methods
Let’s add the
decimals methods to our smart contract. Open the contract file and add the following code:
Testing the Symbol and Decimals methods
Start testing your contract by running the
symbol method. The output should be the string
Next, run the
decimals method. The output should be the integer
Making the Symbol and Decimals methods read-only
The standard implies that the
decimals methods should be read-only. This means that they should not make changes to the storage. Let’s fix this before we continue.
decimals methods to be read-only: