
How to Get the Holders of an ERC20 Token
IntroductionIn the world of cryptocurrency, knowing the holders of a particular token can provide valuable insights and opportunities for collaboration. Chainbase, a leading platform, offers a powerful API called getTokenHolders that allows you to retrieve a list of addresses for all the holders of a specific ERC20 token. This tutorial will guide you through the process of using Chainbase API to get the holders of a cryptocurrency deployed on various chains. By leveraging this information, yo...

How to Determine the Type of an EVM Contract
In common on-chain data parsing, there is often a large demand for determining the type of contract. This article will judge on relevant standards and engineering practices to determine whether the contract belongs to ERC20 / ERC721 / ERC1155. For more use cases, you can refer to the developer documentation of Chainbase, or ask the original author through Discord. We are happy to discuss issues related to Web3 infra, Data SDK, Chainbase APIs, etc.Rules to determine different contractsWith the...

How to Register a Chainbase Account?
To get started, go to the Chainbase official website.websiteClick on the dashboard to register a new account.loginEnter your email and password.Untitled.pngNext, create a new project in the console to obtain an API key. Now it's time to start your Web3 journey!
All-in-one web3 data infrastructure for indexing, transforming, and utilization of on-chain data at scale.

How to Get the Holders of an ERC20 Token
IntroductionIn the world of cryptocurrency, knowing the holders of a particular token can provide valuable insights and opportunities for collaboration. Chainbase, a leading platform, offers a powerful API called getTokenHolders that allows you to retrieve a list of addresses for all the holders of a specific ERC20 token. This tutorial will guide you through the process of using Chainbase API to get the holders of a cryptocurrency deployed on various chains. By leveraging this information, yo...

How to Determine the Type of an EVM Contract
In common on-chain data parsing, there is often a large demand for determining the type of contract. This article will judge on relevant standards and engineering practices to determine whether the contract belongs to ERC20 / ERC721 / ERC1155. For more use cases, you can refer to the developer documentation of Chainbase, or ask the original author through Discord. We are happy to discuss issues related to Web3 infra, Data SDK, Chainbase APIs, etc.Rules to determine different contractsWith the...

How to Register a Chainbase Account?
To get started, go to the Chainbase official website.websiteClick on the dashboard to register a new account.loginEnter your email and password.Untitled.pngNext, create a new project in the console to obtain an API key. Now it's time to start your Web3 journey!
All-in-one web3 data infrastructure for indexing, transforming, and utilization of on-chain data at scale.

Subscribe to Chainbase

Subscribe to Chainbase
Share Dialog
Share Dialog


<100 subscribers
<100 subscribers
The Author: masterdai
As a Developer Relations at Chainbase, I often find myself at the intersection of technology and community. One of the most common requests we receive from our community is the ability to merge Dex transaction data and price data together, similar to what other companies offer. Today, I'm excited to share how you can craft visualizations using LiveQuery and Chainbase API to meet this need.
To get started, you'll need to create a free account and generate an API key. This key will be used to authenticate your requests to the Chainbase API.
Go to the LiveQuery website and add your api-key to the add on.

Whether you're tracking token transfers, monitoring top token holders, or analyzing token price history, LiveQuery can help you bring your data to life. For instance, you can use LiveQuery to combine data from the Chainbase Token API to create a comprehensive visualization of token activity.
First, let's look at how you can use LiveQuery with the Chainbase Token API. Here's a simple example:
SELECT
value:amount::float AS amount,
value:original_amount::string AS original_amount,
value:usd_value::float AS usd_value,
value:wallet_address::string AS wallet_address
FROM
(
SELECT
chainbase_utils.get('/v1/token/top-holders',
PARSE_JSON('{"chain_id": 1, "contract_address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0"}')
)::variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data)
This SQL statement is making a request to the /v1/token/top-holders endpoint, retrieving the JSON response, flattening the nested JSON array, and finally extracting the desired fields from each item in the array. The information it's extracting relates to the top holders of a particular token, specified by the contract_address in the Ethereum blockchain (as indicated by the chain_id of 1). You can see the result below.

You can also obtain much more specific data from our dataset to visualize ETH UniswapV3 pool data. Here's a simple example:
SELECT
value:name::string AS name,
value:symbol::string AS symbol,
value:totalValueLockedUSD::int AS total_Value_Locked_USD,
value:createdBlockNumber::int AS createdBlockNumber,
value:id::string AS contract_address
FROM
(
SELECT
chainbase_utils.post(
'/v1/subgraphs/ethereum_uniswap_v3/1.0.0',
{
'operationName':'MyQuery',
'query':'
query MyQuery {
liquidityPools(first: 10, orderBy: totalValueLockedUSD, orderDirection: desc) {
id
createdBlockNumber
symbol
totalValueLockedUSD
name
}
}'
}
) :: variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data:liquidityPools)
This SQL query uses the chainbase_utils.post function to send a request to the 'ethereum_uniswap_v3' subgraph, asking for the top 10 liquidity pools based on their total locked value in USD. The data returned from the subgraph is in the JSON format, which is then flattened to extract the properties of the pools. These properties - name, symbol, total locked value in USD, the block number at the time the pool was created, and contract address - are then selected from the response and used to form the output table.

