diff --git a/docs/modules/ROOT/pages/erc20.adoc b/docs/modules/ROOT/pages/erc20.adoc index 852cdf7d3..9f2c7bd9e 100644 --- a/docs/modules/ROOT/pages/erc20.adoc +++ b/docs/modules/ROOT/pages/erc20.adoc @@ -62,7 +62,13 @@ It is important to understand that `decimals` is _only used for display purposes You'll probably want to use a `decimals` value of `18`, just like Ether and most ERC20 token contracts in use, unless you have a very special reason not to. When minting tokens or transferring them around, you will be actually sending the number `num GLD * 10^decimals`. -NOTE: By default, `ERC20` uses a value of `18` for `decimals`. To use a different value, you will need to call xref:api:token/ERC20.adoc#ERC20-_setupDecimals-uint8-[_setupDecimals] in your constructor. +NOTE: By default, `ERC20` uses a value of `18` for `decimals`. To use a different value, you will need to override the `decimals()` function in your contract. + +```solidity +function decimals() public view virtual override returns (uint8) { + return 16; +} +``` So if you want to send `5` tokens using a token contract with 18 decimals, the the method to call will actually be: diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 883c388d7..c10041504 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -35,7 +35,7 @@ contract('ERC20', function (accounts) { expect(await this.token.decimals()).to.be.bignumber.equal('18'); }); - describe('_setupDecimals', function () { + describe('set decimals', function () { const decimals = new BN(6); it('can set decimals during construction', async function () {