Different blockchains use different decimal places and units for their native assets and tokens. This reference provides conversion formulas and utilities for accurate amount handling across all supported chains.
CRITICAL: CACAO uses 10 decimals, not 8!Decimals: 10 (for CACAO), 8 (for other assets)
Base Unit: Smallest CACAO unit
Conversion: 1 CACAO = 10,000,000,000 base units
Decimals: 24
Base Unit: YoctoNEAR
Conversion: 1 NEAR = 1,000,000,000,000,000,000,000,000 yoctoNEAR
// YoctoNEAR to NEARconst near = yoctoNEAR / 1e24;// Orconst near = yoctoNEAR / 1000000000000000000000000;// NEAR to YoctoNEARconst yoctoNEAR = Math.floor(near * 1e24);// Examples1000000000000000000000000 // → 1.0 NEAR5000000000000000000000000 // → 5.0 NEAR// Using NEAR API libraryimport { utils } from 'near-api-js';const near = utils.format.formatNearAmount(yoctoNEAR);const yoctoNEAR = utils.format.parseNearAmount(near);