Although Flipside does not have on-chain data about SUI, it is available in Chainbase's Datacloud. Through the method below, we can visualize the on-chain data of SUI:
First, go to the Chainbase Datacloud and select the data you want to show in the live query. In this example, I use the sui.validators table to see the rank and SUI balance in their SUI staking pool.
WITH latest AS (
SELECT max(epoch) AS latest
FROM sui.validators
)
SELECT
name,
staking_pool_sui_balance / 1000000000 AS stake_balance,
image_url
FROM
sui.validators,
latest
WHERE
sui.validators.epoch = latest.latest
ORDER BY
stake_balance DESC

Copy your SQL inside the live query's chainbase_utils.post('/v1/dw/query'), so you can fetch the data in the console.
SELECT
value:name::string AS name,
value:stake_balance::int AS stake_balance
FROM
(
SELECT
chainbase_utils.post(
'/v1/dw/query',
{
'query':
'WITH latest AS (
SELECT max(epoch) AS latest
FROM sui.validators
)
SELECT
name,
staking_pool_sui_balance / 1000000000 AS stake_balance,
image_url
FROM
sui.validators,
latest
WHERE
sui.validators.epoch = latest.latest
ORDER BY
stake_balance DESC'
}
) :: variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data:result)
If you want to put the entire query on one line, here is the sample code:
SELECT
value:name::string AS name,
value:stake_balance::int AS stake_balance
FROM
(
SELECT
chainbase_utils.post(
'/v1/dw/query',
{
'query': 'WITH latest AS (SELECT max(epoch) AS latest FROM sui.validators) SELECT name, staking_pool_sui_balance / 1000000000 as stake_balance, image_url FROM sui.validators, latest WHERE sui.validators.epoch = latest.latest ORDER BY stake_balance DESC'
}
) :: variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data:result)
Please note that putting the entire query on one line may reduce readability, especially for more complex queries. In this particular case, since the query is relatively simple, merging it into one line shouldn't be a big issue.

This SQL command extracts and visualizes on-chain data related to SUI validators, focusing on their names and stake balances. First, it retrieves the most recent epoch from the sui.validators data. Then, it collects the names and staking balances (adjusted to be in correct units) of validators whose records correspond to this latest epoch. The results are ordered by stake balance in descending order. This operation utilizes the 'chainbase_utils.post' function to fetch the data from a specific web API endpoint. Finally, the resulting data structure is flattened for easier processing and analysis.

I've created numerous templates and visualizations using the Chainbase APIs and LiveQuery. These resources are designed to help you get started and inspire your own data analysis projects.
I'm thrilled to see the innovative ways our community is using LiveQuery and Chainbase APIs to visualize and analyze on-chain data. These tools not only simplify the process but also open up new possibilities for understanding and interpreting blockchain data. We're excited to see what you'll create next and are always here to support your journey in the blockchain space.
Happy data crafting!
Chainbase is an all-in-one data infrastructure for Web3 that allows you to index, transform, and use on-chain data at scale. By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase automates the indexing and querying of blockchain data, enabling developers to accomplish more with less effort.
Visit our website chainbase.com Sign up for a free account, and Check out our documentation.
Website|Blog|Twitter|Discord|Link3
The Original Link: Crafting Visualizations with LiveQuery and Chainbase API
The Author: masterdai
As a Developer Relations at Chainbase, I often find myself at the intersection of technology and community. One of the most common requests we receive from our community is the ability to merge Dex transaction data and price data together, similar to what other companies offer. Today, I'm excited to share how you can craft visualizations using LiveQuery and Chainbase API to meet this need.
To get started, you'll need to create a free account and generate an API key. This key will be used to authenticate your requests to the Chainbase API.
Go to the LiveQuery website and add your api-key to the add on.

Whether you're tracking token transfers, monitoring top token holders, or analyzing token price history, LiveQuery can help you bring your data to life. For instance, you can use LiveQuery to combine data from the Chainbase Token API to create a comprehensive visualization of token activity.
First, let's look at how you can use LiveQuery with the Chainbase Token API. Here's a simple example:
SELECT
value:amount::float AS amount,
value:original_amount::string AS original_amount,
value:usd_value::float AS usd_value,
value:wallet_address::string AS wallet_address
FROM
(
SELECT
chainbase_utils.get('/v1/token/top-holders',
PARSE_JSON('{"chain_id": 1, "contract_address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0"}')
)::variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data)
This SQL statement is making a request to the /v1/token/top-holders endpoint, retrieving the JSON response, flattening the nested JSON array, and finally extracting the desired fields from each item in the array. The information it's extracting relates to the top holders of a particular token, specified by the contract_address in the Ethereum blockchain (as indicated by the chain_id of 1). You can see the result below.

