Files
aitbc/docs/4_blockchain/10_api-blockchain.md
oib 06e48ef34b chore: standardize configuration, logging, and error handling across blockchain node and coordinator API
- Add infrastructure.md and workflow files to .gitignore to prevent sensitive info leaks
- Change blockchain node mempool backend default from memory to database for persistence
- Refactor blockchain node logger with StructuredLogFormatter and AuditLogger (consistent with coordinator)
- Add structured logging fields: service, module, function, line number
- Unify coordinator config with Database
2026-02-13 22:39:43 +01:00

2.6 KiB

Blockchain API Reference

Complete API reference for blockchain node operations.

RPC Endpoints

Get Block

GET /rpc/block/{height}

Response:

{
  "block": {
    "header": {
      "height": 100,
      "timestamp": "2026-02-13T10:00:00Z",
      "proposer": "ait-devnet-proposer-1",
      "parent_hash": "0xabc123...",
      "state_root": "0xdef456...",
      "tx_root": "0xghi789..."
    },
    "transactions": [...],
    "receipts": [...]
  },
  "block_id": "0xjkl012..."
}

Get Transaction

GET /rpc/tx/{tx_hash}

Response:

{
  "tx": {
    "hash": "0xabc123...",
    "type": "transfer",
    "from": "0x1234...",
    "to": "0x5678...",
    "value": 100,
    "gas": 21000,
    "data": "0x..."
  },
  "height": 100,
  "index": 0
}

Submit Transaction

POST /rpc/broadcast_tx_commit

Request Body:

{
  "tx": "0xabc123...",
  "type": "transfer",
  "from": "0x1234...",
  "to": "0x5678...",
  "value": 100,
  "data": "0x..."
}

Response:

{
  "tx_response": {
    "code": 0,
    "data": "0x...",
    "log": "success",
    "hash": "0xabc123..."
  },
  "height": 100,
  "index": 0
}

Get Status

GET /rpc/status

Response:

{
  "node_info": {
    "protocol_version": "v0.1.0",
    "network": "ait-devnet",
    "node_id": "12D3KooW...",
    "listen_addr": "tcp://0.0.0.0:7070"
  },
  "sync_info": {
    "latest_block_height": 1000,
    "catching_up": false,
    "earliest_block_height": 1
  },
  "validator_info": {
    "voting_power": 1000,
    "proposer": true
  }
}

Get Mempool

GET /rpc/mempool

Response:

{
  "size": 50,
  "txs": [
    {
      "hash": "0xabc123...",
      "fee": 0.001,
      "size": 200
    }
  ]
}

WebSocket Endpoints

Subscribe to Blocks

WS /rpc/block

Message:

{
  "type": "new_block",
  "data": {
    "height": 1001,
    "hash": "0x...",
    "proposer": "ait-devnet-proposer-1"
  }
}

Subscribe to Transactions

WS /rpc/tx

Message:

{
  "type": "new_tx",
  "data": {
    "hash": "0xabc123...",
    "type": "transfer",
    "from": "0x1234...",
    "to": "0x5678...",
    "value": 100
  }
}

Error Codes

Code Description
0 Success
1 Internal error
2 Invalid transaction
3 Invalid request
4 Not found
5 Conflict

Rate Limits

  • 1000 requests/minute for RPC
  • 100 requests/minute for writes
  • 10 connections per IP

Next