construction/metadata - Cardano

This endpoint returns the online metadata needed to construct a transaction, such as the current fee parameters and time-to-live, from the options produced by preprocess.

Parameters

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

FieldTypeRequiredDescription
network_identifierobjectYesThe network to construct for
optionsobjectYesThe options returned by the preprocess endpoint
public_keysarrayNoPublic keys required for the transaction

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/construction/metadata' \
--header 'Content-Type: application/json' \
--data-raw '{
    "network_identifier": {
        "blockchain": "cardano",
        "network": "mainnet"
    },
    "options": {
        "relative_ttl": 1000,
        "transaction_size": 246
    }
}'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/construction/metadata',
    {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({"network_identifier": {"blockchain": "cardano", "network": "mainnet"}, "options": {"relative_ttl": 1000, "transaction_size": 246}})
    }
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/construction/metadata',
    headers={'Content-Type': 'application/json'},
    json={"network_identifier": {"blockchain": "cardano", "network": "mainnet"}, "options": {"relative_ttl": 1000, "transaction_size": 246}}
)

print(response.json())

Response

json{
    "metadata": {
        "ttl": 193929071,
        "protocol_parameters": {
            "coinsPerUtxoSize": "4310",
            "maxTxSize": 16384,
            "maxValSize": 5000,
            "keyDeposit": "2000000",
            "maxCollateralInputs": 3,
            "minFeeCoefficient": 44,
            "minFeeConstant": 155381,
            "minPoolCost": "170000000",
            "poolDeposit": "500000000",
            "protocol": 11
        }
    },
    "suggested_fee": [
        {
            "value": "166205",
            "currency": {
                "symbol": "ADA",
                "decimals": 6
            }
        }
    ]
}

Response Parameters

FieldTypeDescription
metadataobjectMetadata required to build the transaction, such as ttl
suggested_feearrayThe suggested fee for the transaction, in ada

Use Cases

  • Fee Fetching: Read the suggested fee before building payloads
  • TTL Resolution: Resolve the absolute time to live from relative options
  • Online Step: Fetch chain-dependent metadata for construction
  • Transaction Building: Feed metadata into the payloads endpoint

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