RPC and Runtime API

This document describes ways to interact with the Taler node through standardized RPC and specific Runtime APIs.

Node and Protocols

Protocols: HTTP/WS JSON-RPC (jsonrpsee)
Endpoints exposed by node binary (node/src/rpc.rs)
Example of running with open RPC: see node-setup.html

Common RPC (substrate)

system_*: chain information, version, events
state_*: storage reading, subscriptions
author_*: signing/sending extrinsics
chain_*: blocks, hashes, finalization subscriptions

Example of getting network name:

const chain = await api.rpc.system.chain();

Payment and Fees

transactionPayment_queryInfo — fee estimation for call.
const info = await api.rpc.payment.queryInfo(txHex);
console.log(info.partialFee.toString());

Runtime API (example areas)

Staking Runtime API (pallets/staking/runtime-api): quota/reward calculations.
Assets/NFT Runtime APIs (if connected): metadata and balance retrieval.

Calling Runtime API via api.rpc.state.call:

// method name and SCALE-encoded input structure depend on specific runtime-api
const resultHex = await api.rpc.state.call('StakingApi_methodName', paramsAsHex);

Types and Metadata

Use api.registry to register custom types (if there are local types).
Metadata version v14+ contains information about pallets/extrinsics/events.

Security

In production, restrict RPC: --rpc-methods Safe, CORS/hosts.
Don't expose private nodes with Unsafe methods publicly.

Debugging

Runtime logs: -lruntime=debug.
Event subscriptions: api.query.system.events.

See also:

external-developers.html for dApp examples
partner-pallets.html for integrating custom runtime APIs