constructionMetadata

Rosetta API for Cosmos

Overview

The constructionMetadata method retrieves metadata necessary to construct transactions for a specific network using the Rosetta API. This is particularly useful in environments where transactions need to be constructed offline or in secure environments.

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 (e.g., "mainnet" or "testnet").
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.
optionsobjectNoOptional parameters for specifying the metadata required for different types of transactions. Can include various flags and values depending on the transaction type.
publicKeysarrayNoList of public keys involved in the transaction. Each object in the array contains hexBytes and curveType.
hexBytesstring (from publicKey)YesHexadecimal representation of the public key.
curveTypestring (from publicKey)YesCryptographic curve associated with the public key (e.g., "secp256k1").

Returns

FieldTypeDescription
metadataobjectContains necessary metadata for transaction construction including signers, sequence number, and recent block hash.

Example Result

{
  "metadata": {
    "requiredSigners": [
      {
        "publicKey": "03fa...",
        "signatureType": "ecdsa_recovery"
      }
    ],
    "sequence": 45,
    "recentBlockHash": "abcd1234..."
  }
}

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"
    }
}'
// yarn add @tatumio/tatum

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

const cosmos = await TatumSDK.init<CosmosRosetta>({
  network: Network.COSMOS_ROSETTA,
});

const constructionMetadata = await tatum.rpc.constructionMetadata({
  networkIdentifier: {
    blockchain: "cosmos",
    network: "mainnet",
  },
});

console.log(constructionMetadata);

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