Integers

CosmWasm offers integer types starting at 64 bit precision, all the way up to 512 bits.

Reasoning behind wrapping the primitive 64 bit type is the interaction with, for example, JavaScript (same goes for parsers like jq or any parser that parses numbers into double precision floats). A u64 would normally serialize into a regular integer field in JSON. The issue here is that, due to representing integers in form of double precision floats, JavaScript can only handle up to ~53 bit numbers without potentially losing information.

💡

There is nothing wrong with using the primitive 64- and 128-bit types in your contract for calculations. The issues mentioned here can only happen when you de-/serialize these values.

Our wrapper fixes this by serializing numbers as strings, letting JavaScript clients deserialize these numbers into their respective BigInteger types.

The other integer types, which reach even higher amounts of precision, are serialized in the same way.

Integers come in the following variants:

UnsignedSigned
64 bitUint64 (opens in a new tab)Int64 (opens in a new tab)
128 bitUint128 (opens in a new tab)Int128 (opens in a new tab)
256 bitUint256 (opens in a new tab)Int256 (opens in a new tab)
512 bitUint512 (opens in a new tab)Int512 (opens in a new tab)