construction/payloads - Cardano

This endpoint builds an unsigned transaction and the payloads that must be signed, from the operations and metadata. It is an offline step that returns the material to sign.

Parameters

The request body is a JSON object with the following fields.

FieldTypeRequiredDescription
network_identifierobjectYesThe network to construct for
operationsarrayYesThe operations describing the transaction
metadataobjectYesMetadata returned by the metadata endpoint

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/construction/payloads' \
--header 'Content-Type: application/json' \
--data-raw '{
    "network_identifier": {
        "blockchain": "cardano",
        "network": "mainnet"
    },
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "output",
            "account": {
                "address": "addr1qxy2lpan99fcnhhyzr8w8qk4dqz4mp7g6b8h3r2v5c9d0e1f2g3h4j5k6l7m8n9p0q"
            },
            "amount": {
                "value": "9240398",
                "currency": {
                    "symbol": "ADA",
                    "decimals": 6
                }
            }
        }
    ],
    "metadata": {
        "ttl": "10454789"
    }
}'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/construction/payloads',
    {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({"network_identifier": {"blockchain": "cardano", "network": "mainnet"}, "operations": [{"operation_identifier": {"index": 0}, "type": "output", "account": {"address": "addr1qxy2lpan99fcnhhyzr8w8qk4dqz4mp7g6b8h3r2v5c9d0e1f2g3h4j5k6l7m8n9p0q"}, "amount": {"value": "9240398", "currency": {"symbol": "ADA", "decimals": 6}}}], "metadata": {"ttl": "10454789"}})
    }
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/construction/payloads',
    headers={'Content-Type': 'application/json'},
    json={"network_identifier": {"blockchain": "cardano", "network": "mainnet"}, "operations": [{"operation_identifier": {"index": 0}, "type": "output", "account": {"address": "addr1qxy2lpan99fcnhhyzr8w8qk4dqz4mp7g6b8h3r2v5c9d0e1f2g3h4j5k6l7m8n9p0q"}, "amount": {"value": "9240398", "currency": {"symbol": "ADA", "decimals": 6}}}], "metadata": {"ttl": "10454789"}}
)

print(response.json())

Response

json{
    "unsigned_transaction": "a400818258200e...unsigned-cbor...",
    "payloads": [
        {
            "account_identifier": {
                "address": "addr1qxy2lpan99fcnhhyzr8w8qk4dqz4mp7g6b8h3r2v5c9d0e1f2g3h4j5k6l7m8n9p0q"
            },
            "hex_bytes": "3e6f2d8c...signing-payload",
            "signature_type": "ed25519"
        }
    ]
}

Response Parameters

FieldTypeDescription
unsigned_transactionstringThe unsigned transaction in CBOR hex
payloadsarrayThe payloads to sign, each with the account and bytes

Use Cases

  • Transaction Building: Produce an unsigned transaction from operations
  • Offline Signing: Return payloads to sign on an air-gapped device
  • Multi-Signature: Enumerate the payloads each signer must sign
  • Construction Flow: Advance the flow to the parse and combine steps

Error Handling

Error CodeMessageDescription
1Invalid requestA required construction field is missing or malformed
6Transaction decode failedThe supplied transaction could not be decoded
14Invalid signatureA supplied signature is malformed or does not match
5Internal errorThe node failed to process the construction step