Skip to content

@lelantos-org/sdk / index / parseAmount

Function: parseAmount() ​

ts
function parseAmount(
   value, 
   asset, 
   opts?
): CircuitAmount;

Defined in: @lelantos-org/sdk/dist/wallet/assets/amount.d.ts:22

Human decimal string → circuit units.

Default round: "exact" for a plain asset (an amount finer than one unit is refused, never truncated), "up" for a yield asset (the inverse of formatAmount: a formatted balance parses back to itself). A leading - is accepted so signed figures round-trip; operations refuse non-positive amounts themselves.

ts
const usdc = await wallet.asset("USDC");
await wallet.transfer({ asset: usdc.id, amount: parseAmount("12.5", usdc), recipient });

Parameters ​

ParameterType
valuestring
assetAssetUnits
opts?{ round?: Rounding; }
opts.round?Rounding

Returns ​

CircuitAmount

Throws ​

on a non-string, a malformed number, an asset without decimals, or an off-unit amount under "exact".