Quick Start
InMemoryBlockchain
Local in-memory storage. Blocks must be added viaputBlock():
ForkBlockchain
Fetches blocks from a remote RPC for block numbers at or below the fork point:ForkBlockchainOptions
Block Type
Full Ethereum block with header and body data:Error Handling
Error Codes
| Code | Description |
|---|---|
BLOCK_NOT_FOUND | Block does not exist |
INVALID_PARENT | Block’s parent not found |
ORPHAN_HEAD | Cannot set orphan block as head |
INVALID_HASH | Invalid block hash |
RPC_ERROR | RPC request failed (fork mode) |
Service Interface
Method Reference
| Method | Description |
|---|---|
getBlockByHash | Retrieve block by hash |
getBlockByNumber | Retrieve block by number |
getCanonicalHash | Get canonical block hash for number |
getHeadBlockNumber | Get current chain head number |
putBlock | Store a block |
setCanonicalHead | Set canonical chain head |
hasBlock | Check if block exists |
localBlockCount | Count locally stored blocks |
orphanCount | Count orphan blocks |
canonicalChainLength | Length of canonical chain |
isForkBlock | Check if block is from fork (ForkBlockchain only) |
destroy | Cleanup resources |

