ERC-20 Metadata Facet
ERC-20 token metadata within a diamond
- Exposes external view functions for token name, symbol, and decimals.
- Retrieves metadata from shared diamond storage.
- Compatible with ERC-2535 diamond standard for routing.
- Provides immutable selectors for discovery via
exportSelectors.
Overview
This facet exposes ERC-20 token metadata functions, such as name, symbol, and decimals, through the diamond proxy. It accesses shared storage to retrieve these values, providing a consistent interface for token information within a Compose diamond. Developers add this facet to make token metadata accessible while maintaining diamond's upgradeability.
Storage
ERC20MetadataStorage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc20.metadata")) |
Functions
name
Returns the name of the token.
Returns:
| Property | Type | Description |
|---|---|---|
- | string | The token name. |
symbol
Returns the symbol of the token.
Returns:
| Property | Type | Description |
|---|---|---|
- | string | The token symbol. |
decimals
Returns the number of decimals used for token precision.
Returns:
| Property | Type | Description |
|---|---|---|
- | uint8 | The number of decimals. |
exportSelectors
Exports the function selectors of the ERC20Metadata facet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the ERC20MetadataFacet |
Best Practices
- Ensure the
ERC20MetadataFacetis correctly registered with the diamond's facet registry. - Access token metadata via the diamond proxy address to leverage routing and upgradeability.
- Do not directly call internal functions of this facet; use its external ABI exposed through the diamond.
Security Considerations
This facet contains only view functions and does not modify state. Input validation is not applicable. Follow standard Solidity security practices.