Inazuma docs · Devnet
WASM smart contracts
Inazuma is programmable. Contracts are plain WebAssembly modules executed by a deterministic, fuel-metered runtime inside consensus — they hold INAZ, keep their own key/value state, move funds, emit logs and produce receipts.
Engine
wasmi (WASM)
Metering
Fuel per rai
State
Key/value in consensus
Deploy fee
5 INAZ
1 · The VM
No EVM, no Solidity. Any language that compiles to WebAssembly targets the chain directly.
- →Contracts live at their own base58 address, derived deterministically from creator + nonce + code hash.
- →A contract account holds INAZ exactly like a user account and can send it onward.
- →Storage is a key/value map committed into consensus state, not an off-chain sidecar.
- →Execution is deterministic: no floats, no clocks, no network, no randomness — every node reaches the same result.
- →Calls are metered with fuel bought by the transaction fee; running out reverts the whole call atomically.
- →Every call produces a receipt with return data, logs, fuel used and an error string on revert.
2 · Guest ABI
Import these from module "env". Your module must export invoke() -> i32; a non-zero return reverts the call.
| Import | Meaning |
|---|---|
| inz_input_len() -> i32 | Length of the call arguments. |
| inz_input(ptr, cap) -> i32 | Copy call arguments into memory. |
| inz_return(ptr, len) | Set return data (max 8 KB). |
| inz_log(ptr, len) | Emit a log line onto the receipt (max 64). |
| inz_caller(ptr, cap) -> i32 | Address that sent the call. |
| inz_self(ptr, cap) -> i32 | This contract's address. |
| inz_value() -> i64 | INAZ attached to the call, in rai. |
| inz_height() -> i64 | Current block height. |
| inz_balance() -> i64 | This contract's balance, in rai. |
| inz_read(kptr, klen, ptr, cap) -> i32 | Read storage; -1 when the key is unset. |
| inz_write(kptr, klen, vptr, vlen) -> i32 | Write storage (max 512 writes per call). |
| inz_transfer(aptr, alen, amount_rai) -> i32 | Send INAZ from the contract (max 32 per call). |
3 · Deploy
Send a deploycontract transaction whose payload carries hex-encoded WASM. The response predicts the contract address.
# 1. compile to wasm (any language: Rust, C, Zig, AssemblyScript, .wat)
rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown
# 2. deploy — payload.code is hex-encoded wasm bytes
curl -s https://rpc.inazuma.network -H 'content-type: application/json' -d '{
"jsonrpc":"2.0","id":1,"method":"inaz_sendTransaction",
"params":{"tx":{
"kind":"deploycontract",
"from":"<your address>",
"nonce":7,
"fee":"...",
"payload":{"code":"0061736d0100..."},
"signature":"<ed25519 sig>"
}}
}'
# → { "hash": "...", "status": "pending", "contract": "<contract address>" }4 · Call & query
callcontract mutates state and costs fuel. inaz_query runs the same code read-only and throws every write away.
# state-changing call — args are hex, value attaches INAZ
{"kind":"callcontract","to":"<contract>","payload":{"args":"676574"}, ...}
# read-only query, free, no transaction
curl -s https://rpc.inazuma.network -H 'content-type: application/json' -d '{
"jsonrpc":"2.0","id":1,"method":"inaz_query",
"params":{"address":"<contract>","args":"676574"}
}'
# → { ok, returnHex, returnText, logs, fuelUsed, writesDiscarded }| Method | Returns |
|---|---|
| inaz_contracts | Every deployed contract, count and current deploy fee. |
| inaz_getContract | Code hash, size, creator, height, call count, balance, storage preview. |
| inaz_contractStorage | One storage key's value (hex + text). |
| inaz_getReceipt | ok, fuelUsed, return data, logs and error for a call. |
| inaz_query | Read-only execution — no fee, no state change. |
5 · Fuel & fees
Fuel is bought with the transaction fee. There is no separate gas token or gas price to guess.
| Parameter | Value |
|---|---|
| Fuel per rai of fee | 400 |
| Minimum fuel granted | 1,000,000 |
| Maximum fuel per call | 2,000,000,000 |
| Read-only query fuel | 50,000,000 |
| Deploy fee | 5 INAZ (burned to reward pool) |
invoke() reverts every write and transfer from that call. The fee is still consumed.Limits
| Limit | Value |
|---|---|
| Code size | 256 KB |
| Call arguments | 16 KB |
| Storage key | 128 bytes |
| Storage value | 8 KB |
| Writes per call | 512 |
| Transfers per call | 32 |
| Logs per call | 64 |
| Return data | 8 KB |
Example contract
A counter written in raw WebAssembly text format, shipped in the core repo.
;; args "" -> increment
;; args "get" -> read without writing
;; args "add:<n>" -> add n
(module
(import "env" "inz_input_len" (func $input_len (result i32)))
(import "env" "inz_read" (func $read (param i32 i32 i32 i32) (result i32)))
(import "env" "inz_write" (func $write (param i32 i32 i32 i32) (result i32)))
(import "env" "inz_return" (func $ret (param i32 i32)))
(memory (export "memory") 1)
(data (i32.const 0) "count")
(func (export "invoke") (result i32) ... ))Full source: contracts/counter.wat — runtime: src/contracts.rs. Browse what is live on the explorer.
