Let's take this contract as an example: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
.
It has multiple methods / properties that I wish to access, e.g.
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
At the moment, it seems like I need to call all of them individually, e.g.
await pairContract.methods.name().call()
await pairContract.methods.symbol().call()
await pairContract.methods.decimals().call()
await pairContract.methods.totalSupply().call()
Is there a way to retrieve all of the above in a single call to limit the number of roundtrips / requests?
I have found that there is BatchRequest
, but from what I can tell, it is equivalent to:
[
pairContract.methods.name().call(),
pairContract.methods.symbol().call(),
pairContract.methods.decimals().call(),
pairContract.methods.totalSupply().call()
]
i.e. it does not actually batch the requests.