Skip to content

Braga has been retired. The next public testnet is coming in September 2026. Read the announcement →

dec(value): DecValue

Defined in: src/attr/values.ts:226

A signed fixed-point decimal with exactly 18 decimal places, indexed for equality and range queries.

Pass fractional values as strings. A JavaScript number cannot represent most decimals exactly, so accepting dec(0.1 + 0.2) would quietly store 0.30000000000000004; requiring the string keeps what you write and what is stored the same thing. Excess precision is likewise an error rather than a rounding.

A decimal string, or an integral number / bigint.

string | number | bigint

DecValue

If the value is malformed, has more than 18 fractional digits, or falls outside the int256 range.

dec("3.5")
dec("-0.000000000000000001") // the smallest step
dec(5) // integers may be passed bare