First off, thanks for ethers, it's great!
I'm trying to do a balance snapshot and I'm wondering if there's an equivalent to Web3's ability to pass in a block number when doing a function call like they do here, e.g.
myContract.methods.methodName().call(transactionObject, blockNumber, callback)
Is that something we can do with ethers? I couldn't find anything about it in the documentation, and looking through the code I'm not sure this is handled.
To do that currently you need to use the provider directly, but I will add that feature since it is quite useful. Keep in mind that a pruning node may not be able to respond correctly to blocks over 1024 blocks old.
To do it manually, for now:
var iface = new ethers.Interface(abi);
var info = iface.functions.methodName();
var tx = {
to: contractAddress,
data: info.data
}
provider.call(tx, blockNumber).then((result) => {
console.log(result);
});
I will add it to the Contract object this weekend though to the v4 branch, so then it can be overridden like normal contract overrides:
contract.methodName({ blockNumber: blockNumber }).then((result) => {
console.log(result);
});
Thanks! :)
The key chosen for contract overrides is blockTag.
This feature is now available in 4.0.5. I will update the documentation shortly.
Thanks! :)
Hi @ricmoo - did you ever add the documentation for this? I can't see it.
The documentation for v5 is currently only on my laptop. I鈥檒l be working on it while on the plane to NY for ETHNewYork shortly. :)
Oh! I think I confused this with another issue. I will check on the v4 docs too.
Most helpful comment
To do that currently you need to use the provider directly, but I will add that feature since it is quite useful. Keep in mind that a pruning node may not be able to respond correctly to blocks over 1024 blocks old.
To do it manually, for now:
I will add it to the Contract object this weekend though to the v4 branch, so then it can be overridden like normal contract overrides:
Thanks! :)