Git Product home page Git Product logo

Comments (14)

emorling avatar emorling commented on August 13, 2024

I was under the impression the code should not fail with tryAggregate: true?

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Are you trying to call a state changing method here?

from ethereum-multicall.

emorling avatar emorling commented on August 13, 2024

Are you trying to call a state changing method here?

Thanks for fast response! I am calling standard "tokenByIndex" which exists in ERC20 contracts as read method:

https://etherscan.io/address/0x160c404b2b49cbc3240055ceaee026df1e8497a0#readContract

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Ok first web3 user here normally ethers users haha

let me try to run this code tomorrow and come back to you.. you are just using a infura or alchemy normal node right? I’m guessing the interface it tried to execute using web3 is a bit off as that error tends to be trying to call a method which is state changing logic (hence out of gas shizzle) but web3 generic error messaging may be this! Will look at fix it tomorrow time thanks for raising

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Can you confirm which web3 version you are using as well please?

from ethereum-multicall.

emorling avatar emorling commented on August 13, 2024

Can you confirm which web3 version you are using as well please?

Thanks! its this

"web3": "^1.7.1"

from ethereum-multicall.

emorling avatar emorling commented on August 13, 2024

you are just using a infura or alchemy normal node right?

Yes correct!

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Can you try to delete web3Instance for me and pass in nodeUrl instead? (Not on computer but if that works it be down to the web3 version I reckon and could make you carry on without this blocking you).

const multicall = new Multicall({ nodeUrl: INSERT_HERE, tryAggregate: true});

Let me know the outcome

from ethereum-multicall.

emorling avatar emorling commented on August 13, 2024

Sure outcome didn't all fit in terminal, but:

0000……………..\"},\"latest\"],\"id\":45,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"-----EDITED TO REMOVE URL TO ETHEREUM NODE -----"}, code=CALL_EXCEPTION, version=providers/5.6.6) at Logger.makeError (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/logger/lib/index.js:233:21) at Logger.throwError (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/logger/lib/index.js:242:20) at checkError (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:108:16) at JsonRpcProvider.<anonymous> (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:703:47) at step (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23) at Object.throw (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53) at rejected (/Users/eliamorling/Documents/workspace/eth-crawler/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ...to show where the warning was created) (node:79911) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:79911) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Wow hahaha!

And your using the ABI supplied in the etherscan link you sent right?

Also looking at your code I think I may know your issue here, even reads have an max allowance you can fetch from a node, it looks like your passing an insane amount of requests here..

Could you revert back to your code and then maybe do a request with say 5 tokenIds for now and see if it works?

const tokenIDs = [1,2,3,4,5]

Just want to make sure your not requesting a bit too much information

from ethereum-multicall.

emorling avatar emorling commented on August 13, 2024

Wow hahaha!

And your using the ABI supplied in the etherscan link you sent right?

Also looking at your code I think I may know your issue here, even reads have - max allowance you get fetch from a node, it looks like your passing an insane amount of requests here..

Could you revert back to your code and then maybe do a request with say 5 tokenIds for now and see if it works?

const tokenIDs = [1,2,3,4,5]

Just want to make sure your not requesting a bit too much information

This is the ABI I am using, it's the same as in the etherscan:

const abi = [{'inputs':[{'internalType':'uint256','name':'index','type':'uint256'}],'name':'tokenByIndex','outputs':[{'internalType':'uint256','name':'','type':'uint256'}],'stateMutability':'view','type':'function'}];

Sure it works with just the 5 tokens. But here I can fetch 12K without any problem?

require('dotenv').config();
const { Multicall } = require('ethereum-multicall');
const Web3 = require('web3');

const abi = [{'inputs':[{'internalType':'uint256','name':'index','type':'uint256'}],'name':'tokenByIndex','outputs':[{'internalType':'uint256','name':'','type':'uint256'}],'stateMutability':'view','type':'function'}];

const options = {
  timeout: 10000, // ms
  reconnect: { auto: true, delay: 1000,  maxAttempts: 5, onTimeout: false }
};
const provider = new Web3.providers.HttpProvider(process.env.QUICKNODE_HTTP_URL);
const web3 = new Web3(provider, options);
const multicall = new Multicall({ web3Instance: web3, tryAggregate: true});

async function main() {
  const tokenIDs = Array.from({length: 12000}, (_, i) => i );
  const calls = tokenIDs.map((token_id) => { return { methodName: 'tokenByIndex', methodParameters: [token_id] }; });
  const contractCallContext = [{ reference: 'contract', contractAddress: '0x34d85c9cdeb23fa97cb08333b511ac86e1c4e258', abi, calls}];
  const results = await multicall.call(contractCallContext);
  const extract = results.results.contract.callsReturnContext.map((r) => r.success ? web3.utils.hexToNumber(r.returnValues[0].hex) : null);
  console.log(extract);
}

main();

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Your problem is down to max response sizes from the node.. it all depend! If I was you I would fine a safe amount which the node likes that could be 1000,2000 and then do many promise.all on a multicall.call instance which means you still get your results back just as fast but won’t be limited by the nodes thinking response is too big! Does that make sense?

This is not down to a coding issue here it’s limitations of the read nodes sizes!

from ethereum-multicall.

emorling avatar emorling commented on August 13, 2024

I see... but I thought tryAggregate would make it possible to get results without the whole thing crashing?

from ethereum-multicall.

joshstevens19 avatar joshstevens19 commented on August 13, 2024

Well the entire thing is throwing so everything would blow up.. it’s actually better it does this here then gives you false for all because it has not executed any of the contract calls.. out of gas === too large I can try to make it a better message but it’s defo better to throw here then give a false positive back to users that everything failed (aka it will look like it executed it on chain).

Solution reduce sizes of requests and bulk call maybe il add a method called bulk call?! Or maybe il try to handle this internally and split the array up.. but for now reduce your size and call .call with promise.all and you get your result. Thanks for raising defo a feature to add here of maybe handling this for you in the lib 👍

from ethereum-multicall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.