While using covalent plugin handling some error

i install the plugin into my server but it is not showing on my browsers console

const init = async ()=> {
    Moralis.start({ serverUrl, appId });
  moralis.initplugins ()
   const result =await Moralis. Plugins.covalent.getChangesInTokenHolerBetweenBlockHeights(GetChangesinTokenHoldersDto);
( {
  chainId: 1,
  address:'0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
  startingBlock: 	10972953	,
  endingBlock: 12189743,
  pageNumber: 1,
  pageSize: 2,
  quoteCurrency: string,
});
console.log(result.data)
  };
     init();

you can try here to write: await Moralis.start({ serverUrl, appId }); without the second line

i try this but got error “moralis is not define at init”

const init = async ()=> {
   await Moralis.start({ serverUrl, appId });
  moralis.initplugins ()
   
console.log (moralis.plugins)
  };
     init();

you have more code than that, right, like the code to import Moralis, and the code that sets serverUrl and appId

yeah that is in js file which is i m running and going through console i m doing plugins

and my other code is working like price , read data from smartcontract but when i m going to browsers console and seeing what plugins is install then showing error

it is working fine when i m not using plugins as i comment out the code then its showi ng moralis is not define at init

 const serverUrl = "https://4l81fhpvqkit.usemoralis.com:2053/server";
    const appId = "pfaPMZpSl0COD4qDiZ6ytcu2ePIMaPWI2pSrhTZm";
 
   const oi = async ()=> {
   await  Moralis.start({ serverUrl, appId });
//   moralis.initplugins ();
//  console.log(moralis.plugins);
//    const result =await Moralis. Plugins.covalent.getChangesInTokenHolerBetweenBlockHeights({  
//   chainId: 1,
//   address:'0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
//   startingBlock: 	10972953	,
//   endingBlock: 12189743,
//   pageNumber: 1,
//   pageSize: 2,
//   quoteCurrency: string,
// });
// console.log(result.data)
 };
 oi();

Hey @Sudhanshusribastava2

Moralis and Plugins start with capital letters

Moralis.initPlugins()
console.log(Moralis.Plugins)

yeah thnks it works … but when i m treying using plugin to get token holders at a block then it shows error "Uncaught Error: Something went wrong
{
“code”: 500010,
“message”: "Cannot get token holders of block block_height for given "
this is my transaction which block i used https://bscscan.com/tx/0x61bd376db03ef90e2174912386aa4af9e5c8481a42c7f9435d24f4c4a68d9e93

  Moralis.initPlugins ();
const covalent = Moralis. Plugins.covalent;
   const result =await covalent.getBlockTokenHolders({  
    chainId: 1;
  contractAddress:'0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
  blockHeight:12189743 ,
  pageNumber: 1,
  pageSize: 100,
  quoteCurrency: 'usd',
});
console.log(result.data)

Chain id 1 is not BSC though. Try with the correct id

i also try with correct chain id 56 and ox38 but same error …

  Moralis.initPlugins ();
const covalent = Moralis. Plugins.covalent;
   const result =await covalent.getBlockTokenHolders({  
    chainId: 0x38,
  contractAddress:'0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
  blockHeight: 12189743,
  pageNumber: 1,
  pageSize: 100,
  quoteCurrency: 'usd',
});
console.log(result.data)

I get results if I try myself.
Why are you using pageNumber 1? The first page is 0.
Please check the docs and try again: https://github.com/MoralisWeb3/plugindocs/tree/main/covalent%20plugin

My query:

  const result = await covalent.getBlockTokenHolders({
    chainId: 56,
    contractAddress: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
    blockHeight: 12189743
  });
  console.log(result.data);

Result:

{
  updated_at: '2021-12-08T08:09:22.802146243Z',
  items: [
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x41a6bc535f304c613de4c74f16811ef213cd1e6a',
      balance: '5034791543049516080052',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x88a393f2aff8d8e0dd7bb4add82cd8ebac439b9e',
      balance: '1200080160400000000000',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x64f213a52e9e14b16a0982390f6d8cd7f3526073',
      balance: '1027012189363946602242',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x7b09c4427f921228e500f8007b6e9a7f73293159',
      balance: '588000000000000000000',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x833de4922bb693dc4640ec0bd81caacc51fbb1d3',
      balance: '500000000000000000000',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x5974c357769d77a04cd87aee3e49e5bf719d1cfe',
      balance: '479640840000000000000',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      balance: '364524269909264126564',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0xf809a4156b5abd7b74a94d8a99c93ccbdadb7d07',
      balance: '287309317277273191142',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x84a85695f83ea04e5ab0d43ee4b592b1f2de2b48',
      balance: '208760840000000000000',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x8ef18d821cd446c587ec2c3f1cbc4266915e0e06',
      balance: '200000000000000000000',
      total_supply: null,
      block_height: 12189743
    },
    {
      contract_decimals: 18,
      contract_name: 'Crypto Planet Token',
      contract_ticker_symbol: 'CPT',
      contract_address: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
      supports_erc: null,
      logo_url: 'https://logos.covalenthq.com/tokens/56/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078.png',
      address: '0x33baf490a9d9bc84ded6b54d28ed1d6ca5aae374',
      balance: '109880840000000000000',
      total_supply: null,
      block_height: 12189743
    }
  ],
  pagination: { has_more: false, page_number: 0, page_size: 100, total_count: 11 }
}

Oops sorry sir , thanks for result

pagination: { has_more: false, page_number: 0, page_size: 100, total_count: 11 }

Total_count : 11 is number of holders ?

i dont know why its not working i try many times even i copy paste ur code to browsers console also its giving error , can u try this code

const oi = async ()=> {
  Moralis.initPlugins ();
 const covalent =  Moralis. Plugins.covalent;
 const result = await covalent.getBlockTokenHolders({
    chainId: 56,
    contractAddress: '0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078',
    blockHeight: 12189743,                  pageNumber: 0
  });
  console.log(result.data);
   
 };
 oi();

The code you posted above works fine. What’s the error you get?

moralis.js:5604 Uncaught (in promise) Error: Something went wrong
{
  "code": 500010,
  "message": "Cannot get token holders of block `block_height` for given `address`",
  "details": {
    "axiosConfig": {
      "url": "56/tokens/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078/token_holders/",
      "method": "GET",
      "params": {
        "page-number": 0,
        "page-size": 100,
        "quote-currency": "USD",
        "block-height": "12189743"
      }
    },
    "class": {
      "pageNumber": 0,
      "pageSize": 100,
      "quoteCurrency": "USD",
      "chainId": 56,
      "contractAddress": "0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078",
      "blockHeight": "12189743",
      "axiosConfig": {
        "url": "56/tokens/0x28e4f32fa7e842ad0a6e530bb6b4ec03b36d5078/token_holders/",
        "method": "GET",
        "params": {
          "page-number": 0,
          "page-size": 100,
          "quote-currency": "USD",
          "block-height": "12189743"
        }
      }
    },
    "error": "Request failed with status code 401"
  }
}
    at moralis.js:5604
    at tryCatch (moralis.js:28297)
    at Generator.invoke [as _invoke] (moralis.js:28527)
    at Generator.next (moralis.js:28352)
    at asyncGeneratorStep (moralis.js:27806)
    at _next (moralis.js:27828)
```[quote="dani, post:15, topic:5454, full:true"]
The code you posted above works fine. What's the error you get?
[/quote]

  this is error  i m getting when i m doing the code to my console browser ,
1 Like

Check the plugins version, should be 0.0.9. Update the plugin if is not updated.