Fetch block transactions
There are two endpoints that allow for querying transactions.
The block_transaction
endpoint allows you to fetch a transaction at a certain block height. It is the implementation of the /block/transaction endpoint of the Rosetta API standard.
The search_transactions
endpoint allows you to query for transactions given a set of parameters. It is the implementation of the /search/transactions endpoint.
An ICRC-1 ledger block always contains exactly one transaction. The hash of the block as well as the index of the block is guaranteed to be unique while the hash of the transaction is not.
Prerequisites
Your Rosetta instance is up and running under the address
0.0.0.0:8082
.Make sure to use the correct
[NetworkIdentifier
](/docs/current/developer-docs/defi/rosetta/icrc_rosetta/data_api/network).
BlockTransaction endpoint
For this example the following arbitrary BlockIdentifier
and TransactionIdentifier
are used:
"block_identifier": {
"index": 1357691,
"hash": "0415ed9ea78fed787e125179c99a7d0e599ee6e4cb0d610eed2c791e6e3f5e19"
}
"transaction_identifier": {
"hash": "700481a99b9a10cf4c4d037141ae5f1472fefe1f5be6b43d02577e398da4bdfe"
}
An example request can be found below:
curl --location '0.0.0.0:8082/block/transaction' --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "mxzaz-hqaaa-aaaar-qaada-cai"
},
"block_identifier": {
"index": 1357691,
"hash": "0415ed9ea78fed787e125179c99a7d0e599ee6e4cb0d610eed2c791e6e3f5e19"
},
"transaction_identifier": {
"hash": "700481a99b9a10cf4c4d037141ae5f1472fefe1f5be6b43d02577e398da4bdfe"
}
}'
The response is similar to that of the block endpoint as there is only one transaction within a block. If you want to fetch multiple transactions at a time you may want to have a look
at the /call
endpoint that allows you to query multiple blocks at a time.
{
"transaction": {
"transaction_identifier": {
"hash": "700481a99b9a10cf4c4d037141ae5f1472fefe1f5be6b43d02577e398da4bdfe"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "lrf2i-zba54-pygwt-tbi75-zvlz4-7gfhh-ylcrq-2zh73-6brgn-45jy5-cae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "230407",
"currency": {
"symbol": "ckBTC",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "xmiu5-jqaaa-aaaag-qbz7q-cai",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-230407",
"currency": {
"symbol": "ckBTC",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "xmiu5-jqaaa-aaaag-qbz7q-cai",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-10",
"currency": {
"symbol": "ckBTC",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"memo": [
0,
0,
0,
0,
0,
0,
249,
198
]
}
}
}
SearchTransactions endpoint
There are several parameters that can be used to query transactions. See the full specification to see what query parameters can be used.
For example, if you want to fetch all transactions in a given block (range of maximal 10000 blocks) where a specific account was involved, you can make a request to the search/transactions
endpoint:
curl --location '0.0.0.0:8081/search/transactions' --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network":"2ouva-viaaa-aaaaq-aaamq-cai"
},
"account_identifier": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account":{
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
}
}'
The response lists all transactions where the given account_identifier
was involved:
{
"transactions": [
{
"block_identifier": {
"index": 327933,
"hash": "bfef612ec9c8734ea5ade23844c0e9299ba51bd588e07f87f4050b69cc05991c"
},
"transaction": {
"transaction_identifier": {
"hash": "a0739cfa2cd7fa64b9408805bac6e36ba8a02fcaf837b3a47a12a8651dec30ec"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "a2teg-wgpcc-sdxre-jeg7v-7cnsd-m773p-7fjwv-b26yv-vucfg-k2ge7-bae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "5736352790",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-5736352790",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"created_at_time": 1716902391113000000
}
}
},
{
"block_identifier": {
"index": 327931,
"hash": "9fc7c296376b7d8479419dade3c9a6976a87c547dce4c530c1bb5937996567ee"
},
"transaction": {
"transaction_identifier": {
"hash": "1854ad9d8beb72950a01b06ca1625259f6f1f3eace8a40f179df77d26c9a27fd"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "5186652790",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "5207ef97240888864d78c5db1d97b304d6e6812d1092b028423407dd9fa983ae"
}
},
"amount": {
"value": "-5186652790",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "5207ef97240888864d78c5db1d97b304d6e6812d1092b028423407dd9fa983ae"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"memo": [
0,
0,
0,
0,
102,
85,
217,
237
]
}
}
},
{
"block_identifier": {
"index": 327928,
"hash": "f903a7074fa8bd95a8f19465aaa8d6768701b0374ccc0ec9557c3ab0fc74fe37"
},
"transaction": {
"transaction_identifier": {
"hash": "74288d7265c43b0b9c0d32a0e9d6c03bfc50bf6111b70f65122b6f42e427cdd3"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "dc69a3a296e3e031f660d310cb78448883a5b345bdc6a58243e9942e6c7c1b97"
}
},
"amount": {
"value": "-549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "dc69a3a296e3e031f660d310cb78448883a5b345bdc6a58243e9942e6c7c1b97"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"memo": [
0,
0,
0,
0,
102,
85,
217,
222
]
}
}
},
{
"block_identifier": {
"index": 167448,
"hash": "46573be9a81ac00e26703ba90610ab56a31af83cf99e5e1a3f6343e564e17052"
},
"transaction": {
"transaction_identifier": {
"hash": "4b88816bfdd9e9b88f8abd9412ad625b2488316b00080f5cd48fa26ece58ff78"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "shsif-nys7w-xmvyw-vdmdl-nogsj-3hua2-nnm4t-scrwf-7lc55-mxbgn-4ae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "1649300000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-1649300000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"created_at_time": 1701791593105000000
}
}
},
{
"block_identifier": {
"index": 167447,
"hash": "e3b36a8f61437fb40a983b5e57cde1e325bfad3a83064949968000243bdf9eb0"
},
"transaction": {
"transaction_identifier": {
"hash": "f8a0dbd2a91390c68e0ab525863422616225c0fedcaa339db86f4448921cc083"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "52197d5faef60214d4b0f666842664a1306e6bf28296b65bed092d239b34ffb2"
}
},
"amount": {
"value": "-549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "52197d5faef60214d4b0f666842664a1306e6bf28296b65bed092d239b34ffb2"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"memo": [
0,
0,
0,
0,
101,
111,
71,
82
]
}
}
},
{
"block_identifier": {
"index": 167446,
"hash": "e65953a4204bd10b1304dac5db0943e5dc43d83af5986f1604987f61b77f4186"
},
"transaction": {
"transaction_identifier": {
"hash": "b09b6133fe6023e20aec81719f734123699e5663193cc0dd74f31935fd318fe0"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "5a1cb3b2b6c9e25e49f626bb94afd43fd0577648fa6c19d7f70b537fab6a68c4"
}
},
"amount": {
"value": "-549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "5a1cb3b2b6c9e25e49f626bb94afd43fd0577648fa6c19d7f70b537fab6a68c4"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"memo": [
0,
0,
0,
0,
101,
111,
71,
73
]
}
}
},
{
"block_identifier": {
"index": 167445,
"hash": "aefd96367e28aea604cffe115d483707a41524490c04e7fe6fe96171a37fe664"
},
"transaction": {
"transaction_identifier": {
"hash": "738266fb1ecf7de8db9786df903c2689907274532f0b72997ecbd80b88a334c5"
},
"operations": [
{
"operation_identifier": {
"index": 3
},
"related_operations": [
{
"index": 4
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "h2upz-svoky-hpfgf-lobao-afowo-h6xs6-4jhj5-26q3u-zimva-as2tg-dae",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
"amount": {
"value": "549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 4
},
"related_operations": [
{
"index": 3
},
{
"index": 5
}
],
"type": "TRANSFER",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "7fa327c3e414b4d700062f7eb68a1f69da1762f5c7f3496e76bc97dd3367b429"
}
},
"amount": {
"value": "-549800000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 5
},
"related_operations": [
{
"index": 3
},
{
"index": 4
}
],
"type": "FEE",
"status": "COMPLETED",
"account": {
"address": "2jvtu-yqaaa-aaaaq-aaama-cai",
"sub_account": {
"address": "7fa327c3e414b4d700062f7eb68a1f69da1762f5c7f3496e76bc97dd3367b429"
}
},
"amount": {
"value": "-100000",
"currency": {
"symbol": "CHAT",
"decimals": 8
}
},
"metadata": {
"fee_set_by": "User"
}
}
],
"metadata": {
"memo": [
0,
0,
0,
0,
101,
111,
71,
64
]
}
}
}
],
"total_count": 7
}