createNetworkTransaction

Cosmos RPC

Overview

The createNetworkTransaction method allows you to create a network-specific transaction from an unsigned transaction and an array of provided signatures. The signed transaction returned from this method will be sent to the submitTransaction endpoint by the caller.

Parameters

NameTypeRequiredDescription
networkIdentifierobjectYesIdentifies the Cosmos blockchain and network details.
blockchainstring (from networkIdentifier)YesThe blockchain identifier, typically "Cosmos".
networkstring (from networkIdentifier)YesThe network name on which the transaction is taking place.
subNetworkIdentifierobject (from networkIdentifier)NoOptional sub-network identifier object.
networkstring (from subNetworkIdentifier)YesThe name of the sub-network within Cosmos.
metadataobject (from subNetworkIdentifier)NoMetadata associated with the sub-network.
unsignedTransactionstringYesContains the unsigned transaction blob.
signaturesarrayYesAn array of signature objects.
signing_payloadobject (from signatures)YesThe payload that was signed.
addressstring (from signing_payload)No[DEPRECATED] Network-specific address of the account that should sign the payload.
accountIdentifierobject (from signing_payload)NoContains information about the account.
addressstring (from accountIdentifier)YesThe Cosmos account address associated with the operation.
sub_accountobject (from accountIdentifier)NoOptional sub-account object.
addressstring (from sub_account)YesThe sub-account address.
metadataobject (from sub_account)NoMetadata for the sub-account.
metadataobject (from accountIdentifier)NoMetadata for the account.
hex_bytesstring (from signing_payload)YesHex-encoded string of the payload bytes.
signatureTypestring (from signing_payload)NoSignature type (e.g., "ecdsa", "ed25519").
publicKeyobject (from signatures)YesContains the public key.
hexBytesstring (from publicKey)YesHexadecimal representation of the public key.
curveTypestring (from publicKey)YesThe cryptographic curve type of the public key (e.g., "secp256k1").
signatureTypestring (from signatures)YesThe type of signature (e.g., "ecdsa", "ed25519").
hexBytesstring (from signatures)YesHex-encoded signature.

Returns

FieldTypeDescription
signedTransactionstringA string that represents the fully signed transaction ready for submission.

Example Result

{
  "signedTransaction": "0x..."
}

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/cosmos-mainnet/construction/combine' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
    "networkIdentifier": {
        "blockchain": "cosmos",
        "network": "mainnet"
    },
    "unsignedTransaction": "YOUR_UNSIGNED_TRANSACTION",
    "signatures": [
      {
        "signing_payload": {
            "hex_bytes": "HEX_ENCODED_PAYLOAD_BYTES"
        },
        "publicKey": {
            "hexBytes": "PUBLIC_KEY_HEX",
            "curveType": "secp256k1"
        },
        "signatureType": "ecdsa",
        "hexBytes": "SIGNATURE_HEX"
      }
    ]
}'
// Import required libraries and modules from Tatum SDK
import { TatumSDK, Cosmos, Network } from "@tatumio/tatum";

// Initialize the Tatum SDK for Cosmos
const cosmos = await TatumSDK.init<Cosmos>({ network: Network.COSMOS_MAINNET });

// Define the input parameters with only required fields
const params = {
  networkIdentifier: {
    blockchain: "cosmos",
    network: "mainnet",
  },
  unsignedTransaction: "YOUR_UNSIGNED_TRANSACTION",
  signatures: [
    {
      signing_payload: {
        hexBytes: "PAYLOAD_HEX", // Hex-encoded payload bytes.
      },
      publicKeys: [
        {
          hexBytes: "PUBLIC_KEY_HEX", // Hexadecimal representation of the public key.
          curveType: "secp256k1", // Curve type (secp256k1, secp256k1_bip340, secp256r1, edwards25519, tweedle, pallas).
        },
      ],
      signatureType: "ecdsa", // Signature type (ecdsa, ecdsa_recovery, ed25519, schnorr_1, schnorr_bip340, schnorr_poseidon).
      hexBytes: "SIGNATURE_HEX", // Hex-encoded signature.
    },
  ],
};

// Create network transaction from signatures
const networkTransaction = await tatum.rpc.createNetworkTransaction(params);

// Log the network transaction
console.log("Network Transaction:", networkTransaction);

// Always destroy the Tatum SDK instance when done to stop any background processes
await tatum.destroy();