Try it Live
Run Uint examples in the interactive playground
Usage Patterns
Arithmetic Operations
Comparison with BigInt
JSON Serialization
See Also
- fromBigInt - Create from BigInt
- toNumber - Convert to number
- toString - Convert to string
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Convert Uint256 to JavaScript BigInt
const a = Uint(100n)
const b = Uint(50n)
// Use BigInt for operations not supported by Uint
const bigIntA = Uint.toBigInt(a)
const bigIntB = Uint.toBigInt(b)
// Custom operation
const result = bigIntA ** 2n + bigIntB
const resultUint = Uint(result)
const value = Uint(1000n)
const bigint = Uint.toBigInt(value)
if (bigint > 500n) {
console.log("Greater than 500")
}
const value = Uint(12345n)
// BigInt not supported in JSON.stringify
const json = JSON.stringify({
balance: Uint.toBigInt(value).toString() // Convert to string
})
Was this page helpful?
