question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error getting token balances when using web3.alchemy.getTokenBalances

See original GitHub issue

Hi there, I have the following code:

const web3 = createAlchemyWeb3(
  `https://eth-mainnet.alchemyapi.io/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`
)
const getTokenBalanceWithAlchemy = async (address, tokens) => {
  try {
    let tokenBalances = await web3.alchemy.getTokenBalances(address, tokens)
    return tokenBalances
  } catch (error) {
    console.error(error)
  }
}
getTokenBalanceWithAlchemy("0x87BA155A86Cf63be05445bABB184e327551810F8", ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"])

For some reason, the request gives me an error…

index.js?d1cc:41 TypeError: this.decodeParameters is not a function
    at ABICoder.decodeParameter (index.js?8fce:273)
    at eval (index.js?1558:113)
    at Array.map (<anonymous>)
    at processTokenBalanceResponse (index.js?1558:111)
    at eval (index.js?1558:102)
    at step (tslib.es6.js?61e8:102)
    at Object.eval [as next] (tslib.es6.js?61e8:83)
    at fulfilled (tslib.es6.js?61e8:73)

Can someone help me figure out why this is happening? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
defidocommented, Dec 31, 2021

That is correct. 1.1.3 works, latest throws an error.

0reactions
thebrianchencommented, Jun 20, 2022

Reopening since multiple people have reported this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

alchemy_getTokenBalances - Alchemy Docs
Returns ERC20 token balances for all tokens the given address has ever transacted in with. Optionally accepts a list of contracts.
Read more >
Alchemy API trying to call `getTokenBalances` at a particular ...
The function will then return all of my current token balances but not my token balances as of the specified block height, followed...
Read more >
alchemy-web3/README.md at master - GitHub
Returns token balances for a specific address given a list of contracts. Parameters: An object with the following fields: contract : The address...
Read more >
Get Token Balance of Address at Particular Block Number with ...
We've released a new and updated version on how to get token balances that specifically includes the block number parameter as well.
Read more >
How Do I Get All the Tokens? - Medium
Problem. I make login with metamask on my website. But I want to get all tokens ... https://docs.moralis.io/moralis-dapp/web3-api/account#gettokenbalances ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found