Skip to main content

Function: toBaseUnits()

GalaChain core SDK 1.0.0-rc.8


GalaChain core SDK 1.0.0-rc.8 / bridge / toBaseUnits

Function: toBaseUnits()

toBaseUnits(amount, decimals): bigint

Defined in: packages/gala-core-sdk/dist/bridge.d.ts:2685

Convert a decimal amount to base units (smallest denomination)

Parameters​

amount​

string

The decimal amount as a string (e.g., "1.5")

decimals​

number

The number of decimal places

Returns​

bigint

The amount in base units as a bigint

Throws​

GalaSDKError INVALID_BRIDGE_AMOUNT: not_a_number, or too_many_decimals when it cannot be represented with the given decimals (it is never rounded)