@token:amount
Convert a human-readable token amount to its base unit (applying decimals).
On-chain (@token:amount!): Scales against a live decimals() read rather than a build-time constant.
Returns: number
Syntax
Section titled “Syntax”@token:amount(tokenSymbolOrAddress amount)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
tokenSymbolOrAddress | token-symbol | Token symbol (e.g. DAI) or address |
amount | number | Human-readable amount |
Examples
Section titled “Examples”# Convert 100 DAI to base unitsset $amount @token:amount(DAI 100)See Also
Section titled “See Also”- @token — resolve a token symbol to its address
@balance— query token balance- @token:format — format base units as a human-readable string
- @num.parse — generic decimal parsing
On-chain face (@amount!)
Section titled “On-chain face (@amount!)”Scale a human-readable amount into base units against the LIVE
decimals() read: mul(mantissa, exp(10, decimals - k)) where the
amount is mantissa / 10^k. The native token's decimals are a chain
constant, so a native @amount! folds at build time.