Documentation

Kanari Documentation

API Reference

Documentation for interacting with Kanari Network via API.

Last updated

API Reference

Kanari nodes expose an Axum JSON-RPC API for blockchain state, transactions, Move modules, objects, NFTs, checkpoints, and diagnostics. Public deployments should place a gateway or load balancer in front of multiple RPC nodes.

Endpoint

JSON-RPC requests are POST requests to /rpc:

http://127.0.0.1:19001/rpc
http://192.168.1.101:19001/rpc

Opening the base URL in a browser is not the same as calling JSON-RPC. Use POST with Content-Type: application/json.

Request Wrapper

{
  "jsonrpc": "2.0",
  "method": "kanari_<methodName>",
  "params": { /* method-specific fields */ },
  "id": 1
}

Common methods

Method names are defined in crates/kanari-rpc-api.

AreaExamples
Chain stats/checkpointskanari_getStats, kanari_getBlockHeight, kanari_getBlock, kanari_getFullBlock
State roots/diagnosticskanari_getSmtStatus, kanari_getCanonicalStateSnapshot, kanari_compareCanonicalStateSnapshot
Transactionskanari_getTransaction, kanari_buildNativeTransfer, kanari_submitTransaction
Balances/assetstoken balance, owner balances, fungible asset holders, asset transactions
Objects/modulesget object, get object by ref, list modules, verify module, publish package/module
NFTsowned NFTs and collections
Move callsbuild/call function and view function

Module Methods

kanari_publishModule

Publish a new Move module to the network.

Request params:

{
  "sender": "0x...",
  "module_bytes": [1,2,3],
  "module_name": "MyModule",
  "gas_limit": 1000000,
  "gas_price": 1,
  "sequence_number": 0,
  "signature": null,
  "execute_immediate": false
}

Response (Success):

{
  "jsonrpc": "2.0",
  "result": { "hash": "<tx-hash-hex>", "status": "pending", "action": "publish" },
  "id": 1
}

kanari_upgradeModule

Upgrade an existing module. The request params are identical to kanari_publishModule.

Response (Success):

{ 
  "jsonrpc": "2.0", 
  "result": { "hash": "<tx-hash>", "status": "pending", "action": "upgrade" }, 
  "id": 1 
}

kanari_getModule

Fetch module info and bytecode.

Request params:

{ "address": "0x...", "name": "MyModule" }

Response result:

{
  "address": "0x...",
  "name": "MyModule",
  "bytecode_hash": "<blake3-hex>",
  "size": 1234,
  "dependencies": []
}

kanari_listModules

List all modules available in the runtime. Send an empty object {} as params.

kanari_verifyModule

Verify module bytecode locally without publishing.

Request params:

{ "module_bytes": [1,2,3] }

cURL Examples

Publish a Module (Submit Pending TX):

curl -X POST http://127.0.0.1:19001/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","method":"kanari_publishModule","params":{"sender":"0x1","module_bytes":[1,2,3],"module_name":"M","gas_limit":1000000,"gas_price":1,"sequence_number":0},"id":1}'

Get a Module:

curl -X POST http://127.0.0.1:19001/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","method":"kanari_getModule","params":{"address":"0x1","name":"M"},"id":1}'

Error Codes

The HTTP response can be 200 while the JSON-RPC payload contains an error object. Client code should inspect both the HTTP status and JSON-RPC response body.

CodeDescription
200Success - Request completed successfully.
400Bad Request - Invalid parameters.
401Unauthorized - Invalid or missing API key.
404Not Found - The requested resource does not exist.
500Internal Server Error - Something went wrong on our end.