Skip to main content

Get an Account Balance

An AccountBalanceRequest is utilized to make a balance request on the /account/balance endpoint. If the block_identifier is populated, a historical balance query should be performed.

Request Body

REQUIRED

network_identifier

object

REQUIRED

The network_identifier specifies which network a particular object is associated with.

blockchain

string

REQUIRED

Blockchain name

network

string

REQUIRED

If a blockchain has a specific chain-id or network identifier, it should go in this field. It is up to the client to determine which network-specific identifier is mainnet or testnet.

sub_network_identifier

object

In blockchains with sharded state, the SubNetworkIdentifier is required to query some object on a specific shard. This identifier is optional for all non-sharded blockchains.

network

string

REQUIRED

Network name

metadata

object

Meta data from subnetwork identifier

producer

string

REQUIRED

producer

account_identifier

object

REQUIRED

The account_identifier uniquely identifies an account within a network. All fields in the account_identifier are utilized to determine this uniqueness (including the metadata field, if populated).

address

string

REQUIRED

The address may be a cryptographic public key (or some encoding of it) or a provided username.

sub_account

object

An account may have state specific to a contract address (ERC-20 token) and/or a stake (delegated balance). The sub_account_identifier should specify which state (if applicable) an account instantiation refers to.

address

string

REQUIRED

The address may be a cryptographic public key (or some encoding of it) or a provided username.

metadata

object

If the SubAccount address is not sufficient to uniquely specify a SubAccount, any other identifying information can be stored here. It is important to note that two SubAccounts with identical addresses but differing metadata will not be considered equal by clients.

metadata

object

Blockchains that utilize a username model (where the address is not a derivative of a cryptographic public key) should specify the public key(s) owned by the address in metadata.

block_identifier

object

When fetching data by BlockIdentifier, it may be possible to only specify the index or hash. If neither property is specified, it is assumed that the client is making a request at the current block.

Responses

200

Success

Schema

OPTIONAL

block_identifier

object

The block_identifier uniquely identifies a block in a particular network.

hash

string

This is also known as the block hash.

index

integer

This is also known as the block height.

balances

object[]

A single account balance may have multiple currencies

value

string

Value of the transaction in atomic units represented as an arbitrary-sized signed integer. For example, 1 BTC would be represented by a value of 100000000.

currency

object

Currency is composed of a canonical Symbol and Decimals. This Decimals value is used to convert an Amount.Value from atomic units (Satoshis) to standard units (Bitcoins).

symbol

string

Canonical symbol associated with a currency.

decimals

integer

Number of decimal places in the standard unit representation of the amount. For example, BTC has 8 decimals. Note that it is not possible to represent the value of some currency in atomic units that is not base 10.

metadata

object

OPTIONAL

Any additional information related to the currency itself. For example, it would be useful to populate this object with the contract address of an ERC-20 token.

metadata

object

OPTIONAL

coins

object[]

OPTIONAL

If a blockchain is UTXO-based, all unspent Coins owned by an account_identifier should be returned alongside the balance. It is highly recommended to populate this field so that users of the Rosetta API implementation don't need to maintain their own indexer to track their UTXOs.

coin_identifier

object

CoinIdentifier uniquely identifies a Coin.

identifier

string

Identifier should be populated with a globally unique identifier of a Coin. In Bitcoin, this identifier would be transaction_hash:index.

amount

object

Amount is some Value of a Currency. It is considered invalid to specify a Value without a Currency.

value

string

Value of the transaction in atomic units represented as an arbitrary-sized signed integer. For example, 1 BTC would be represented by a value of 100000000.

currency

object

Currency is composed of a canonical Symbol and Decimals. This Decimals value is used to convert an Amount.Value from atomic units (Satoshis) to standard units (Bitcoins).

symbol

string

Canonical symbol associated with a currency.

decimals

integer

Number of decimal places in the standard unit representation of the amount. For example, BTC has 8 decimals. Note that it is not possible to represent the value of some currency in atomic units that is not base 10.

metadata

object

OPTIONAL

Any additional information related to the currency itself. For example, it would be useful to populate this object with the contract address of an ERC-20 token.

metadata

object

OPTIONAL

metadata

object

OPTIONAL

Account-based blockchains that utilize a nonce or sequence number should include that number in the metadata. This number could be unique to the identifier or global across the account address.

sequence_number

integer

400

Error

Schema

OPTIONAL

code

integer

Code is a network-specific error code. If desired, this code can be equivalent to an HTTP status code.

message

string

Message is a network-specific error message. The message MUST NOT change for a given code. In particular, this means that any contextual information should be included in the details field.

retriable

boolean

An error is retriable if the same request may succeed if submitted again.

details

object

OPTIONAL

Often times it is useful to return context specific to the request that caused the error (i.e. a sample of the stack trace or impacted account) in addition to the standard error message.

address

string

OPTIONAL

error

string

OPTIONAL