GoldRush SDK for Rust
A Rust client library for the GoldRush blockchain data APIs by Covalent. Fetch token balances, transaction history, NFT data, and more across 100+ blockchain networks.
Features
- ๐ Async/await support with Tokio
- ๐ก๏ธ Type-safe API responses with serde
- ๐ Automatic retries with exponential backoff
- ๐ Comprehensive error handling
- ๐ Multi-chain support (Ethereum, Polygon, BSC, Avalanche, and more)
- ๐ Built-in pagination helpers
- ๐งช Extensive test coverage
Supported Endpoints
- Token Balances - Get ERC-20 token balances for any address
- Transactions - Fetch transaction history with detailed information
- NFTs - Query NFT holdings and metadata
- Historical Data - Access portfolio valuations over time
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["macros", "rt-multi-thread"] }
Basic Usage
use ;
async
Examples
Token Balances
use ;
let options = new
.quote_currency
.no_spam
.page_size;
let balances = client
.get_token_balances_for_wallet_address
.await?;
Transaction History
use ;
let options = new
.page_size
.quote_currency
.with_log_events;
let transactions = client
.get_all_transactions_for_address
.await?;
NFT Holdings
use ;
let options = new
.with_metadata
.no_spam
.page_size;
let nfts = client
.get_nfts_for_address
.await?;
Specific Transaction
let transaction = client
.get_transaction
.await?;
NFT Metadata
let metadata = client
.get_nft_metadata
.await?;
Supported Chains
The SDK supports all chains available in the GoldRush API. Some popular ones include:
- Ethereum -
eth-mainnet,eth-goerli,eth-sepolia - Polygon -
matic-mainnet,matic-mumbai - BSC -
bsc-mainnet,bsc-testnet - Avalanche -
avalanche-mainnet,avalanche-fuji - Arbitrum -
arbitrum-mainnet,arbitrum-goerli - Optimism -
optimism-mainnet,optimism-goerli - Base -
base-mainnet,base-goerli
For the full list, see the GoldRush documentation.
Configuration
Client Configuration
use ;
use Duration;
let config = default
.with_timeout
.with_max_retries
.with_user_agent;
let client = new?;
Custom Base URL
let config = new
.with_timeout;
let client = new?;
Error Handling
The SDK provides comprehensive error types:
use Error;
match client.get_token_balances_for_wallet_address.await
Pagination
Manual Pagination
let mut page = 0;
loop
Using Iterator Helper
use ;
let options = new.page_size;
let mut iter = new;
while let Some = iter.next.await?
Running Examples
Clone this repository and run the examples:
# Set your API key
# Run balance example
# Run with specific address
# Run transaction example
# Run NFT example
Testing
Run the unit tests:
Run integration tests (requires API key):
API Key
Get your free API key from the Covalent Dashboard.
- Free tier: 100,000 API credits per month
- Generous rate limits for development and small applications
- Production plans available for higher volumes
Related Projects
- TypeScript SDK: @covalenthq/client-sdk
- Go SDK: covalent-api-sdk-go
- GoldRush Kit: React components for blockchain UIs
- Block Explorer Template: Built with GoldRush
Requirements
- Rust 1.70.0 or later
- Tokio runtime for async support
Roadmap
- WebSocket support for real-time data
- Additional analytics endpoints
- More comprehensive pagination helpers
- CLI tools
- Framework integrations (Axum, Actix)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
TODOs for Maintainers
The following items need confirmation from the Covalent team:
- Base URL: Confirm exact production URL for GoldRush API (currently using
https://api.goldrush.dev) - Endpoint Paths: Verify exact paths for all endpoints (e.g.,
/v1/{chain}/address/{address}/balances_v2/) - Response Formats: Align models with actual API response structure
- Chain Names: Confirm supported chain identifiers format
- Error Codes: Map specific API error codes to appropriate error variants
- Crate Name: Finalize crate name and repository URL
- Authentication: Confirm Bearer token format vs other auth methods
Links
- GoldRush API Documentation: https://goldrush.dev/docs/overview
- Covalent Website: https://www.covalenthq.com/
- TypeScript SDK: https://www.npmjs.com/package/@covalenthq/client-sdk
- Go SDK: https://github.com/covalenthq/covalent-api-sdk-go