JSON-RPC API
Complete reference for the QuanChain RPC surface. Native qc_* namespaces, eth_* compatibility, and a websocket subscription model.
Endpoints
Testnet RPC: https://rpc-testnet.quanchain.ai
Testnet WS: wss://ws-testnet.quanchain.ai
Mainnet: (published at launch)All POST bodies follow the standard JSON-RPC 2.0 shape:
{ "jsonrpc": "2.0", "method": "qc_chainHead", "params": [1], "id": 1 }Authentication
The public RPC is open and rate-limited per IP. For higher quotas, dedicated endpoints, or write-mempool priority, request an API key from the developer portal and pass it as a header:
curl https://rpc-testnet.quanchain.ai \
-H "X-QuanChain-Key: qc_live_..." \
-X POST -d '{ "jsonrpc": "2.0", "method": "qc_chainHead", "params": [1], "id": 1 }'qc_chain · chain state
qc_chainHeadRPCHead block of the requested channel.
[channel: 1|2|3]{ height, hash, ts }qc_blockByHeightRPCFull block at the given channel + height.
[channel, height]Blockqc_blockByHashRPCFull block by its hash. Channel inferred.
[hash]Blockqc_chainConfigRPCNetwork config: chain id, channel finalities, current epoch.
[]ChainConfigqc_wallet · wallet introspection
qc_walletInfoRPCResolve any wallet address (parent or child) to its current state.
[address]{ level, parent, activeChild, ... }qc_parentTreeRPCSnapshot of the parent's Merkle tree: root, depth, used indices.
[parentAddr]MerkleSnapshotqc_resolveAddressRPCForward-resolve a retired child to the currently active child of its parent.
[oldChild]addressqc_tx · transactions
qc_sendRawTransactionRPCBroadcast a pre-signed SpendAndRotate envelope.
[hex]txHashqc_getTransactionRPCConfirmed transaction including its rotation child.
[hash]Tx | nullqc_getReceiptRPCReceipt with logs, gas used, and new active child.
[hash]Receipt | nullqc_recentTransactionsRPCRecent transactions across all channels (chain caps at 50).
[limit?]Tx[]qc_spend · SpendAndRotate helpers
qc_prepareSpendRPCBuild an unsigned SpendAndRotate envelope. Caller signs offline.
[from, to, amount]UnsignedEnvelopeqc_estimateFeeRPCEstimate the channel fee at current congestion.
[channel, payloadSize]feeQCHqc_prepare* exist solely to assemble envelopes; the caller signs and resubmits via qc_sendRawTransaction.qc_recovery · parent operations
qc_prepareRecoveryRPCBuild a recovery envelope. Requires composite signature from parent.
[parent, reason, newLevel?]UnsignedRecoveryqc_recoveryStatusRPCPending and historical recoveries for a parent identity.
[parent]RecoveryStatusWebsocket subscriptions
import { QuanChain } from '@quanchain/sdk';
const ws = new QuanChain.Ws('wss://ws-testnet.quanchain.ai');
ws.subscribe('newBlocks', { channel: 1 }, (block) => {
console.log('C1 head:', block.height, block.hash);
});
ws.subscribe('walletEvents', { parent: 'QC20_...' }, (ev) => {
// 'rotate' | 'recovery' | 'inboundTransfer'
});Subscriptions are filtered server-side. Channel-1 newBlocks fires roughly every 200 ms; walletEvents only fires for the parent address(es) in the filter.
Error codes
-32600 Invalid JSON-RPC request
-32601 Method not found
-32602 Invalid params (validation failure)
-32000 Server error (generic)
-32010 Wallet rotation conflict — child already spent
-32011 Composite signature failed verification
-32012 Merkle proof failed verification
-32013 Channel capacity exceeded — retry on different channel
-32020 Rate-limit hit (HTTP 429 also returned)Rate limits
Public RPC is limited to 100 requests per minute per IP. Authenticated keys lift the limit to 6,000 rpm by default and can be raised further via the developer portal. Websocket connections have no per-message ceiling; subscriptions are capped at 32 per socket.
SDK-friendly examples for every method are in the SDKs reference.