2. Writing your Parser

Chainwalkers requires that every parser have two bash entrypoint scripts:

  1. get_height.sh

  2. parse_blocks.sh

All code specific to your blockchain parser should live in the parsing/ directory.

Your parser should communicate directly with the RPC interface of one of your nodes.

Get Height

get_height.sh writes the best block height as a json response to stdout.

The response must be a JSON object with the following output schema.

> bash get_height.sh
{
"height": Integer
}

Parse Blocks

parse_blocks.sh parses an array of block heights as input and writes a json response to stdout.

The response must be a JSON array of block objects, with each block containing an array of transaction objects (including any data associated with smart contract calls).

For example:

> bash parse_blocks.sh 2913247 2913248 2913249
[
{
"Hash": "9112283aa8dc05a1ec315a8b9af624520bf170f9e8d8fc4809cd75fa4193cef3",
"Size": 1645,
"Header": {
"Version": 0,
"PrevBlockHash": "07166c9490556cfd656b60fc5613958d717af098365c1415bc929fc5645b9c84",
"TransactionsRoot": "b51e9cfe4e622e3d523ab09a33029c402a3bf72c6da893eab509f63228a7c57f",
"BlockRoot": "81ecd9d5877a0ae3781ed3d7df42435f1659c75e994e6e7de3d1b8130fc8cafd",
"Timestamp": 1543736464,
"Height": 1123209,
"ConsensusData": 1997724616647534726,
"ConsensusPayload": "{\"leader\":9,\"vrf_value\":\"BBKD7tjTu6TW7ukQZzKG5xpXPwKHLuB5GNpCwRx9pLkXcUEUPd28ZYVnDgOF9qyfa8ylaU+GRkNzUCXzJcOspq0=\",\"vrf_proof\":\"py6BBsd7Qg8/7vDGEfxuvs50zmHvsR6EDA0cmPglcpk5CGgMGIRIDy9TZCqLAc8ItjdvF9BcxLtf0z5GZSIE+A==\",\"last_config_block_num\":1014300,\"new_chain_config\":null}",
"NextBookkeeper": "AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM",
"Bookkeepers": ["022e911fb5a20b4b2e4f917f10eb92f27d17cad16b916bce8fd2dd8c11ac2878c0", "022e911fb5a20b4b2e4f917f10eb92f27d17cad16b916bce8fd2dd8c11ac2878c0", "02765d98bb092962734e365bd436bdc80c5b5991dcf22b28dbb02d3b3cf74d6444", "022bf80145bd448d993abffa237f4cd06d9df13eaad37afce5cb71d80c47b03feb", "0251f06bc247b1da94ec7d9fe25f5f913cedaecba8524140353b826cf9b1cbd9f4"],
"SigData": ["e013e96a9710f10f3f117be5070067a33511557a752b9c7a50a8a49ebcd9d581c5dd0e9f09ea7da691e0df828ba843c9d8579aecff03ce90cc81b3ef2b843930", "7241bd6591ccdf88f4f288945e23ee32a83531f30a9d0a7b90dc5398f231b517eaca0f9b33a6c21ec0ec31aef07ee113d728a6d7abf38c6f35e8fd74935fd401", "515df59c1caa7a54a2374e20a2847f634d466b8493ea224912dff5e8b6858b22a47d062747a5cfbff6461973c4845fe36e85a346beab62d51c92b2e8c310ee11", "1275e1dff69844354a2a9b58b0cad89eec0c4eda7c7157037bff5a9ceb81dff8556320fd30d85c529c1e95edd985d34b136066d93f0d1e70339c80ba3be62a75", "82fdf17ddaaedf07f4aebbca50c12f704184341402fc80917255ef78abb46d12903599b457606a70c4c0b58cf9976e7548a850e68b102e97a1479ea0e33be847"],
"Hash": "9112283aa8dc05a1ec315a8b9af624520bf170f9e8d8fc4809cd75fa4193cef3"
},
"Transactions": [
{
"Version": 0,
"Nonce": 3605551263,
"GasPrice": 500,
"GasLimit": 20000,
"Payer": "Adj7W5Z2hTeKH7YwJsfMzLuwiD671mvJ6X",
"TxType": 209,
"Payload": {
"Code": "00c66b2a6469643a6f6e743a41656750453643714c714e4e4571376b314d6865343136626e736443454b394a4d696a7cc82103b7a70338b40e9bed3f33a3ceb7d5eef76abb8c060eff2b74a641ba1eb1c5e67c6a7cc86c127265674944576974685075626c69634b65791400000000000000000000000000000000000000030068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
},
"Attributes": [],
"Sigs": [{
"PubKeys": ["03b7a70338b40e9bed3f33a3ceb7d5eef76abb8c060eff2b74a641ba1eb1c5e67c"],
"M": 1,
"SigData": ["0184398e09d4270152ceb5af705ed6c40f91772af4f9cc67fd3cbeb7db9bba73623501bbf4fc4694411de7943ee95ebfd138a9fcb92802555c3358e22c7bcdeba4"]
}, {
"PubKeys": ["03d1e206eddddba493d838deb4546dd735edee4b4fff591bce97ae7d3591d7f371"],
"M": 1,
"SigData": ["013565b063534918ef9450cc721a93122877a217ec37d218be6f042f92d58284a06d9efc329dd3f9ee00ed2e0bba62f1032644d6cb7b81faac8e15d768eecc03df"]
}],
"Hash": "c41d44a592a16da45273d616c236fc22b71c8a72075c38d29aa10340226167e1",
"Height": 1123209,
"States": [{
"contract_address": "0300000000000000000000000000000000000000",
"states": ["Register", "did:ont:AegPE6CqLqNNEq7k1Mhe416bnsdCEK9JMi"]
}, {
"contract_address": "0200000000000000000000000000000000000000",
"function_name": "transfer",
"from": "Adj7W5Z2hTeKH7YwJsfMzLuwiD671mvJ6X",
"to": "AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
"amount": 10000000
}]
},
...
]
},
...
]