Skip to content

Commit

Permalink
docs: multisend example (#32)
Browse files Browse the repository at this point in the history
* Update README to multicall pattern

* Update mutisend pattern comment

* Update README.md

* Update README.md

* fix: update typo

* update comments

tested on sepolia and optimism-mainnet

* small typoe

* docs: clean up comments in docs

* style: run black

---------

Co-authored-by: solarthesis <[email protected]>
Co-authored-by: kaleb <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2024
1 parent 02d865d commit ea9f9aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,16 @@ vault = tokens["yvDAI"]
amount = dai.balanceOf(safe) # How much we want to deposit
# Create a multisend transaction (a transaction that executes multiple calls)
txn = multisend.Transaction()
txn = multisend.MultiSend()
txn.add(dai.approve, vault, amount)
txn.add(vault.deposit, amount)
# Fetch signatures from any local signers, and broadcast if confirmations are met
# Otherwise, it will post the partially confirmed message to Safe Global's API
txn(sender=safe)
# Note that in case the user intends to only stage a transaction, then `submit=False` argument can also be added
# It is normal that when a user only intend to stage a transaction, an error is thrown
# this can be ignored by including the necessary try-catch (from ape.exceptions import SignatureError)
# Note that transaction is automatically prompted for execution if enough signers are available in local
txn(sender=safe,gas=0)
```

## Development
Expand Down
11 changes: 9 additions & 2 deletions ape_safe/multisend.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,20 @@ class MultiSend(ManagerAccessMixin):
Usage example::
from ape_safe import multisend
from ape import accounts
txn = multisend.Transaction()
# load the safe
safe = accounts.load("my-safe")
txn = multisend.MultiSend()
txn.add(contract.myMethod, *call_args)
txn.add(contract.myMethod, *call_args)
... # Add as many calls as desired to execute
txn.add(contract.myMethod, *call_args)
receipt = txn(sender=my_signer) # Sends the multisend transaction
# Stage the transaction to publish on-chain
# NOTE: if not enough signers are available, publish to Safe API instead
receipt = txn(sender=safe,gas=0)
"""

def __init__(self) -> None:
Expand Down

0 comments on commit ea9f9aa

Please sign in to comment.