
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

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!
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers


The Author: mumu
In this tutorial, we'll be using the Chainbase DeFi dataset to retrieve the addresses of Uniswap V2 pools. Chainbase provides a wealth of blockchain data, enabling developers to access, analyze, and utilize on-chain data easily and efficiently.
A free account at Chainbase with an API key.
An IDE. Our examples are shown in JavaScript, you can use VS Code as your IDE for example.
A contract address of an ERC20 token as your input.
To begin with, you'll need to register on Chainbase and obtain an API key. This key will be used to authenticate your requests to the Chainbase API.
In this section, we will learn how to retrieve pool data from the Chainbase dataset. Let's use the following query:
query SpecificTokenInfo {
liquidityPool(id: "0xd6e3f90f531f8dc9229ddbd2e59b4a6c7a5f5de0") {
inputTokens {
symbol
id
decimals
}
outputToken {
symbol
id
decimals
}
}
}
This query allows us to obtain information about a specific liquidity pool by providing its ID. The response will include details about the input and output tokens, such as their symbols, IDs, and decimals.
Now, let's explore how to get pool information using pagination. The following query demonstrates this:
query GetPoolInfo($inputTokens: String, $skip: Int!) {
liquidityPools(
first: 100
skip: $skip
orderBy: createdTimestamp
where: {inputTokens_: {name: $inputTokens}}
) {
createdTimestamp
deposits {
hash
_walletAddress
}
}
}
#eg.
{
"inputTokens": "USDT",
"skip": 2
}
This query enables us to retrieve pool information in batches of 100 pools at a time, skipping the desired number of pools using the $skip variable. The pools are ordered by their creation timestamp, and we can filter the results based on the input tokens' name.
To query the withdraw and deposit information from a specific address, we can use the following query:
# Query the withdraw and deposit information from a specific address
query GetWallet($wallet: String) {
withdraws(where: {from: $wallet}) {
blockNumber
from
hash
id
logIndex
timestamp
to
}
deposits(where: {from: $wallet}) {
blockNumber
from
hash
id
logIndex
timestamp
to
}
}
# eg.
{
"wallet": "0xb862cd7c725139bbed253bbc7f06e359a89bdea7"
}
By providing the wallet address through the $wallet variable, we can obtain details about both withdrawals and deposits associated with that address.
Lastly, let's explore how to query pool transactions. The following query accomplishes this:
query GetPoolTx {
liquidityPools(
first: 5,
orderBy: createdTimestamp,
orderDirection: desc) {
createdTimestamp
deposits {
id
_walletAddress
from
to
inputTokenAmounts
inputTokens {
symbol
}
outputTokenAmount
outputToken {
symbol
}
}
swaps {
id
_walletAddress
from
to
}
withdraws {
id
_walletAddress
from
to
}
}
}
This query fetches data for the five most recent liquidity pools. It includes details about deposits, swaps, and withdrawals associated with these pools.
The GraphQL query UniV2Pool allows us to retrieve specific information about the top Uniswap V2 liquidity pools. Let's dive into the details of the query:
query UniV2Pool {
liquidityPools(first: 5, orderBy: createdTimestamp, orderDirection: desc) {
id
name
createdBlockNumber
inputTokens {
symbol
}
swaps(orderBy: timestamp, orderDirection: desc) {
hash
amountIn
amountOut
}
}
}
In this query, we are using the liquidityPools field to fetch data for the first five pools. The pools are sorted based on their creation timestamp in descending order, meaning we get the most recently created pools first.
Results
"liquidityPools": [
{
"id": "0xd6e3f90f531f8dc9229ddbd2e59b4a6c7a5f5de0",
"name": "Uniswap V2 Worldcoin/Wrapped Ether",
"createdBlockNumber": "17761399",
"inputTokens": [
{
"symbol": "WLD"
},
{
"symbol": "WETH"
}
],
"swaps": []
},
{
"id": "0x26bdfc68454a5028de4109007c8e2f6cbf0af33f",
"name": "Uniswap V2 TAGToken/Wrapped Ether",
"createdBlockNumber": "17761364",
"inputTokens": [
{
"symbol": "TAG"
},
{
"symbol": "WETH"
}
],
"swaps": []
},
{
"id": "0x50a516b47e4a3da12bced268645baa1da34b25b5",
"name": "Uniswap V2 X.com/Wrapped Ether",
"createdBlockNumber": "17761362",
"inputTokens": [
{
"symbol": "X.com"
},
{
"symbol": "WETH"
}
],
In conclusion, using our DeFi dataset to retrieve Uniswap V2 pool addresses is a powerful tool for blockchain developers. By following the provided queries and steps, you can efficiently access and analyze on-chain data. Chainbase opens up new possibilities for building DeFi applications and understanding blockchain ecosystems.
What is Chainbase? Chainbase is a platform that provides a comprehensive set of blockchain data, allowing developers to access and utilize on-chain information for their projects.
Why do I need an API key for Chainbase? The API key serves as a security measure to authenticate your requests and ensure that only authorized users can access Chainbase's data.
Can I use other programming languages instead of JavaScript for the examples? Yes, you can use other programming languages that are compatible with the Chainbase API, but the examples in this tutorial are demonstrated in JavaScript.
How does pagination help in retrieving pool information? Pagination breaks down the data retrieval into smaller, manageable chunks. It allows you to retrieve a limited number of pools at a time, making the process more efficient.
What data can I obtain from querying pool transactions? By querying pool transactions, you can get valuable information about deposits, swaps, and withdrawals associated with specific liquidity pools.
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: How to Get Uniswap V2 Pool Data
The Author: mumu
In this tutorial, we'll be using the Chainbase DeFi dataset to retrieve the addresses of Uniswap V2 pools. Chainbase provides a wealth of blockchain data, enabling developers to access, analyze, and utilize on-chain data easily and efficiently.
A free account at Chainbase with an API key.
An IDE. Our examples are shown in JavaScript, you can use VS Code as your IDE for example.
A contract address of an ERC20 token as your input.
To begin with, you'll need to register on Chainbase and obtain an API key. This key will be used to authenticate your requests to the Chainbase API.
In this section, we will learn how to retrieve pool data from the Chainbase dataset. Let's use the following query:
query SpecificTokenInfo {
liquidityPool(id: "0xd6e3f90f531f8dc9229ddbd2e59b4a6c7a5f5de0") {
inputTokens {
symbol
id
decimals
}
outputToken {
symbol
id
decimals
}
}
}
This query allows us to obtain information about a specific liquidity pool by providing its ID. The response will include details about the input and output tokens, such as their symbols, IDs, and decimals.
Now, let's explore how to get pool information using pagination. The following query demonstrates this:
query GetPoolInfo($inputTokens: String, $skip: Int!) {
liquidityPools(
first: 100
skip: $skip
orderBy: createdTimestamp
where: {inputTokens_: {name: $inputTokens}}
) {
createdTimestamp
deposits {
hash
_walletAddress
}
}
}
#eg.
{
"inputTokens": "USDT",
"skip": 2
}
This query enables us to retrieve pool information in batches of 100 pools at a time, skipping the desired number of pools using the $skip variable. The pools are ordered by their creation timestamp, and we can filter the results based on the input tokens' name.
To query the withdraw and deposit information from a specific address, we can use the following query:
# Query the withdraw and deposit information from a specific address
query GetWallet($wallet: String) {
withdraws(where: {from: $wallet}) {
blockNumber
from
hash
id
logIndex
timestamp
to
}
deposits(where: {from: $wallet}) {
blockNumber
from
hash
id
logIndex
timestamp
to
}
}
# eg.
{
"wallet": "0xb862cd7c725139bbed253bbc7f06e359a89bdea7"
}
By providing the wallet address through the $wallet variable, we can obtain details about both withdrawals and deposits associated with that address.
Lastly, let's explore how to query pool transactions. The following query accomplishes this:
query GetPoolTx {
liquidityPools(
first: 5,
orderBy: createdTimestamp,
orderDirection: desc) {
createdTimestamp
deposits {
id
_walletAddress
from
to
inputTokenAmounts
inputTokens {
symbol
}
outputTokenAmount
outputToken {
symbol
}
}
swaps {
id
_walletAddress
from
to
}
withdraws {
id
_walletAddress
from
to
}
}
}
This query fetches data for the five most recent liquidity pools. It includes details about deposits, swaps, and withdrawals associated with these pools.
The GraphQL query UniV2Pool allows us to retrieve specific information about the top Uniswap V2 liquidity pools. Let's dive into the details of the query:
query UniV2Pool {
liquidityPools(first: 5, orderBy: createdTimestamp, orderDirection: desc) {
id
name
createdBlockNumber
inputTokens {
symbol
}
swaps(orderBy: timestamp, orderDirection: desc) {
hash
amountIn
amountOut
}
}
}
In this query, we are using the liquidityPools field to fetch data for the first five pools. The pools are sorted based on their creation timestamp in descending order, meaning we get the most recently created pools first.
Results
"liquidityPools": [
{
"id": "0xd6e3f90f531f8dc9229ddbd2e59b4a6c7a5f5de0",
"name": "Uniswap V2 Worldcoin/Wrapped Ether",
"createdBlockNumber": "17761399",
"inputTokens": [
{
"symbol": "WLD"
},
{
"symbol": "WETH"
}
],
"swaps": []
},
{
"id": "0x26bdfc68454a5028de4109007c8e2f6cbf0af33f",
"name": "Uniswap V2 TAGToken/Wrapped Ether",
"createdBlockNumber": "17761364",
"inputTokens": [
{
"symbol": "TAG"
},
{
"symbol": "WETH"
}
],
"swaps": []
},
{
"id": "0x50a516b47e4a3da12bced268645baa1da34b25b5",
"name": "Uniswap V2 X.com/Wrapped Ether",
"createdBlockNumber": "17761362",
"inputTokens": [
{
"symbol": "X.com"
},
{
"symbol": "WETH"
}
],
In conclusion, using our DeFi dataset to retrieve Uniswap V2 pool addresses is a powerful tool for blockchain developers. By following the provided queries and steps, you can efficiently access and analyze on-chain data. Chainbase opens up new possibilities for building DeFi applications and understanding blockchain ecosystems.
What is Chainbase? Chainbase is a platform that provides a comprehensive set of blockchain data, allowing developers to access and utilize on-chain information for their projects.
Why do I need an API key for Chainbase? The API key serves as a security measure to authenticate your requests and ensure that only authorized users can access Chainbase's data.
Can I use other programming languages instead of JavaScript for the examples? Yes, you can use other programming languages that are compatible with the Chainbase API, but the examples in this tutorial are demonstrated in JavaScript.
How does pagination help in retrieving pool information? Pagination breaks down the data retrieval into smaller, manageable chunks. It allows you to retrieve a limited number of pools at a time, making the process more efficient.
What data can I obtain from querying pool transactions? By querying pool transactions, you can get valuable information about deposits, swaps, and withdrawals associated with specific liquidity pools.
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: How to Get Uniswap V2 Pool Data
No activity yet