Construction-combine
This section details how to call the construction/combine
endpoint of the Rosetta construction API.
The request and response types can be found in the official documentation.
Signing payloads
The payloads that one receives from the construction/payloads
endpoint contain a hex string that needs to be signed with the private key of the accountidentifier
that is associated with the hex string.
Here is an example of such a payload:
{"account_identifier":{"address":"8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4"},"hex_bytes":"0a69632d72657175657374df3e33267733b2030e8a4fc1d7eb6e0884ab461806630921a9c0c9749abb99de","signature_type":"ecdsa"}
This means that we need to sign the hex bytes 0a69632d72657175657374df3e33267733b2030e8a4fc1d7eb6e0884ab461806630921a9c0c9749abb99de
with the private key associated with the accountidentifier
8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4
using an ecdsa
signature type. This would result in the signature in hex representation 3046022100ce0807d84c8321bf3525361ad25654be81076e75e8c004970789d385f195fc500221008eebd282efabb878ac54e77dc4230acf54d103ef05253db44cb9fba0fb382764
Fetching a signed transaction
The construction/combine
endpoint will create a signed transaction and return it. A call to the endpoint may look like the following:
curl --location '0.0.0.0:8081/construction/combine' --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "00000000000000020101"
},
"unsigned_transaction": "a2677570646174657381826b5452414e53414354494f4ea56b63616e69737465725f69644a000000000000000201016b6d6574686f645f6e616d656773656e645f70626361726758480a0b08baea959fe0a9e58dbd0112040a02080a1a0308904e2a220a207f622708b363917e3ba0ef8ac1cb0dfe241ef5ffca54f32c1480473ee3a12cad3a0a0899d9c88df3d893e0176673656e646572581d2e70031d8e7ff922b6ad9f2a9eb3c1e77ffa7b6c0d0120dd4ac7e4f7026e696e67726573735f6578706972790070696e67726573735f6578706972696573811b17c04eff12cf8023",
"signatures": [
{
"signing_payload": {
"account_identifier": {
"address": "8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4"
},
"hex_bytes": "0a69632d726571756573748c85871f2b1d1edea73797b31cd63094fa82052fed84c06d45d6c719170d8f6f",
"signature_type": "ecdsa"
},
"signature_type": "ecdsa",
"public_key": {
"hex_bytes": "047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c757367",
"curve_type": "secp256k1"
},
"hex_bytes": "877f315ab0e84ac781395b4c1ce2978f77e316abe2f6eb058a22e80e14246d5c9e2e2d8ff863dca53be432aa65154a39d4b6b5304774e8ebcbe3117fd17e35dd"
},
{
"signing_payload": {
"account_identifier": {
"address": "8b84c3a3529d02a9decb5b1a27e7c8d886e17e07ea0a538269697ef09c2a27b4"
},
"hex_bytes": "0a69632d726571756573747a67e99e9f5e1cdfa741f8f757bb8c04f00a5fdb20a68bb273ce80973af7a6de",
"signature_type": "ecdsa"
},
"signature_type": "ecdsa",
"public_key": {
"hex_bytes": "047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c757367",
"curve_type": "secp256k1"
},
"hex_bytes": "bbb93c5e86b8b42128dcac381051e996949f0d8cfc70cc3e8f2bbd2d4788cce7ac8c8d5bc179adf528cebd2c8b61e6288e0b0595d85a11b56fd1649dbaafcffb"
}
]
}'
The response will resemble the following:
{'signed_transaction': '81826b5452414e53414354494f4e81a266757064617465a367636f6e74656e74bf6c726571756573745f747970656463616c6c6b63616e69737465725f69644a000000000000000201016b6d6574686f645f6e616d656773656e645f70626361726758480a0b08baea959fe0a9e58dbd0112040a02080a1a0308904e2a220a207f622708b363917e3ba0ef8ac1cb0dfe241ef5ffca54f32c1480473ee3a12cad3a0a0899d9c88df3d893e0176673656e646572581d2e70031d8e7ff922b6ad9f2a9eb3c1e77ffa7b6c0d0120dd4ac7e4f7026e696e67726573735f6578706972791b17c04eff12cf8023ff6d73656e6465725f7075626b657958583056301006072a8648ce3d020106052b8104000a034200047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c7573676a73656e6465725f7369675840877f315ab0e84ac781395b4c1ce2978f77e316abe2f6eb058a22e80e14246d5c9e2e2d8ff863dca53be432aa65154a39d4b6b5304774e8ebcbe3117fd17e35dd6a726561645f7374617465a367636f6e74656e74bf6c726571756573745f747970656a726561645f73746174656673656e646572581d2e70031d8e7ff922b6ad9f2a9eb3c1e77ffa7b6c0d0120dd4ac7e4f70265706174687381824e726571756573745f73746174757358208c85871f2b1d1edea73797b31cd63094fa82052fed84c06d45d6c719170d8f6f6e696e67726573735f6578706972791b17c04eff12cf8023ff6d73656e6465725f7075626b657958583056301006072a8648ce3d020106052b8104000a034200047a83e378053f87b49aeae53b3ed274c8b2ffbe59d9a51e3c4d850ca8ac1684f7131b778317c0db04de661c7d08321d60c0507868af41fe3150d21b3c6c7573676a73656e6465725f7369675840bbb93c5e86b8b42128dcac381051e996949f0d8cfc70cc3e8f2bbd2d4788cce7ac8c8d5bc179adf528cebd2c8b61e6288e0b0595d85a11b56fd1649dbaafcffb'}