Skip to main content

ERC-20 Metadata Facet

ERC-20 token metadata within a diamond

Key Features
  • 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

Definition
struct ERC20MetadataStorage {
string name;
string symbol;
uint8 decimals;
}

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc20.metadata"))

Functions

name

Returns the name of the token.

function name() external view returns (string memory);

Returns:

PropertyTypeDescription
-stringThe token name.

symbol

Returns the symbol of the token.

function symbol() external view returns (string memory);

Returns:

PropertyTypeDescription
-stringThe token symbol.

decimals

Returns the number of decimals used for token precision.

function decimals() external view returns (uint8);

Returns:

PropertyTypeDescription
-uint8The number of decimals.

exportSelectors

Exports the function selectors of the ERC20Metadata facet This function is use as a selector discovery mechanism for diamonds

function exportSelectors() external pure returns (bytes memory);

Returns:

PropertyTypeDescription
-bytesselectors The exported function selectors of the ERC20MetadataFacet

Best Practices

Best Practice
  • Ensure the ERC20MetadataFacet is 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

Security

This facet contains only view functions and does not modify state. Input validation is not applicable. Follow standard Solidity security practices.

Was this helpful?
Last updated:

Newsletter

Get notified about releases, feature announcements, and technical deep-dives on building smart contracts with Compose.

No spam. Unsubscribe anytime.