0

I have a set of addresses (20K +) and a set of tokens (3K+) in my database.`

I want to store their token holdings current state based on an interval lets say every 30 minutes. I got an Infura Enterprise subscription but I dont know what is the most efficient way doing this using web3.

The only way I know which results in way too many requests would be:

for token in tokens web3 contract instance for token for address in addresses token.balanceof(address)

Is there any other way to do this? Like is there a possibility I didnt notice where I could send an array of addresses to a contract instance balanceof function instead of just a single one per request?

Regards

1

You can use the Zapper API. It takes an array of addresses and can return tokensets or other properties as well. 20k is a lot of addresses so I suggest pulling in these properties by using a set of loops and storing them in your own array.

Here is a link to the API swagger:

https://api.zapper.fi/api/static/index.html#/Protocol%20Balances/BalanceController_getProtocolBalancesV2

Hope this helps :)

2
  • Thank you for the suggestion. I checked the API but it seems this is just viable for defi not erc20 tokens on the ethreum blockchain or did I read that wrong?
    – Chris S
    Jun 30 at 11:16
  • It is for ERC20, BEP20 and a bunch more. So it is what you need. Just a side note as well: I think you are understanding the term DeFi wrong. DeFi is short for Decentralized Finance which encompasses all Financial Activities that takes place in or on a decentralized manner. It's not some protocol. Jun 30 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.