ContractRuntime

Native bridge to the Rust contract runtime.

Exposes functions that match the WASM onchain-runtime exactly:

  • persistentHashAligned: binary_repr + SHA-256 (proper field-aligned encoding)

  • bigIntToValue / valueToBigInt: field element encoding

  • contractQuery: VM opcode execution via state handles

Functions

Link copied to clipboard

Assemble a contract call transaction from circuit execution output.

Link copied to clipboard
fun assembleDeployTx(paramsJson: String): String?

Assemble a contract DEPLOY transaction from constructor output.

Link copied to clipboard
fun bigIntToValue(bigintStr: String): String?

Convert BigInt (hex string) to Value (JSON).

Link copied to clipboard
fun contractQuery(handle: Long, opcodesJson: String): String?

Execute opcodes against a contract state handle.

Link copied to clipboard
Link copied to clipboard

Compute persistent commit: SHA-256(opening || binary_repr(value)).

Link copied to clipboard
fun persistentHash(inputHex: String): String?

Raw persistent hash (SHA-256) of hex bytes.

Link copied to clipboard
fun persistentHashAligned(alignedValueJson: String): String?

Persistent hash with proper AlignedValue encoding (matches WASM).

Link copied to clipboard
fun stateClone(handle: Long): Long

Clone a state handle (saves initial state before circuit queries).

Link copied to clipboard
fun stateCreate(stateHex: String): Long

Create a contract state from SCALE hex, return handle.

Link copied to clipboard
fun stateCreateWithNulls(structureJson: String): Long

Create state from a JSON structure descriptor (nested arrays of nulls).

Link copied to clipboard
fun stateFree(handle: Long)

Free a contract state handle.

Link copied to clipboard
fun stateReadFields(handle: Long): String?

Read contract state fields as JSON.

Link copied to clipboard
fun stateSetOperation(handle: Long, operationName: String)

Set an operation on a state handle.

Link copied to clipboard
fun valueToBigInt(valueJson: String): String?

Convert Value (JSON) to BigInt (decimal string).