{[
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/Ethereum.png",
name: "Ethereum",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/Polygon.png",
name: "Polygon",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/BSC.png",
name: "BNB Chain",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/Fantom.png",
name: "Fantom",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/Avalanche.png",
name: "Avalanche",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/Arbitrum.png",
name: "Arbitrum",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/Optimism.png",
name: "Optimism",
},
{
link: "https://platform.chainbase.com/assets/rpcService/multiChain/zkSync.png",
name: "zkSync",
},
].map((v) => (
{v.name}
))}
# Overview
Source: https://docs.chainbase.com/platform/features/datacloud/overview
## What is Data Cloud
* DataCloud is a powerful online platform designed for on-chain data processing. It is tailored to provide extensive capabilities in data querying, analysis, and processing. This platform enables developers to swiftly and effectively analyze on-chain data, facilitating the creation of high-performance, low-latency APIs for streamlined Web3 application development.
* This platform significantly simplifies the process from analyzing on-chain data to building high-performance APIs, especially suitable for applications requiring real-time data monitoring and dynamic data analysis.
* DataCloud supports a wide range of users, from exchanges and DeFi application operators to market analysts, offering powerful tools to focus more on innovation and optimizing Web3 application features.
## Features
* **Unified Datasets (Raw / Decoded / Abstracted)**: The datasets have been unified, providing a more streamlined and efficient data handling experience.
* **Parameterized Queries**: Introducing parameterized templates for more flexible and efficient data querying.
* **File Explorer**: A new tool to explore and manage saved queries.
* **Task API**: Replacing the SQL API, this new feature allows for more advanced and customizable data handling tasks.
## QuickStart
**Enter Data Cloud**: Access the [Data Cloud](https://console.chainbase.com/dataCloud) interface to start your data exploration.
**Input a Simple SQL Query**: Use the following SQL query in the Data Cloud to extract information from Ethereum transaction data, focusing on a specific block number:
```sql
select
block_timestamp,
block_number,
_value,
_from,
_to
FROM ethereum.erc20_transfer
WHERE block_number = 17089970
```
This query retrieves details such as the timestamp of the block, block number, originating address, transaction value, and the transaction hash, specifically targeting transactions in block number 17089970 on the Ethereum blockchain.
**Execute the Query**: Run this query within Data Cloud to pull the specified data from the Ethereum blockchain.

**Introduction to Custom Parameters**: In Data Cloud, you have the ability to use a dedicated parameter input box, which allows for the customization of query parameters. This feature enhances the flexibility and user-friendliness of SQL queries.
**Setting Up a Query with Custom Parameters**: Hereâs an example of how you can structure an SQL query using a custom parameter for the block number:

```sql
SELECT
block_timestamp,
block_number,
from_address,
value,
gas,
hash
FROM ethereum.transactions
WHERE block_number = {blocknumber}
```
**Using the Custom Parameter Box**: When you run this query, use the custom parameter box to input or select the desired block number. This input will replace the {blocknumber} placeholder in the query, allowing you to retrieve data for that specific block on the Ethereum blockchain with ease.

**Save your query to File Explorerďź**
After saving your SQL query, it will be visible and accessible at any time within the "File Explorer" on the left side. This tool is meticulously designed to simplify your navigation and management of saved queries. With easy access to these entries in the file management panel, complemented by the search functionality at the top, you can quickly locate and retrieve previously saved queries, significantly enhancing the efficiency of your development workflow in data analysis and database management. The "File Explorer" serves as a centralized platform for viewing and organizing SQL queries, further enabling developers to manage and execute data operations with great efficiency.
Finally, by clicking on "Generate API," you can create an API endpoint that allows you to invoke the data seen in Data Cloud within your own programs, offering a 'what you see is what you get' convenience. Additionally, you have the flexibility to select from different programming languages according to your tech stack, ensuring seamless integration into your development environment.
```typescript
const apiKey = "your-api-key";
const queryId = "424242";
const headers = {
"API-KEY": apiKey,
"CONTENT-TYPE": "application/json",
};
async function executeQuery(queryId) {
return await fetch(
`https://api.chainbasehq.com/v1/query/${queryId}/execute`,
{ method: "POST", headers }
)
.then((response) => response.json())
.then((data) => data.data[0].executionId);
}
async function checkStatus(executionId) {
return await fetch(
`https://api.chainbasehq.com/v1/execution/${executionId}/status`,
{ headers }
)
.then((response) => response.json())
.then((data) => data.data[0].status);
}
async function getResults(executionId) {
return await fetch(
`https://api.chainbasehq.com/v1/execution/${executionId}/results`,
{ headers }
).then((response) => response.json());
}
async function main() {
const executionId = await executeQuery(queryId);
let status;
do {
status = await checkStatus(executionId);
await new Promise((resolve) => setTimeout(resolve, 1000));
} while (status !== "FINISHED" && status !== "FAILED");
return await getResults(executionId);
}
main().then(console.log);
```

## SQL Example
**Query the total cross-chain amount for a user:**
```sql
SELECT
'out' as type,
project,
token,
from_chain,
to_chain,
sum(cast(amount as decimal(38, 0))) as total
FROM
bridge_ethereum.transfers
WHERE
"from" = '0xf99d58e463a2e07e5692127302c20a191861b4d6'
group by
project,
token,
from_chain,
to_chain
UNION ALL
SELECT
'in' as type,
project,
token,
from_chain,
to_chain,
sum(cast(amount as decimal(38, 0))) as total
FROM
bridge_ethereum.transfers
WHERE
"to" = '0xf99d58e463a2e07e5692127302c20a191861b4d6'
group by
project,
token,
from_chain,
to_chain
```
This query consists of two parts: one part calculates the total amount of funds sent from a specific address (marked as 'out'), and the other part calculates the total amount of funds sent to that address (marked as 'in'). The two parts are combined using UNION ALL to provide a complete view of the total cross-chain transfer amount.
**Query the total liquidity provided by the user for each liquidity pool.**
```sql
select
project,
pool,
token_address,
sum(cast(amount as decimal(38, 0)))
from
dex_ethereum.liquidity
where
"from" = '{{UserAddress}}'
or "to" = '{{UserAddress}}'
group by
project,
pool,
token_address
```
**Query for token holdings**
```sql
select
*
from
ethereum.erc20_balances b
left join ethereum.token_metas t on t.contract_address = b.contract_address
where
wallet_address = '0x2e12979da9ad061ccc204c00d0e3a477a8cc4aea'
limit
10
```
**Query the total amount of loans and collateral for a user.**
```sql
with
lending_raw as (
select
project,
asset,
category,
sum(cast(amount as decimal(38, 0))) as total_amount
from
lending_ethereum.feeds
where
account = '{{UserAddress}}'
group by
project,
asset,
category
)
select
project,
asset,
category,
total_amount / t.decimals as volume,
t.name
from
lending_raw l
left join ethereum.token_metas t on t.contract_address = l.asset
```
DataCloud fundamentally transforms how we interact with blockchain data, offering unprecedented flexibility and efficiency for all Web3 developers. As you embark on this journey of exploration and innovation, Chainbase will be your ultimate partner, guiding you through the ever-evolving realm of Web3 development.
# Write Efficient Queries
Source: https://docs.chainbase.com/platform/features/datacloud/write-efficient-queries
## Tips for writing efficient queries
When you write a query, you want to make sure it runs as efficiently as possible. Here are some tips to help you write efficient queries:
1. **Limit the columns in the `SELECT` clause**: Only request the columns you need, as it reduces the amount of data the query engine needs to process.
2. **Use the `LIMIT` clause**: If you are only interested in a specific number of rows, use the `LIMIT` clause to avoid processing more data than necessary.
3. **Filter early and use predicate pushdown**: Apply filters as early as possible in the query to reduce the amount of data being processed. This takes advantage of predicate pushdown, which pushes filter conditions down to the storage layer, reducing the amount of data read from storage. For example, if you only need data from a specific date range, filter on the date column as early as possible.
4. **Use `UNION ALL` instead of `UNION`**: If youâre combining the results of multiple queries, use `UNION ALL` instead of `UNION` to avoid the overhead of removing duplicate rows.
5. **Only order when necessary**: Ordering results can be computationally expensive. If you donât need ordered results, avoid using `ORDER BY`.
6. **Always use the actual data while filtering**: Do not use functions on the filter columns: For example, if you want to filter on a date, do not use date\_trunc('day', block\_timestamp) > '2022-01-01'. Instead, use block\_timestamp > '2022-01-01'. The first example will not be able to use the min/max values of the block\_time column to skip entire parquet files or row groups within files while scanning through a table, while the second example will. The same goes for other functions, such as substr, lower, upper etc.
7. **Use `UNION ALL` instead of `OR`**: If you need to combine the results of multiple queries, use `UNION ALL` instead of `OR` to avoid the overhead of removing duplicate rows. For example, instead of using `SELECT * FROM table WHERE column = 'value1' OR column = 'value2'`, use `SELECT * FROM table WHERE column = 'value1' UNION ALL SELECT * FROM table WHERE column = 'value2'`.
8. **User lower-case address directly in SQL**: If you are filtering on an address, use the lower-case address directly in the SQL query. For example, instead of using `SELECT * FROM transactions WHERE from_address = lower('0x1234567890ABCDEF')`, use `SELECT * FROM transactions WHERE from_address = '0x1234567890abcdef'`. This allows the query engine to use the min/max values of the from\_address column to skip entire ORC files or row groups within files while scanning through a table.
# Overview
Source: https://docs.chainbase.com/platform/features/sync/overview
## Introduction

Welcome to our Chainbase Sync service tutorial. This service is designed to offer:
1. **Complete and Accurate Historical Data**: Sync-Service ensures full consistency with the tables in DataCloud, providing complete and precise historical data.
2. **Rapid Historical Data Synchronization**: Our service enables quick synchronization of historical data without relying on RPC, streamlining the process significantly.
3. **Up-to-Date Incremental Blockchain Data**: After synchronizing historical data, Sync-Service continuously updates with real-time incremental blockchain data, tailored to your specific needs.
This guide will help you utilize these features to their fullest potential.
## Before You Begin
* Ensure you have a registered Chainbase account.
* Make sure you have a data source and a target data storage system that you wish to synchronize.
## Step 1: Selecting Your Data Source
* Access the Chainbase Sync-Service interface.
* Choose your data source (e.g., PostgreSQL, MySQL, S3, etc.).
* Enter the details and credentials for your data source.

## Step 2: Configuring Data Flow
* Select the type of data to synchronize (raw data, decoded data, or abstracted data).

* Identify the target system, such as a database or object storage system.

* Set the synchronization frequency and specific data sync options.

## Step 3: Syncing and Monitoring
* Start the data synchronization process.
* Monitor the progress and logs using tools provided by Chainbase.
* Verify the data in the target system to ensure successful synchronization.

## Step 4: Managing and Maintenance
* In the 'Jobs' section of the integration interface, users can observe the current status of each sync job.
* The interface provides controls to pause and restart sync jobs as needed.

## Conclusion
The Chainbase Sync service streamlines the data synchronization process, enabling users to efficiently set up and maintain their data workflows within just two interface pages. With continuous synchronization, users can receive ongoing data updates after the initial sync is complete. The system's flexibility, scalability, and ease of use are evident in the variety of data sources and tables users can choose from, tailored to their specific needs. Furthermore, the conformity of table data formats with DataCloud standards ensures seamless integration and consistency across platforms. This comprehensive service package empowers users to harness real-time data insights effectively.
## Frequently Asked Questions (FAQs)
1. **Is the data synchronized with Chainbase Sync-Service in real-time?**
Yes, Chainbase Sync service supports real-time data synchronization. As changes occur in your data source, they are immediately captured and updated in your target system, ensuring that the data you access is always current.
2. **How is the pricing for synchronization calculated?**
The pricing for synchronization with Chainbase Sync-Service is based on several factors, including the volume of data being synchronized, the frequency of sync jobs, and the number of data sources and destinations configured. For detailed pricing information, please refer to our pricing page or contact our [sales team](https://chainbase.com/contact).
3. **Can I choose to start synchronization from a specific block?**
Currently, the ability to begin synchronization from a specific block index is a feature exclusive to our enterprise users. If you require this level of synchronization control, please reach out to our [sales team](https://chainbase.com/contact) for assistance and information on our enterprise solutions.
# Overview
Source: https://docs.chainbase.com/platform/overview
Welcome to Chainbase Data Platform docs. All-in-one web3 data infrastructure for indexing, transforming, and utilizing large-scale on-chain data.
## What is Chainbase Data Platform?
Chainbase Data Platform is an all-in-one data infrastructure for Web3 that allows you to index, transform, and utilize large-scale on-chain data. It is a platform that provides a suite of tools and services to help you build, manage, and scale your Web3 applications.
By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase Data Platform automates the indexing and querying of blockchain data, enabling developers to accomplish complex data tasks with ease.
## Products & Features
### API - Indexed Data
Chainbase Data Platform provides a powerful API that allows you to access indexed data from the blockchain. The API is designed to be easy to use and provides a wide range of features to help you get the data you need.
### Datasets
Chainbase Data Platform supports a wide range of raw, decoded, and abstracted datasets for you to build next-level apps with cutting-edge protocols today and tomorrow.
### Data Cloud
Data Cloud lets you run your low-latency queries through an endpoint to leverage all our indexed datasets for your custom needs.
### Data Sync - Stream data to your backend
With Data Sync, you can stream the data you need into your own infrastructure in real-time, and then use it to build powerful applications.
# Pricing
Source: https://docs.chainbase.com/platform/pricing/pricing
# Support
Source: https://docs.chainbase.com/platform/support
# Supported Networks
Source: https://docs.chainbase.com/platform/supported-networks/supported-networks
We support the following networks in real-time across multiple data types. More chains and types are being onboarded and will coming soon.
| **Ecosystem** | **Blockchains Supported** | **Node RPC** | **Raw** | **Decoded** | **Abstracted** | **Web3 API** |
| ------------- | ------------------------- | ------------ | ------- | ----------- | -------------- | ------------ |
| **EVM** | Ethereum | â | â | â | â | â |
| | Binance Smart Chain (BSC) | â | â | â | â | â |
| | Polygon | â | â | â | â | â |
| | Avalanche (C-Chain) | â | â | â | â | â |
| | Fantom | â | â | â | | |
| | Arbitrum | â | â | â | â | â |
| | Optimism | â | â | â | â | â |
| | Base | â | â | â | â | â |
| | Blast | â | â | â | â | |
| | ZkSync | â | â | â | â | â |
| | Merlin | â | â | | | â |
| **Non EVM** | Bitcoin | | \* | | â | |
| | Sui | â | | | â | |
| | Ton | â | â | â | â | |
| | Tron | â | â | | | |
| | *Solana\** | | \* | \* | \* | \* |
# Get native token balances by address
Source: https://docs.chainbase.com/platform/usecases/balance-api/get-native-token-balances
Getting the token balances of an account is an essential task when dealing with cryptocurrencies, as it allows you to know the amount of tokens that an account holds. The Web3 APIs from Chainbase provide the ability to get all transactions and account balances in a straightforward way. By following the steps below, you can seamlessly get the native token balances of an account on a certain chain through a single API call using Chainbase API.
## Overview - Tools you need to work with Chainbase
1. A free account at [Chainbase](https://www.chainbase.com) with an API key.
2. An IDE. Our examples are shown in JavaScript, you can use [VS Code](https://code.visualstudio.com/) as your IDE for example.
3. A known wallet address as your input.
## Step 1: Set up a free account at Chainbase
To better leverage the ability that Chainbase provides, you can register [here](http://www.chainbase.com/register) for a free account and access to different APIs and data cloud.
After logging into Chainbase, visit the [dashboard](https://console.chainbase.com/) to get an overview. Create a new project in the console and get an API key.

## Step 2: Write script using Chainbase API
1. Using `fetch` in JavaScript.
```jsx
network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.
wallet_addr = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // Take Vitalik's wallet address as an example.
fetch(`https://api.chainbase.online/v1/account/balance?chain_id=${network_id}&address=${wallet_addr}`, {
method: 'GET',
headers: {
'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key.
'accept': 'application/json'
}
}).then(response => response.json())
.then(data => console.log(data.data))
.catch(error => console.error(error));
```
2. Using `axios` in JavaScript. You need to install `axios` using `npm install axios --save` in the terminal first.
```jsx
network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.
wallet_addr = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; // Take Vitalik's wallet address as an example.
const axios = require('axios');
const options = {
url: `https://api.chainbase.online/v1/account/balance?chain_id=${network_id}&address=${wallet_addr}`,
method: 'GET',
headers: {
'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key.
'accept': 'application/json'
}
};
axios(options)
.then(response => console.log(response.data.data))
.catch(error => console.log(error));
```
## Step 3: Print native token balances
Chainbase API [Get native token balances](/api-reference/web3-api/balance/token-balances/get-native-token-balances) takes the chain id and wallet address as parameters, and returns the value of native token balances.
To get data printed, run command `node