Avalanche Chain – Tokens distributed – Moralis Forum

Moralis.Cloud.define(‘getTotalDistributed’, async (request) => {

const web3 = Moralis.web3ByChain(‘0xa86a’);

const contract = new web3.eth.Contract(abi, ‘0xZZZZZZZZZZZZ);

const totalDistributed = await contract.methods.getTotalDividendsDistributed().call().catch(() => ‘error with code’);

const options = {

address: ‘0xZZZZZZZZZZZZZZ’,
chain: ‘avalanche’,
exchange: ‘exchange?’

};

const price = await Moralis.Web3API.token.getTokenPrice(options);
return { totalDistributed, price };

});

Hi there,
I’m willing to get some exchange information of our token on the Avalanche network: Total Distributed, Volume, Mcap, etc.
I’m looking for a way to integrate it into cloud functions in Moralis.Understood that Avalanche network was added, how about the chain/exchange?
Thanks in advance.

Hey there are a couple of built in calls that may help you
1.getTokenMetadataReturns metadata (name, symbol, decimals, logo) for a given token contract address (asynchronous).
//Get metadata for one token
const options = { chain: “bsc”, addresses: “0xe…556” };
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);

//Get metadata for an array of tokens
const options = { chain: “bsc”, addresses: [“0xe…556”, “0xe…742”] };
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);

getTokenPriceReturns the price nominated in the native token and usd for a given token contract address (asynchronous).

//Get token price on PancakeSwap v2 BSC
const options = {
address: “0x7…2”,
chain: “bsc”,
exchange: “PancakeSwapv2”
};
const price = await Moralis.Web3API.token.getTokenPrice(options);

Source

Follow: Grapeswap – The Complete DeFi Multichain Ecosystem
https://grapestaking.lidia.in