You can also obtain much more specific data from our dataset to visualize ETH UniswapV3 pool data. Here's a simple example:
SELECT
value:name::string AS name,
value:symbol::string AS symbol,
value:totalValueLockedUSD::int AS total_Value_Locked_USD,
value:createdBlockNumber::int AS createdBlockNumber,
value:id::string AS contract_address
FROM
(
SELECT
chainbase_utils.post(
'/v1/subgraphs/ethereum_uniswap_v3/1.0.0',
{
'operationName':'MyQuery',
'query':'
query MyQuery {
liquidityPools(first: 10, orderBy: totalValueLockedUSD, orderDirection: desc) {
id
createdBlockNumber
symbol
totalValueLockedUSD
name
}
}'
}
) :: variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data:liquidityPools)
This SQL query uses the chainbase_utils.post function to send a request to the 'ethereum_uniswap_v3' subgraph, asking for the top 10 liquidity pools based on their total locked value in USD. The data returned from the subgraph is in the JSON format, which is then flattened to extract the properties of the pools. These properties - name, symbol, total locked value in USD, the block number at the time the pool was created, and contract address - are then selected from the response and used to form the output table.

Although Flipside does not have on-chain data about SUI, it is available in Chainbase's Datacloud. Through the method below, we can visualize the on-chain data of SUI:
First, go to the Chainbase Datacloud and select the data you want to show in the live query. In this example, I use the sui.validators table to see the rank and SUI balance in their SUI staking pool.
WITH latest AS (
SELECT max(epoch) AS latest
FROM sui.validators
)
SELECT
name,
staking_pool_sui_balance / 1000000000 AS stake_balance,
image_url
FROM
sui.validators,
latest
WHERE
sui.validators.epoch = latest.latest
ORDER BY
stake_balance DESC

Copy your SQL inside the live query's chainbase_utils.post('/v1/dw/query'), so you can fetch the data in the console.
SELECT
value:name::string AS name,
value:stake_balance::int AS stake_balance
FROM
(
SELECT
chainbase_utils.post(
'/v1/dw/query',
{
'query':
'WITH latest AS (
SELECT max(epoch) AS latest
FROM sui.validators
)
SELECT
name,
staking_pool_sui_balance / 1000000000 AS stake_balance,
image_url
FROM
sui.validators,
latest
WHERE
sui.validators.epoch = latest.latest
ORDER BY
stake_balance DESC'
}
) :: variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data:result)
If you want to put the entire query on one line, here is the sample code:
SELECT
value:name::string AS name,
value:stake_balance::int AS stake_balance
FROM
(
SELECT
chainbase_utils.post(
'/v1/dw/query',
{
'query': 'WITH latest AS (SELECT max(epoch) AS latest FROM sui.validators) SELECT name, staking_pool_sui_balance / 1000000000 as stake_balance, image_url FROM sui.validators, latest WHERE sui.validators.epoch = latest.latest ORDER BY stake_balance DESC'
}
) :: variant AS resp
) AS subquery,
LATERAL FLATTEN(input => resp:data:data:result)
Please note that putting the entire query on one line may reduce readability, especially for more complex queries. In this particular case, since the query is relatively simple, merging it into one line shouldn't be a big issue.

This SQL command extracts and visualizes on-chain data related to SUI validators, focusing on their names and stake balances. First, it retrieves the most recent epoch from the sui.validators data. Then, it collects the names and staking balances (adjusted to be in correct units) of validators whose records correspond to this latest epoch. The results are ordered by stake balance in descending order. This operation utilizes the 'chainbase_utils.post' function to fetch the data from a specific web API endpoint. Finally, the resulting data structure is flattened for easier processing and analysis.

I've created numerous templates and visualizations using the Chainbase APIs and LiveQuery. These resources are designed to help you get started and inspire your own data analysis projects.
I'm thrilled to see the innovative ways our community is using LiveQuery and Chainbase APIs to visualize and analyze on-chain data. These tools not only simplify the process but also open up new possibilities for understanding and interpreting blockchain data. We're excited to see what you'll create next and are always here to support your journey in the blockchain space.
Happy data crafting!
Chainbase is an all-in-one data infrastructure for Web3 that allows you to index, transform, and use on-chain data at scale. By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase automates the indexing and querying of blockchain data, enabling developers to accomplish more with less effort.
Visit our website chainbase.com Sign up for a free account, and Check out our documentation.
Website|Blog|Twitter|Discord|Link3
The Original Link: Crafting Visualizations with LiveQuery and Chainbase API
No activity yet