Skip to content

Conversation

@seunlanlege
Copy link
Contributor

Summary

Implements the missing ERC20 metadata functions (name, symbol, decimals) for the pallet-assets precompile to provide full ERC20 compatibility. These functions were missing from the original implementation and are essential for proper EVM wallet and tooling integration.

Changes

Solidity Interface

  • substrate/primitives/ethereum-standards/src/IERC20.sol
    • Added name() external view returns (string memory)
    • Added symbol() external view returns (string memory)
    • Added decimals() external view returns (uint8)

Precompile Implementation

  • substrate/frame/assets/precompiles/src/lib.rs
    • Implemented name() - reads metadata from pallet-assets storage and returns UTF-8 string
    • Implemented symbol() - reads metadata from pallet-assets storage and returns UTF-8 string
    • Implemented decimals() - reads metadata from pallet-assets storage and returns uint8 value
    • All functions charge appropriate gas using dedicated weight functions
    • Proper error handling for missing metadata and invalid UTF-8 encoding

Benchmarks

  • substrate/frame/assets/src/benchmarking.rs
    • Added get_name benchmark - measures metadata read for name field
    • Added get_symbol benchmark - measures metadata read for symbol field
    • Added get_decimals benchmark - measures metadata read for decimals field

Weight Functions

  • substrate/frame/assets/src/weights.rs
    • Added get_name() -> Weight to WeightInfo trait
    • Added get_symbol() -> Weight to WeightInfo trait
    • Added get_decimals() -> Weight to WeightInfo trait
    • Implemented for both SubstrateWeight<T> and () (fallback)
    • Each function: 1 storage read from Assets::Metadata (~12-12.5ms, 2615 bytes proof size)

Closes #8658

@seunlanlege seunlanlege requested a review from a team as a code owner January 30, 2026 15:42
@pgherveou
Copy link
Contributor

fixes #8658

Copy link
Contributor

@pgherveou pgherveou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thanks 🙏

@0xRVE
Copy link
Contributor

0xRVE commented Jan 30, 2026

/cmd fmt

@0xRVE
Copy link
Contributor

0xRVE commented Jan 30, 2026

/cmd prdoc --audience runtime_dev --bump minor

@github-actions
Copy link
Contributor

Command "fmt" has failed ❌! See logs here

@github-actions
Copy link
Contributor

Command "prdoc --audience runtime_dev --bump minor" has failed ❌! See logs here

@seunlanlege
Copy link
Contributor Author

Commands won't run because it's on my fork

@SoneVibe
Copy link

Thanks for the fast progress on #10949 metadata views are a big win!

This will fix frontend crashes and metadata UX for DEXes.

Just confirming: will standard ERC-20 events (Transfer/Approval) be added in a future PR?

For lending (Compound/Aave forks), full events are needed for accrual tracking, liquidations, and subgraphs.

Happy to test on testnet when available.

Thanks again this is accelerating DeFi adoption on Hub!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement IERC20Metadata for pallet-assets precompile

5 participants