Get holders of an ERC20 token
Chainbase offers an ability to get all the holders of a certain token. With one single API call, you can get a list of all the holders’ addresses of the token. In this tutorial, we will showcase how to use Chainbase API Get token holders to get the holders of a cryptocurrency deployed on chains. With this information, you can develop strategies to collaborate with these holders and improve the overall value of your cryptocurrency.
Overview - Tools you need to work with Chainbase
- 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 token 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 for a free account and access to different APIs and data cloud.
After logging into Chainbase, visit the dashboard to get an overview. Create a new project in the console and get an API key.
Step 2: Write script using Chainbase API
- Using
fetch
in JavaScript.
- Using
axios
in JavaScript. You need to installaxios
usingnpm install axios --save
in the terminal first.
Step 3: Print token holders
Chainbase API getTokenHolders takes the chain id and the contract address of a certain ERC20 token as parameters, and returns the holders of that token. You can also set the parameters page
and limit
to do the pagination and set the limitation.
To get data printed, run command node <filename>.js
in the terminal. In this case, the return data looks as follows. Note that since this API only returns unsorted token holders, query result may vary every time. If you want to get the top token holders, you can try another API called getTopTokenHolders.
API Reference
If you want to know more details on the endpoint and optional parameters, check out:
Support
If you meet any trouble following the tutorial, feel free to reach out to us in our Discord to get 24/7 community support.