accountCoins

Rosetta API for {{blockchain}}

Overview

The accountCoins method retrieves information about the coins stored at a specific account address on the {{blockchain}} network, using the Rosetta API. This includes detailed data on each coin or token associated with the account, which is crucial for tracking asset distributions and understanding the account's composition on the blockchain.

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.
accountIdentifierobjectYesContains information about the account.
addressstring (from accountIdentifier)YesThe account address associated with the operation.
sub_accountobject (from accountIdentifier)NoOptional sub-account information.
metadataobject (from accountIdentifier)NoOptional metadata for the account, including public keys if relevant.
addressstring (from sub_account)YesThe sub-account address.
metadataobject (from sub_account)NoMetadata for the sub-account.
includeMempoolbooleanYesInclude state from the mempool when looking up an account's unspent coins. Note, using this functionality breaks any guarantee of idempotency.
currencyobjectNoSpecifies the currency details.
symbolstring (from currency)YesThe symbol or code of the currency.
decimalsnumber (from currency)YesThe number of decimal places for the currency.
metadataobject (from currency)NoAdditional information related to the currency, such as the contract address.

Returns

The response includes details about each coin held in the specified account and sub-account (if provided):

FieldDescription
coinsA list of coin objects representing each asset held by the account.
blockIdentifierThe block identifier where the latest balance snapshot was taken.

Example Result

{
  "blockIdentifier": {
    "index": 1234567,
    "hash": "a1b2c3d4..."
  },
  "coins": [
    {
      "coin_identifier": {
        "identifier": "coin1"
      },
      "amount": {
        "value": "100000000",
        "currency": {
          "symbol": "ATOM",
          "decimals": 6
        }
      }
    }
  ]
}

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/cosmos-mainnet/account/coins' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
    "networkIdentifier": {
        "blockchain": "{{blockchain}}",
        "network": "{{network}}"
    },
    "accountIdentifier": {
        "address": "{{address}}",
    },
    "include_mempool": true
}'
// yarn add @tatumio/tatum

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

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

const accountCoins = await tatum.rpc.getAccountCoins({
  networkIdentifier: {
    blockchain: "{{blockchain}}",
    network: "{{network}}"
  },
  accountIdentifier: {
    address: "{{address}}",
  },
  include_mempool: true
});

console.log(accountCoins);

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