0

I am currently doing a script to retrieve data, I have a personal RPC that accepts 600 calls/second, but my script is making more than 600 calls/second using the getParsedTransactions() method via the web3.js library, so my question is: Is there a way to limit the number of calls/second?

1
  • 1
    are you using getParsedTransactions() to process 600 signatures, or are you running it 600 times once-per-signature? You should just give it less signatures to process at a time, it's not web3.js's responsibility to go slower for you. If you are processing batches of signatures just make them smaller. Almost always web3 will let you limit a large result set
    – 1owk3y
    Commented Sep 12, 2023 at 16:08

1 Answer 1

1

Yes there is a way to do this by using the batchSize parameter in the provider.send function to reduce the number of requests made in a single batch, this will assist the number of request by second made.

const setProvider = new SolanaWeb3Provider('https://testnet.solana.com',{batchSize = 1});

const makeRequests = [
   //Your Request
];

setProvider.send(makeRequests, (err, res) => {
  if(err){
    console.error(err);
    return;
  }

  // Deal with any response

});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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