Comments (4)
@Majorfi thanks for such a detailed answer! I think I get it now.
Probably the easiest fix would be to switch the order of multicall contracts for getEthBalance
, so that the Multicall 3 would be the default.
But I have to think whether this might break something. In the meantime, feel free to give any other ideas.
from ethcall.
Fixed in 5.0.1
from ethcall.
Hey @Majorfi! Did you tried to query ether balance using ethcall on mainnet, and it failed due to trying to use 0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e
?
From the code, this address is used on 1337
chain, which is a local devnet if I'm not mistaken. On mainnet, we indeed use 0xeefba1e63905ef1d7acba5a8513c70307c1ce441
(source) as you could expect.
Are you sure you were querying mainnet? If so, could you please provide a snippet or a repo to reproduce?
from ethcall.
Hey!
Sorry for the late answer. It may not be something to change and this may lead to breaking change, so this is probably to take with caution!
I will talk from my xp and the people around me, but when we usualy work with the network 1337
, it's to fork the Ethereum Mainnet network (1
) and simulate some transactions with the "current state" of eth.
I usually use multicall2
with the tryAll
method, but a few weeks ago, I needed to get the ETH
balance for an account in one batched call.
The thing is that if I am working with the mainnet fork, my tryAll
will use the address 0x5ba1e12693dc8f9c48aad8770482f4739beed696
(which is the same on 1, 5 or 1337), but the getEthBalance
will use the address 0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e
, which is the same as the one on Goerli, but which did not exists on mainnet, making that specific call fails.
The code of getEthBalance
uses the first multicall available:
const multicall = this.multicall || this.multicall2 || this.multicall3;
Which cause the call to fail.
I find it weird that the address for multicall1 is not the same as mainnet (but that's given my xp). However, something should probably be done to call the corresponding multicall based on the method called (all
, tryAll
, tryEach
)
Here a very basic example leading to the error on mainnet fork:
const ethcallProvider = await providers.newEthCallProvider(currentProvider);
const erc20TokenContract = new Contract(token, ERC20_ABI);
calls.push(ethcallProvider.getEthBalance(ownerAddress)); //Will use multicall1
calls.push(tokenContract.balanceOf(ownerAddress));
const results = await ethcallProvider.tryAll(calls); //Will use multicall2
Addresses from the multicall file:
With multicall1:
- 1:
0xeefba1e63905ef1d7acba5a8513c70307c1ce441
- 5:
0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e
- 1337:
0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e
With multicall2:
- 1:
0x5ba1e12693dc8f9c48aad8770482f4739beed696
- 5:
0x5ba1e12693dc8f9c48aad8770482f4739beed696
- 1337:
0x5ba1e12693dc8f9c48aad8770482f4739beed696
With multicall3:
- 1:
0xca11bde05977b3631167028862be2a173976ca11
- 5:
0xca11bde05977b3631167028862be2a173976ca11
- 1337:
0xca11bde05977b3631167028862be2a173976ca11
Please tell me if you want more elements!
Thank you
from ethcall.
Related Issues (20)
- Add example directory HOT 1
- Use ethers 6 HOT 1
- Issue w/ ethcall when using a JsonRpcProvider HOT 1
- The result returned is un-named HOT 2
- Can the callStatic contract method be supported?
- API: provide call overrides (block, from, etc) as object HOT 1
- Don't override "from" value by default HOT 1
- Supporting ethers human-readable ABIs HOT 3
- Encountering RejectCallerWithCode error when using Anvil HOT 2
- queryFilter on Multicall
- Allow custom multicall addresses in Init HOT 3
- Allow to use different networks like Sepolia.
- getting importAssertions error HOT 4
- Switch to Pure ESM HOT 1
- Feature request: add support for 'pending' blockTag HOT 1
- Add arbitrum testnet 421611 HOT 3
- getEthBalance(address) function is stale HOT 1
- Allow manually setting gasLimit
- Set up test matrix HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ethcall.