Skip to content

Add access to core Multicall contract methods #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DefiDebauchery
Copy link
Contributor

@DefiDebauchery DefiDebauchery commented Apr 22, 2025

The core Multicall contracts have various methods for accessing base attributes of the chain at the executed block number, the most important (IMO) being getEthBalance() and getCurrentBlockTimestamp().

getBlockNumber() is slightly redundant since it's already provided via aggregate() / tryBlockAndAggregate() (exposed via #74), but added, along with all other methods, for completeness.

One real-world example that I use in my own code:

calls = [
	Call(wrapped_native, ['balanceOf(address)(uint256)', my_address], [['weth_balance', None]])
]
mc = Multicall(calls, _w3=rpc)
mc.get_eth_balance(my_address)

results = await mc.coroutine()
// {'weth_balance': 4858579460227, 'eth_balance': 60178543536789}

The return signature can be overridden to a different key or formatter.

Edits to overall structure or nomenclature welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant