Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.2

How to get top coin holders

Step 1: Setup Moralis

Read the article Setting Up Moralis: Getting Started and make sure to finish all the steps. Only after that you can go ahead to complete this guide.

Step 2: Get Top Coin Holders

In order to get top coin holders, Moralis provides you a getTopHoldersByCoin endpoint to do so.

Here you'll need three parameters: limit, coinTypeHash, and network.

Once you have obtained the limit, coinTypeHash, and network, you can copy the following code:

const Moralis = require("moralis").default;

const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});

const limit = 10;

const coinTypeHash =
"91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6";

const network = "mainnet";

const response = await Moralis.AptosApi.coins.getTopHoldersByCoin({
limit,
coinTypeHash,
network,
});

console.log(response.result);
};

runApp();

Step 3: Run the script

To run the script, enter the following command:

node index.js

In your terminal, you should see the following JSON response:

{
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2IjoiODYxODkwODQxOTY2Njg0IiwibyI6MSwiaWF0IjoxNjgxMzA5MjQ0fQ.UMcD4qEsRGd6ZQMGqQ4gdj_t-RjGzTgVjn196G--jMg",
"hasNextPage": true,
"result": [
{
"amount": "4304356444212969",
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"owner_address": "0xc739507214d0e1bf9795485299d709e00024e92f7c0d055a4c2c39717882bdfd",
"coin_type": "0x1::aptos_coin::AptosCoin",
"last_transaction_timestamp": "2023-04-09T02:27:11.000Z",
"last_transaction_version": "117257615"
},
{
"amount": "1999997899860150",
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"owner_address": "0xcd30fbbda98b2aed026772c13e5ed90a7f056b589ef9e78cd96415e1af12451c",
"coin_type": "0x1::aptos_coin::AptosCoin",
"last_transaction_timestamp": "2023-03-26T21:02:33.000Z",
"last_transaction_version": "108462050"
},
{
"amount": "1698818070543346",
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"owner_address": "0xae1a6f3d3daccaf77b55044cea133379934bba04a11b9d0bbd643eae5e6e9c70",
"coin_type": "0x1::aptos_coin::AptosCoin",
"last_transaction_timestamp": "2023-04-12T14:20:01.000Z",
"last_transaction_version": "119794359"
},
{
"amount": "1035261098578310",
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"owner_address": "0xaaa9c5fb3b4855e1569321041febcc1146b44af3f08893d4ce41846cc7e25645",
"coin_type": "0x1::aptos_coin::AptosCoin",
"last_transaction_timestamp": "2023-03-17T16:08:56.000Z",
"last_transaction_version": "103430718"
},
{
"amount": "861890841966684",
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"owner_address": "0xcc03e04e08c028a4848ce270b8d8077ad9ec14f8586727b9ed7792039f1b207e",
"coin_type": "0x1::aptos_coin::AptosCoin",
"last_transaction_timestamp": "2023-04-12T07:33:48.000Z",
"last_transaction_version": "119555828"
}
]
}

Congratulations 🥳 You just got top coin holders with just a few lines of code using the Moralis Coin API!

Youtube Video

API Reference

If you want to know more details on the endpoint and optional parameters, check out:

Support

If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.