Introduction
This quickstart guide walks through using the GoldRush TypeScript SDK to quickly build with multichain data leveraging the powerful GoldRush APIs.
Prerequisites
Using any of the GoldRush developer tools requires an API key.
Supported Chains
GoldRush can be used with any of the supported chains. See the full list, including chain categorization, at Supported Chains.
Some data enrichments such as internal transactions and historical balance fetches are only available for Foundational Chains.
Using the GoldRush TypeScript SDK
The GoldRush TypeScript SDK is the fastest way to integrate the GoldRush APIs for working with blockchain data. The SDK works with all supported chains including Mainnets and Testnets.
This SDK requires NodeJS v18 or above.
Step 1. Install the SDK
npm install @covalenthq/client-sdk
See the package on npmjs for more details.
Step 2. Import the Client
The GoldRushClient class provides typesafe, easy-to-use helper functions and classes to use the GoldRush APIs.
import { GoldRushClient } from "@covalenthq/client-sdk";
Step 3. Initialize the Client
import { GoldRushClient } from "@covalenthq/client-sdk";
const ApiServices = async () => {
const client = new GoldRushClient("YOUR_API_KEY");
};
Step 4. Invoke the Service
In this quickstart, we use the BalanceService and getTokenBalancesForWalletAddress() function to fetch all token balances held by an address. This function takes a chain name and wallet address as required arguments.
ENS resolution is supported for eth-mainnet.
import { GoldRushClient } from "@covalenthq/client-sdk";
const ApiServices = async () => {
// Replace with your GoldRush API key
const client = new GoldRushClient("YOUR_API_KEY");
const response = await client.BalanceService.getTokenBalancesForWalletAddress("eth-mainnet", "demo.eth");
if (!response.error) {
console.log(response.data);
} else {
console.log(response.error_message);
}
};
ApiServices();
Example response:
{
"address": "0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de",
"chain_id": 1,
"chain_name": "eth-mainnet",
"quote_currency": "USD",
"updated_at": "2024-11-05T22:18:41.522Z",
"items": [
{
"contract_decimals": 6,
"contract_name": "Tether USD",
"contract_ticker_symbol": "USDT",
"contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"contract_display_name": "Tether USD",
"supports_erc": [],
"logo_url": "https://logos.covalenthq.com/tokens/1/0xdac17f958d2ee523a2206206994597c13d831ec7.png",
"last_transferred_at": "2024-08-28T12:43:35.000Z",
"native_token": false,
"type": "stablecoin",
"is_spam": false,
"balance": "3007173042",
"balance_24h": "3007173042",
"quote_rate": 1,
"quote_rate_24h": 0.9992,
"quote": 3007.173,
"quote_24h": 3004.7673,
"pretty_quote": "$3,007.17",
"pretty_quote_24h": "$3,004.77",
"logo_urls": {},
"protocol_metadata": null,
"nft_data": null
}
]
}