Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
How to speed up token balance on multiple contracts

I'm using ethers to call balanceOf method on all contracts to check if user has any balance there, if not, the token will not show up in his dashboard, but it takes a lot of time, is there a more finesse way to achieve the same goal?

my code:

        for (let key in tokens) {
        if (tokens.hasOwnProperty(key)) {
            let contract_address_to_check = tokens[key].address;
            if (contract_address_to_check != "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") {
                const Contract = new ethers.Contract(contract_address_to_check, Abi, provider);
                let balance_wei = await Contract.balanceOf(address);
                
                if (balance_wei > 0) {
                    let decimals = await Contract.decimals();
                    let balance = balance_wei / 10 ** decimals;
                    console.log(tokens[key].address);
                    console.log(tokens[key].decimals);
                    console.log(tokens[key].symbol);
                    console.log(balance);
                }
            }
        }
    
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use Multicall contract for small wins. A proper solution is indexers like TheGraph that continuously read the blockchain and keep the data available indexed.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!