Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 5, 2023
1 parent b296ddb commit b099554
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 6 deletions.
2 changes: 1 addition & 1 deletion latest/.buildinfo
Original file line number Diff line number Diff line change
@@ -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
Binary file modified latest/.doctrees/commands/console.doctree
Binary file not shown.
Binary file modified latest/.doctrees/commands/networks.doctree
Binary file not shown.
Binary file modified latest/.doctrees/environment.pickle
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/ape.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/api.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/cli.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/contracts.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/exceptions.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/managers.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/plugins.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/types.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/utils.doctree
Binary file not shown.
Binary file modified latest/.doctrees/userguides/contracts.doctree
Binary file not shown.
34 changes: 34 additions & 0 deletions latest/_sources/userguides/contracts.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
2 changes: 1 addition & 1 deletion latest/commands/console.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <h2>console<a class="headerlink" href="#console" title="Permalink to this headin
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">ethereum</span></code></p>
</dd>
<dt class="field-even">Options<span class="colon">:</span></dt>
<dd class="field-even"><p>: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</p>
<dd class="field-even"><p>: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</p>
</dd>
</dl>
</dd></dl>
Expand Down
6 changes: 3 additions & 3 deletions latest/commands/networks.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ <h2>list<a class="headerlink" href="#networks-list" title="Permalink to this hea
<dd><p>Filter the results by network</p>
<dl class="field-list simple">
<dt class="field-odd">Options<span class="colon">:</span></dt>
<dd class="field-odd"><p>goerli-fork | local | mainnet-fork | goerli | sepolia | mainnet | sepolia-fork</p>
<dd class="field-odd"><p>sepolia-fork | local | mainnet | mainnet-fork | goerli-fork | sepolia | goerli</p>
</dd>
</dl>
</dd></dl>
Expand All @@ -249,7 +249,7 @@ <h2>list<a class="headerlink" href="#networks-list" title="Permalink to this hea
<dd><p>Filter the results by provider</p>
<dl class="field-list simple">
<dt class="field-odd">Options<span class="colon">:</span></dt>
<dd class="field-odd"><p>geth | test</p>
<dd class="field-odd"><p>test | geth</p>
</dd>
</dl>
</dd></dl>
Expand Down Expand Up @@ -277,7 +277,7 @@ <h2>run<a class="headerlink" href="#networks-run" title="Permalink to this headi
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">ethereum:local:geth</span></code></p>
</dd>
<dt class="field-even">Options<span class="colon">:</span></dt>
<dd class="field-even"><p>: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</p>
<dd class="field-even"><p>: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</p>
</dd>
</dl>
</dd></dl>
Expand Down
2 changes: 1 addition & 1 deletion latest/searchindex.js

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions latest/userguides/contracts.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#decoding-and-encoding-inputs">Decoding and Encoding Inputs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#multi-call-and-multi-transaction">Multi-Call and Multi-Transaction</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="proxy.html">Proxy Contracts</a></li>
Expand Down Expand Up @@ -387,6 +388,38 @@ <h2>Decoding and Encoding Inputs<a class="headerlink" href="#decoding-and-encodi
</pre></div>
</div>
</section>
<section id="multi-call-and-multi-transaction">
<h2>Multi-Call and Multi-Transaction<a class="headerlink" href="#multi-call-and-multi-transaction" title="Permalink to this heading"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">ape_ethereum</span></code> core plugin comes with a <code class="docutils literal notranslate"><span class="pre">multicall</span></code> module containing tools for interacting with the <a class="reference external" href="https://github.com/mds1/multicall">multicall3 smart contract</a>.
Multicall allows you to group function calls and transactions into a single call or transaction.</p>
<p>Here is an example of how you can use the multicall module:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">ape</span>
<span class="kn">from</span> <span class="nn">ape_ethereum</span> <span class="kn">import</span> <span class="n">multicall</span>


<span class="n">ADDRESSES</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;0xF4b8A02D4e8D76070bD7092B54D2cBbe90fa72e9&quot;</span><span class="p">,</span> <span class="s2">&quot;0x80067013d7F7aF4e86b3890489AcAFe79F31a4Cb&quot;</span><span class="p">)</span>
<span class="n">POOLS</span> <span class="o">=</span> <span class="p">[</span><span class="n">ape</span><span class="o">.</span><span class="n">project</span><span class="o">.</span><span class="n">IPool</span><span class="o">.</span><span class="n">at</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">ADDRESSES</span><span class="p">]</span>


<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="c1"># Use multi-call.</span>
<span class="n">call</span> <span class="o">=</span> <span class="n">multicall</span><span class="o">.</span><span class="n">Call</span><span class="p">()</span>
<span class="k">for</span> <span class="n">pool</span> <span class="ow">in</span> <span class="n">POOLS</span><span class="p">:</span>
<span class="n">call</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">pool</span><span class="o">.</span><span class="n">getReserves</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">call</span><span class="p">()))</span>

<span class="c1"># Use multi-transaction.</span>
<span class="n">tx</span> <span class="o">=</span> <span class="n">multicall</span><span class="o">.</span><span class="n">Transaction</span><span class="p">()</span>
<span class="k">for</span> <span class="n">pool</span> <span class="ow">in</span> <span class="n">POOLS</span><span class="p">:</span>
<span class="n">tx</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">pool</span><span class="o">.</span><span class="n">ApplyDiscount</span><span class="p">,</span> <span class="mi">123</span><span class="p">)</span>

<span class="n">acct</span> <span class="o">=</span> <span class="n">ape</span><span class="o">.</span><span class="n">accounts</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s2">&quot;signer&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">tx</span><span class="p">(</span><span class="n">sender</span><span class="o">=</span><span class="n">acct</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>


Expand Down

0 comments on commit b099554

Please sign in to comment.