diff --git a/latest/.buildinfo b/latest/.buildinfo index df451b1586..e66e7527a2 100644 --- a/latest/.buildinfo +++ b/latest/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: e65dac6cbd62e450935d45d3e43a261e +config: 2f197c89446ccedd72f18fb5ff8e10ba tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/latest/.doctrees/commands/console.doctree b/latest/.doctrees/commands/console.doctree index e8b29a16d2..9e29a478a7 100644 Binary files a/latest/.doctrees/commands/console.doctree and b/latest/.doctrees/commands/console.doctree differ diff --git a/latest/.doctrees/commands/networks.doctree b/latest/.doctrees/commands/networks.doctree index e48e2c1a79..46d4d5da5e 100644 Binary files a/latest/.doctrees/commands/networks.doctree and b/latest/.doctrees/commands/networks.doctree differ diff --git a/latest/.doctrees/environment.pickle b/latest/.doctrees/environment.pickle index bc7a02d23f..9674618912 100644 Binary files a/latest/.doctrees/environment.pickle and b/latest/.doctrees/environment.pickle differ diff --git a/latest/.doctrees/methoddocs/ape.doctree b/latest/.doctrees/methoddocs/ape.doctree index 4ba6649e35..a7bf32be84 100644 Binary files a/latest/.doctrees/methoddocs/ape.doctree and b/latest/.doctrees/methoddocs/ape.doctree differ diff --git a/latest/.doctrees/methoddocs/api.doctree b/latest/.doctrees/methoddocs/api.doctree index 8686da5e35..b2bfed57f7 100644 Binary files a/latest/.doctrees/methoddocs/api.doctree and b/latest/.doctrees/methoddocs/api.doctree differ diff --git a/latest/.doctrees/methoddocs/cli.doctree b/latest/.doctrees/methoddocs/cli.doctree index 2512d452a5..c1af70a3dc 100644 Binary files a/latest/.doctrees/methoddocs/cli.doctree and b/latest/.doctrees/methoddocs/cli.doctree differ diff --git a/latest/.doctrees/methoddocs/contracts.doctree b/latest/.doctrees/methoddocs/contracts.doctree index a94148b1c4..5118d3342f 100644 Binary files a/latest/.doctrees/methoddocs/contracts.doctree and b/latest/.doctrees/methoddocs/contracts.doctree differ diff --git a/latest/.doctrees/methoddocs/exceptions.doctree b/latest/.doctrees/methoddocs/exceptions.doctree index 3eb2a78ffa..72e35ab72c 100644 Binary files a/latest/.doctrees/methoddocs/exceptions.doctree and b/latest/.doctrees/methoddocs/exceptions.doctree differ diff --git a/latest/.doctrees/methoddocs/managers.doctree b/latest/.doctrees/methoddocs/managers.doctree index de3ac48cf8..4e70d3601e 100644 Binary files a/latest/.doctrees/methoddocs/managers.doctree and b/latest/.doctrees/methoddocs/managers.doctree differ diff --git a/latest/.doctrees/methoddocs/plugins.doctree b/latest/.doctrees/methoddocs/plugins.doctree index 2366e369b9..0c6ab272b1 100644 Binary files a/latest/.doctrees/methoddocs/plugins.doctree and b/latest/.doctrees/methoddocs/plugins.doctree differ diff --git a/latest/.doctrees/methoddocs/types.doctree b/latest/.doctrees/methoddocs/types.doctree index e05011833a..30994055a3 100644 Binary files a/latest/.doctrees/methoddocs/types.doctree and b/latest/.doctrees/methoddocs/types.doctree differ diff --git a/latest/.doctrees/methoddocs/utils.doctree b/latest/.doctrees/methoddocs/utils.doctree index 65c1b2d75e..c702806b6e 100644 Binary files a/latest/.doctrees/methoddocs/utils.doctree and b/latest/.doctrees/methoddocs/utils.doctree differ diff --git a/latest/.doctrees/userguides/contracts.doctree b/latest/.doctrees/userguides/contracts.doctree index 693475d544..6493ba9540 100644 Binary files a/latest/.doctrees/userguides/contracts.doctree and b/latest/.doctrees/userguides/contracts.doctree differ diff --git a/latest/_sources/userguides/contracts.md.txt b/latest/_sources/userguides/contracts.md.txt index ff90c39cbd..d5c97e34e6 100644 --- a/latest/_sources/userguides/contracts.md.txt +++ b/latest/_sources/userguides/contracts.md.txt @@ -224,3 +224,37 @@ contract = ape.Contract("0x...") bytes_value = contract.encode_input(0, 1, 2, 4, 5) method_id, input_dict = contract.decode_input(bytes_value) ``` + +## Multi-Call and Multi-Transaction + +The `ape_ethereum` core plugin comes with a `multicall` module containing tools for interacting with the [multicall3 smart contract](https://github.com/mds1/multicall). +Multicall allows you to group function calls and transactions into a single call or transaction. + +Here is an example of how you can use the multicall module: + +```python +import ape +from ape_ethereum import multicall + + +ADDRESSES = ("0xF4b8A02D4e8D76070bD7092B54D2cBbe90fa72e9", "0x80067013d7F7aF4e86b3890489AcAFe79F31a4Cb") +POOLS = [ape.project.IPool.at(a) for a in ADDRESSES] + + +def main(): + # Use multi-call. + call = multicall.Call() + for pool in POOLS: + call.add(pool.getReserves) + + print(list(call())) + + # Use multi-transaction. + tx = multicall.Transaction() + for pool in POOLS: + tx.add(pool.ApplyDiscount, 123) + + acct = ape.accounts.load("signer") + for result in tx(sender=acct): + print(result) +``` diff --git a/latest/commands/console.html b/latest/commands/console.html index 15bbc45264..013d5ac6d6 100644 --- a/latest/commands/console.html +++ b/latest/commands/console.html @@ -209,7 +209,7 @@
ethereum
:mainnet:geth | ethereum:mainnet:geth | :mainnet | ethereum:mainnet | :goerli:geth | ethereum:goerli:geth | :goerli | ethereum:goerli | :sepolia:geth | ethereum:sepolia:geth | :sepolia | ethereum:sepolia | ::test | ethereum:local:test | ::geth | ethereum:local:geth | :local | ethereum:local | ethereum
+:mainnet:geth | ethereum:mainnet:geth | :mainnet | ethereum:mainnet | :goerli:geth | ethereum:goerli:geth | :goerli | ethereum:goerli | :sepolia:geth | ethereum:sepolia:geth | :sepolia | ethereum:sepolia | ::geth | ethereum:local:geth | ::test | ethereum:local:test | :local | ethereum:local | ethereum
goerli-fork | local | mainnet-fork | goerli | sepolia | mainnet | sepolia-fork
+sepolia-fork | local | mainnet | mainnet-fork | goerli-fork | sepolia | goerli
geth | test
+test | geth
ethereum:local:geth
:mainnet:geth | ethereum:mainnet:geth | :mainnet | ethereum:mainnet | :goerli:geth | ethereum:goerli:geth | :goerli | ethereum:goerli | :sepolia:geth | ethereum:sepolia:geth | :sepolia | ethereum:sepolia | ::test | ethereum:local:test | ::geth | ethereum:local:geth | :local | ethereum:local | ethereum
+:mainnet:geth | ethereum:mainnet:geth | :mainnet | ethereum:mainnet | :goerli:geth | ethereum:goerli:geth | :goerli | ethereum:goerli | :sepolia:geth | ethereum:sepolia:geth | :sepolia | ethereum:sepolia | ::geth | ethereum:local:geth | ::test | ethereum:local:test | :local | ethereum:local | ethereum
The ape_ethereum
core plugin comes with a multicall
module containing tools for interacting with the multicall3 smart contract.
+Multicall allows you to group function calls and transactions into a single call or transaction.
Here is an example of how you can use the multicall module:
+import ape
+from ape_ethereum import multicall
+
+
+ADDRESSES = ("0xF4b8A02D4e8D76070bD7092B54D2cBbe90fa72e9", "0x80067013d7F7aF4e86b3890489AcAFe79F31a4Cb")
+POOLS = [ape.project.IPool.at(a) for a in ADDRESSES]
+
+
+def main():
+ # Use multi-call.
+ call = multicall.Call()
+ for pool in POOLS:
+ call.add(pool.getReserves)
+
+ print(list(call()))
+
+ # Use multi-transaction.
+ tx = multicall.Transaction()
+ for pool in POOLS:
+ tx.add(pool.ApplyDiscount, 123)
+
+ acct = ape.accounts.load("signer")
+ for result in tx(sender=acct):
+ print(result)
+