Ask or search…
K
Links

Get all assets the wallet holds

This endpoint can help you fetch all the Assets a wallet holds including native tokens, fungible tokens, non fungible tokens & multitokens.
Managing digital assets across various blockchain networks can be a challenging task. However, with TatumSDK, a powerful TypeScript library, developers can effortlessly retrieve wallet balances from multiple blockchains using a unified interface. This guide will demonstrate how to leverage TatumSDK's cross-chain capabilities to obtain wallet balances on Ethereum and Bitcoin, two popular, yet different blockchain networks. By following the steps outlined, you'll be able to streamline the development process and build applications that easily interact with multiple blockchains, saving time and reducing complexity.

How to get a balance on Ethereum network

Use the TatumSDK (@tatumio/tatum) to get a balance of the wallet.
TatumSDK wraps multiple different calls to the Tatum API together in 1 function, so we don't show here the curl example for using direct HTTP API calls. You can check the API documentation for specific operations, which are internally used inside the library.
TypeScript
JavaScript
1
// yarn add @tatumio/tatum
2
import {TatumSDK, Network, Ethereum, ResponseDto, AddressBalance} from '@@tatumio/tatum'
3
4
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
5
6
const balance: ResponseDto<AddressBalance[]> = await tatum.address.getBalance({
7
addresses: ['0xF64E82131BE01618487Da5142fc9d289cbb60E9d'], // replace with your address
8
})
9
10
console.log(balance.data)
1
// Install with: npm install @tatumio/tatum
2
import { TatumSDK, Network } from "@tatumio/tatum";
3
4
(async () => {
5
try {
6
const tatum = await TatumSDK.init({ network: Network.ETHEREUM });
7
const balance = await tatum.address.getBalance({
8
addresses: ['0xF64E82131BE01618487Da5142fc9d289cbb60E9d'], // replace with your address
9
});
10
console.log(balance.data);
11
} catch (error) {
12
console.error("Error fetching wallet balance:", error);
13
}
14
})();
Expected Response
[
{
asset: 'ETH',
address: '0xF64E82131BE01618487Da5142fc9d289cbb60E9d',
decimals: 18,
balance: '0.001',
type: 'native',
}
]

How to get a balance on the Bitcoin network

In order to get a balance of a Bitcoin address, you can use the same approach and reuse the same code.
TypeScript
JavaScript
1
// yarn add @tatumcom/js
2
import {TatumSDK, Network, Bitcoin, ResponseDto, AddressBalance} from '@tatumio/tatum'
3
4
const tatum = await TatumSDK.init<Bitcoin>({network: Network.BITCOIN})
5
6
const balance: ResponseDto<AddressBalance[]> = await tatum.address.getBalance({
7
addresses: ['bc1q7zw9ax8tm4jk2k2674u6lcd9fwjut8kqtvfeg8'], // replace with your address
8
})
9
10
console.log(balance.data)
11
12
// Expected outcome
13
// [{
14
// asset: 'BTC',
15
// address: 'bc1q7zw9ax8tm4jk2k2674u6lcd9fwjut8kqtvfeg8',
16
// decimals: 8,
17
// balance: '0.001',
18
// type: 'native',
19
// }]
1
// Install with: npm install @tatumcom/js
2
const { TatumSDK, Network } = require("@tatumio/tatum");
3
4
(async () => {
5
try {
6
const tatum = await TatumSDK.init({ network: Network.BITCOIN });
7
const balance = await tatum.address.getBalance({
8
addresses: ["bc1q7zw9ax8tm4jk2k2674u6lcd9fwjut8kqtvfeg8"], // replace with your address
9
});
10
console.log(balance.data);
11
} catch (error) {
12
console.error("Error fetching wallet balance:", error);
13
}
14
})();
15
16
// Expected outcome
17
// [{
18
// asset: 'BTC',
19
// address: 'bc1q7zw9ax8tm4jk2k2674u6lcd9fwjut8kqtvfeg8',
20
// decimals: 8,
21
// balance: '0.001',
22
// type: 'native',
23
// }]
You can see, that the same request and response is used for different blockchain networks.

Request interface

1
interface AddressBalanceDetails {
2
/**
3
* List of addresses to check. Some blockchain network supports only 1 address at a time
4
*/
5
addresses: string[]
6
/**
7
* Optional page size. If not specified, the default page size is used, which is 10.
8
*/
9
pageSize?: number
10
/**
11
* Optional page number. If not specified, the first page is returned.
12
*/
13
page?: number
14
}

Response interface

1
interface ResponseDto<T> {
2
/**
3
* Actual payload of the response
4
*/
5
data: T
6
/**
7
* Status of the response
8
*/
9
status: Status
10
/**
11
* In case of ERROR status, this field contains the error message and detailed description
12
*/
13
error?: ErrorWithMessage
14
}
15
16
interface AddressBalance {
17
/**
18
* Blockchain address of the balance.
19
*/
20
address: string
21
/**
22
* Asset of the balance. For native currencies, it's always present. For tokens, only when readable from the contract `symbol()` method.
23
*/
24
asset?: string
25
/**
26
* Decimals of the asset. Valid for native and fungible tokens. For tokens, only when readable from the contract `decimals()` method.
27
*/
28
decimals?: number
29
/**
30
* Balance of the address.
31
*/
32
balance: string
33
/**
34
* Type of the balance.
35
*/
36
type: 'native' | 'fungible' | 'nft' | 'mutlitoken'
37
/**
38
* Optional token contract address. Valid only for tokens (USDT, NFTs of any kind), not for native network balances (ETH, BTC).
39
*/
40
tokenAddress?: string
41
/**
42
* Optional token ID. Valid only for non-fungible and semi-fungible tokens.
43
*/
44
tokenId?: string
45
/**
46
* Block number of the last balance update.
47
*/
48
lastUpdatedBlock?: number
49
}

Supported blockchain networks

Network
Support
Ethereum / Ethereum Sepolia BNB Smart Chain / BNB Smart Chain Testnet Celo / Celo Alfajores Polygon / Polygon Mumbai Chilliz
Multiple addresses per 1 invocation Native Assets ERC-20 Tokens (USDT, USDC,...) NFTs (BAYC,...) ERC-1155 Tokens
Solana / Solana Devnet
Multiple addresses per 1 invocation Native Assets (SOL)
XRP / XRP Testnet Bitcoin / Bitcoin Testnet Litecoin / Litecoin Testnet Dogecoin / Dogecoin Testnet Cardano / Cardano Preprod
Native Assets Only 1 address per 1 invocation
© Tatum Technology, LLC