Skip to content

feat(assets): support up to 18 decimals and full 256-bit BigInt totalSupply - #4101

Closed
D-H-O-R-A wants to merge 1 commit into
wavesplatform:version-1.6.xfrom
D-H-O-R-A:feat/support-18-decimals-and-erc20-supply
Closed

D-H-O-R-A wants to merge 1 commit into
wavesplatform:version-1.6.xfrom
D-H-O-R-A:feat/support-18-decimals-and-erc20-supply

Conversation

@D-H-O-R-A

Copy link
Copy Markdown

Summary

Back in 2020-2021, there were community discussions regarding Waves asset limitations compared to EVM ecosystems: specifically the historical 8-decimal cap and the friction it causes when bridging, tokenizing, or interacting with standard ERC-20 tokens (which standardly use 18 decimals). While back then it was debated, practical EVM/Web3 compatibility has shown that full 18-decimal support and preserving 256-bit totalSupply precision is essential for seamless interoperability.

This PR addresses this limitation cleanly, allowing assets to be issued with up to 18 decimals and ensuring full EVM RPC compatibility without altering binary serialization schemes or breaking backward compatibility.

Key Changes

  1. Expand MaxAssetDecimals from 8 to 18:
    • In IssueTransaction.scala, updated MaxAssetDecimals = 18.
    • The wire format for decimals in Waves binary serialization is a single byte (buf.put(decimals.value) / buf.getByte) and Protobuf uses int32 varint. Decimal values in the range 0..18 use the exact same byte representation.
    • 100% backwards-compatible: all historical transactions and existing assets (0..8 decimals) deserialize and validate identically.
  2. 256-bit totalSupply() in EVM RPC (EthRpcRoute):
    • In EthRpcRoute.scala, added/updated totalSupply() (0x18160ddd) call to retrieve _.totalVolume.bigInteger encoded as Uint256.
  3. Comprehensive Unit Testing:
    • Added HighDecimalsIssueSpec validating:
      • Creation of 18-decimal assets (Ethereum standard).
      • Decimal range checks from 0 to 18.
      • Strict rejection of decimals > 18.
      • Binary serialization roundtrip (V2).
      • Protobuf serialization roundtrip (V3).
    • Ran against existing IssueTransactionV2Specification to confirm 0 regressions on historical tx bytes.

@D-H-O-R-A
D-H-O-R-A requested a review from phearnot as a code owner October 23, 2026 02:48
@D-H-O-R-A

Copy link
Copy Markdown
Author

Closed for further internal architecture analysis and design.

@D-H-O-R-A D-H-O-R-A closed this Oct 23, 2026
@D-H-O-R-A
D-H-O-R-A deleted the feat/support-18-decimals-and-erc20-supply branch October 23, 2026 03:02
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.

1 participant