constructionPayloads

Rosetta API for Cosmos

Overview

The constructionPayloads contains the network, a slice of operations, and arbitrary metadata that was returned by the call to constructionMetadata. Optionally, the request can also include an array of publicKeys associated with the AccountIdentifiers returned in constructionPreprocess response.

Parameters

NameTypeRequiredDescription
networkIdentifierobjectYesIdentifies the Cosmos blockchain and network details.
blockchainstring (from networkIdentifier)YesThe name of the blockchain, typically "Cosmos".
networkstring (from networkIdentifier)YesThe network name on which the transaction is taking place.
subNetworkIdentifierobject (from networkIdentifier)NoOptional sub-network identifier.
networkstring (from subNetworkIdentifier)YesThe name of the sub-network within Cosmos.
metadataobject (from subNetworkIdentifier)NoMetadata associated with the sub-network.
operationsarrayYesAn array of operation objects, each representing a transaction component.
operationIdentifierobject (from operations)YesIdentifier for the operation. Includes index and optionally network_index.
indexnumber (from operationIdentifier)YesThe index of the operation within the transaction.
network_indexnumber (from operationIdentifier)NoNetwork-specific index of the operation.
relatedOperationsarray (from operations)NoOperations related to the current operation.
indexnumber (from relatedOperations)YesIndex of related operations.
network_indexnumber (from relatedOperations)NoNetwork-specific index of related operations.
typestring (from operations)YesThe type of operation, e.g., "TRANSFER".
statusstring (from operations)NoThe status of the operation.
accountobject (from operations)NoThe account involved in the operation. Includes address, and optionally subAccount and metadata.
addressstring (from account)YesThe Cosmos account address associated with the operation.
subAccountobject (from account)NoAn optional sub-account object.
metadataobject (from account)NoMetadata for the account.
addressstring (from subAccount)YesThe sub-account address.
metadataobject (from subAccount)NoAn optional metadata object for the sub-account.
amountobject (from operations)NoThe monetary amount involved in the operation. Includes value, currency, and optionally metadata.
valuestring (from amount)YesThe value of the transaction amount.
currencyobject (from amount)YesAn object specifying the currency details. Includes symbol, decimals, and optionally metadata.
metadataobject (from amount)NoMetadata object for the amount.
symbolstring (from currency)YesThe symbol or code of the currency.
decimalsnumber (from currency)YesThe number of decimal places for the currency.
metadataobject (from currency)NoAny additional information related to the currency itself, such as contract addresses.
coin_changeobject (from operations)NoInformation about changes to the coin state (e.g., created or spent).
coinIdentifierobject (from coin_change)YesAn object containing a coin identifier.
identifierstring (from coinIdentifier)YesIdentifier should be populated with a globally unique identifier of a Coin.
coin_actionstring (from coin_change)YesCoinActions are different state changes that a Coin can undergo.
publicKeysarrayNoList of public keys involved in authorizing the transaction.
hexBytesstring (from publicKeys)YesHexadecimal representation of the public key.
curveTypestring (from publicKeys)YesThe cryptographic curve type of the public key, e.g., "secp256k1".
metadataobject (from operations)NoAdditional information about the operation.
metadataobjectNoOptional metadata for transaction construction.

Returns

FieldTypeDescription
unsigned_transactionstringA hexadecimal string representing the unsigned transaction data.
payloadsarrayAn array of objects containing the information that must be signed.

Example Result

{
  "unsigned_transaction": "0x...",
  "payloads": [
    {
      "address": "cosmos1...",
      "hex_bytes": "f2ca1bb6c7...",
      "signature_type": "ecdsa_recovery"
    }
  ]
}

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/cosmos/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
    "networkIdentifier": {
        "blockchain": "cosmos",
        "network": "mainnet"
    },
    "operations": [
      {
        "operationIdentifier": {
          "index": 1
        },
        "type": "TRANSFER",
      }
    ]
}'
// yarn add @tatumio/tatum

import { TatumSDK, Cosmos, Network } from "@tatumio/tatum";

const cosmos = await TatumSDK.init<Cosmos>({ network: Network.COSMOS_MAINNET });

const params = {
  networkIdentifier: {
    blockchain: "cosmos",
    network: "mainnet",
  },
  operations: [
    {
      operationIdentifier: {
        index: 1,
      },
      type: "TRANSFER",
    },
  ],
  publicKeys: [
    {
      hexBytes: "abc123...",
      curveType: "secp256k1",
    },
  ],
};

const constructionPayloads = await tatum.rpc.constructionPayloads(params);

console.log("Construction Payloads:", constructionPayloads);

await tatum.destroy(); // Destroy Tatum SDK - needed for stopping background jobs