Construction-submit
This section details how to call the construction/submit
endpoint of the Rosetta construction API.
The request and response types can be found in the official documentation.
The endpoint sends to transactions to the IC. The first being the Call Request
which contains the information of what submit, which canister, what function in the canister and with what arguments should be called.
The second is a Read-State Request
which continously fetches the current status of the Call Request
from the IC. It returns either containing some Error or the response of the canister.
This means that a call to the construction/submit
endpoint is blocking until a result is available. Inside the returned object you will find information about the response from the ledger.
The construction/submit
endpoint can be called with the following:
curl --location '0.0.0.0:8081/construction/submit' --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "00000000000000020101"
},
"signed_transaction": "a168726571756573747381826b5452414e53414354494f4e81a266757064617465a367636f6e74656e74bf6c726571756573745f747970656463616c6c6b63616e69737465725f69644a000000000000000201016b6d6574686f645f6e616d656773656e645f70626361726758480a0b0899f29a9eeae1e288e20112040a02080a1a0308904e2a220a207f622708b363917e3ba0ef8ac1cb0dfe241ef5ffca54f32c1480473ee3a12cad3a0a089cd7c5caff8791e0176673656e646572581d2e70031d8e7ff922b6ad9f2a9eb3c1e77ffa7b6c0d0120dd4ac7e4f7026e696e67726573735f6578706972791b17c04477da6ec16aff6d73656e6465725f7075626b657958583056301006072a8648ce3d020106052b8104000a034200047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c7573676a73656e6465725f73696758406c382fa3a993266ef760e87f2a24098ee77577d2627d0648eb80c09abdfc8e1e69db98391bf28f8bd76d0baa18e3635a36c7da21258351db57879be677cb74bf6a726561645f7374617465a367636f6e74656e74bf6c726571756573745f747970656a726561645f73746174656673656e646572581d2e70031d8e7ff922b6ad9f2a9eb3c1e77ffa7b6c0d0120dd4ac7e4f70265706174687381824e726571756573745f7374617475735820f44e9df174422a8da79510951553aa40f05069061ce7c4d4f49d95299760196e6e696e67726573735f6578706972791b17c04477da6ec16aff6d73656e6465725f7075626b657958583056301006072a8648ce3d020106052b8104000a034200047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c7573676a73656e6465725f73696758401f7fedfbd38d5a9e73491f41d5f923bac0f6696729b29eb7bba02621f9bd184e9cc7c9b455c72bf6940a3ff12e8346d087ac630868771be0dde72343d8549e1c"
}'
The response would resemble the following:
{'transaction_identifier': {'hash': '93b71e1bdb5016e31f28a7762283c896f1d749cdbd8569c1bf8487f804f7923b'}, 'metadata': {'operations': [{'account': {'address': '8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4'}, 'amount': {'currency': {'decimals': 8, 'symbol': 'ICP'}, 'value': '-10'}, 'metadata': {'block_index': 342, 'transaction_identifier': {'hash': '93b71e1bdb5016e31f28a7762283c896f1d749cdbd8569c1bf8487f804f7923b'}}, 'operation_identifier': {'index': 0}, 'status': 'COMPLETED', 'type': 'TRANSACTION'}, {'account': {'address': '7f622708b363917e3ba0ef8ac1cb0dfe241ef5ffca54f32c1480473ee3a12cad'}, 'amount': {'currency': {'decimals': 8, 'symbol': 'ICP'}, 'value': '10'}, 'metadata': {'block_index': 342, 'transaction_identifier': {'hash': '93b71e1bdb5016e31f28a7762283c896f1d749cdbd8569c1bf8487f804f7923b'}}, 'operation_identifier': {'index': 1}, 'status': 'COMPLETED', 'type': 'TRANSACTION'}, {'account': {'address': '8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4'}, 'amount': {'currency': {'decimals': 8, 'symbol': 'ICP'}, 'value': '-10000'}, 'metadata': {'block_index': 342, 'transaction_identifier': {'hash': '93b71e1bdb5016e31f28a7762283c896f1d749cdbd8569c1bf8487f804f7923b'}}, 'operation_identifier': {'index': 2}, 'status': 'COMPLETED', 'type': 'FEE'}]}}
To know whether the transaction was successful or not you can look at the status
field. If it says "status": "COMPLETED
then the transaction was successful. This is true for any transaction type supported by Rosetta.
Alternatively, a user can query the /block
or block/transaction
endpoints to see whether the transaction has been included in the blockchain of the ICP ledger.