Skip to content

@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

@token:amount(tokenSymbolOrAddress amount)
NameTypeDescription
tokenSymbolOrAddresstoken-symbolToken symbol (e.g. DAI) or address
amountnumberHuman-readable amount
# Convert 100 DAI to base units
set $amount @token:amount(DAI 100)
  • @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

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.