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 coin metadata by coin type hashes

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 Coin Metadata By Coin Type Hashes

In order to get coin metadata by coin type hashes, Moralis provides you a getCoinsByCoinTypeHash endpoint to do so.

Here you'll need one parameter: coinTypeHashes.

Once you have obtained the coinTypeHashes, 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 coinTypeHashes = [
"175cc6491b0d75a131a36391318cde4c4b1312de70675c7e46cc54dacfe7ae29",
];

const response = await Moralis.AptosApi.coins.getCoinInfoByCoinTypeHashes({
coinTypeHashes,
network: "mainnet",
});

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:

{
[
{
"coin_type": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT",
"coin_type_hash": "175cc6491b0d75a131a36391318cde4c4b1312de70675c7e46cc54dacfe7ae29",
"name": "Tether USD",
"creator_address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa",
"decimals": 6,
"supply_aggregator_table_handle": null,
"supply_aggregator_table_key": null,
"symbol": "USDT",
"transaction_created_timestamp": "2022-10-19T02:43:38.000Z",
"transaction_version_created": "2413215"
}
]
}

Congratulations 🥳 You just got coin metadata by coin type hashes 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.