Skip to main content

Sample Requests

Advanced API

Below are a few examples for making requests to the Coinbase Node's Advanced API using the Coinbase Cloud SDK.

Balances

GetSingleBalance

import { GetSingleBalanceResponse } from 'coinbase-cloud-sdk';

const singleBalance: GetSingleBalanceResponse = await coinbaseCloud.advanced
.getSingleBalance(
'0x00000000DF0635793e91d4f8e7426dbd9ed08471186f428D',
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
);

See getSingleBalance.

GetBalances

import { GetBalancesResponse } from 'coinbase-cloud-sdk';

const balances: GetBalancesResponse = await coinbaseCloud.advanced
.getBalances([
{
address: '0x00000000DF0635793e91d4f8e7426dbd9ed08471186f428D',
contract: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
},
{
address: '0xdf0635793e91d4f8e7426dbd9ed08471186f428d',
contract: '0x6b175474e89094c44da98b954eedeac495271d0f'
}
]);

See getBalances.

Allowances

GetTokenAllowances

import { GetTokenAllowancesResponse } from 'coinbase-cloud-sdk';

const allowances: GetTokenAllowancesResponse = await coinbaseCloud.advanced
.getTokenAllowances([
{
owner: '0xa646147bda82a866eba03568f363fc9c90185c6e',
spender: '0xadd0e097b961572b2a1f5de572c622eef97e3d82',
contracts: ['0xdac17f958d2ee523a2206206994597c13d831ec7']
}
]);

See getTokenAllowances.

Transactions and Transfers

GetTransactionByHash

import { GetTransactionByHashResponse } from 'coinbase-cloud-sdk';

const transaction: GetTransactionByHashResponse = await coinbaseCloud.advanced
.getTransactionByHash(
'0x2be70b2bcff662ba941c3f3c7706ef2c674d0d0ea4a13a91543cbe18862063d4'
);

See getTransactionByHash.

GetTransactionsByAddress

import { GetTransactionsByAddressResponse } from 'coinbase-cloud-sdk';

const transactions: GetTransactionsByAddressResponse = await coinbaseCloud.advanced
.getTransactionsByAddress(
'0xcAfB10eE663f465f9d10588AC44eD20eD608C11e',
'0x0',
'0xf183f2',
'SENDER_OR_RECEIVER',
'desc',
20,
1
);

See getTransactionsByAddress.

GetTokenTransfersByAddress

import { GetTokenTransfersByAddressResponse } from 'coinbase-cloud-sdk';

const tokenTransfers: GetTokenTransfersByAddressResponse = await coinbaseCloud.advanced
.getTokenTransfersByAddress(
'0x0000000000000000000000000000000000000000',
'0xdb0db3',
'0xea11e0',
'RECEIVER_ONLY',
'asc',
10,
1
);

See getTokenTransfersByAddress.

Contracts

GetTokenStandardEvents

import { GetTokenStandardEventsResponse } from 'coinbase-cloud-sdk';

const tokenEvents: GetTokenStandardEventsResponse = await coinbaseCloud.advanced
.getTokenStandardEvents(
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'0x1',
'0xea11e0',
['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'],
'desc',
10,
1
);

See getTokenStandardEvents.

GetTokenMetadata

import { GetTokenContractMetadataResponse } from 'coinbase-cloud-sdk';

const tokenMetadata: GetTokenContractMetadataResponse = await coinbaseCloud.advanced
.getTokenMetadata('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48');

See getTokenMetadata.

Was this helpful?