Avalanche Chain - Tokens distributed

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.getTokenMetadata
Returns 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);
  1. getTokenPrice
    Returns 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);

I can pull the metadata alright. Your query will result in gathering an output like:

[
  {
    "address": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
    "name": "Kylin Network",
    "symbol": "KYL",
    "decimals": "18",
    "logo": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
    "logo_hash": "ee7aa2cdf100649a3521a082116258e862e6971261a39b5cd4e4354fcccbc54d",
    "thumbnail": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
    "block_number": "string",
    "validated": "string"
  }
]

Iā€™m looking for a way to pull market cap, 24hour volume from an exchange supporting Avalanche.

you can try to call functions directly on a smart contract, you can use directly runContractFunction: https://docs.moralis.io/moralis-server/web3-sdk/native#runcontractfunction