0

I call contract like this :

  static async getInitialProps(res) {


    const users = await UsersContract.methods.getUsers().call();
    const totalusers = await UsersContract.methods.getTotalUsers().call();
    var i;
    const emails = [];
    const usersETHaddr = [];



    for (i = 0; i < totalusers; i++) {

     emails.push(await UsersContract.methods.getUserEmail(i).call());
     usersETHaddr.push(await UsersContract.methods.getUserETH(i).call());

    }


    return { emails,usersETH};

  }

When i have 10-15 users inside the array it loads ok But when i have 20-30 users it takes around 3 minutes to load

I use infura not geth

So why does it load slower when i add more users to the array ?

  • 2
    You have a for loop on the number of users, and you're asking why it takes longer when you add more users? What exactly are you expecting, that it would run faster??? – goodvibration Jan 2 at 9:01
  • i need the for loop – alin Jan 2 at 9:58
  • What has that got to do with what I wrote? – goodvibration Jan 2 at 9:59
  • it's a for loop outside the contract , not inside the contract ,making calls per total users , do to fact no solution to call all users with one call ... – alin Jan 2 at 10:13
  • inside for loop call 1 gets user 1 ,call 2 gets user 2 ,you can not do call 1 call user 1 + user 2 + user n – alin Jan 2 at 10:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.