Appearance
Solidity API
IERC20Metadata
_Interface for the optional metadata functions from the ERC20 standard. These functions are optional in the ERC20 standard but are widely used and considered best practice to implement. They provide human-readable information about the token.
Note: While these functions are marked as "optional" in ERC20, many services, exchanges, and applications expect these functions to be present and may not work correctly without them._
name
solidity
function name() external view returns (string)Returns the name of the token
This is an optional function in ERC20, but it's widely used and expected. The name should be a human-readable string (e.g., "USD Coin"). Once set, the name should never change during the lifetime of the contract.
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | string | A string representing the name of the token (e.g., "USD Coin") |
symbol
solidity
function symbol() external view returns (string)Returns the symbol of the token
This is an optional function in ERC20, but it's widely used and expected. The symbol should be a shorter version of the name, typically 3-5 characters (e.g., "USDC"). It's commonly used in trading pairs and UI displays. Once set, the symbol should never change during the lifetime of the contract.
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | string | A string representing the symbol of the token (e.g., "USDC") |
decimals
solidity
function decimals() external view returns (uint8)Returns the number of decimals used for display purposes
_This is an optional function in ERC20, but it's widely used and expected. The decimals value is used to determine how to interpret the token's numerical value. For example, if decimals is 2, a balance of 505 should be displayed as 5.05.
Common values:
- 18 (default for most tokens, matching ETH)
- 6 (common for stablecoins like USDC)
- 8 (used by some tokens to match Bitcoin)
IMPORTANT: This value only affects the display of token amounts, not their internal representation. All arithmetic operations should still use the full integer value.
Once set, the decimals value should never change during the lifetime of the contract._
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint8 | The number of decimals used for token display purposes |