Skip to main content

Overview

Managing token decimals is critical when working with HBAR, HTS tokens, and ERC tokens on Hedera, as each system has distinct precision standards. These differences impact how token balances are calculated, displayed, and transferred across various tools and environments.

Token Decimal Comparison and API Context

HBAR has two scales on Hedera. Inside the network, including inside the EVM, HBAR is counted in tinybars (8 decimals, 1 ℏ = 10⁸ tinybars). The JSON-RPC relay presents HBAR to Ethereum tooling in weibars (18 decimals, 1 tinybar = 10¹⁰ weibars) so that wallets and libraries such as ethers and viem work unchanged. When an Ethereum transaction executes, the network divides its value by 10¹⁰ to get tinybars before the EVM runs; the relay multiplies tinybar amounts by 10¹⁰ when it returns balances and gas prices. Key impacts:
  • Inside a contract, never scale msg.value by 10**10. Compare it with tinybar amounts directly, such as the result of the Exchange Rate system contract.
  • Multiply by 10**10 only when you hand a tinybar amount to JSON-RPC tooling as a transaction value.
  • The relay rejects a nonzero value smaller than one tinybar (10¹⁰ weibars) with JSON-RPC error -32602: Value can't be non-zero and less than 10_000_000_000 wei which is 1 tinybar. Any precision finer than a tinybar is dropped when the network converts the value.
  • HBAR fees are always calculated in tinybars, regardless of the API or service used.

Conversion Helpers

Use these helpers when you move an HBAR amount between the two scales, for example when a contract receives a weibar amount as a function argument from a front end. Don’t apply them to msg.value or address.balance inside a contract: those are already in tinybars. Code Example: Decimal Conversion Helpers
Reference: Smart Contracts Gas and Fees

Additional Resources