sol

function sol(value, rounding?): Sol;

Parses a decimal string as a Sol fixed-point value.

The default rounding mode is 'strict', which throws SOLANA_ERROR__FIXED_POINTS__STRICT_MODE_PRECISION_LOSS when the input has more than 9 fractional digits. Pass another RoundingMode to accept a rounded result.

Parameters

ParameterType
valuestring
rounding?RoundingMode

Returns

Sol

Example

sol('1.5');            // represents 1.5 SOL (raw === 1_500_000_000n)
sol('0.000000001');    // the smallest representable amount: 1 Lamport
sol('1.1234567891', 'round'); // rounded to 9 decimals

See

On this page