gnosis safe tx builder

Overview

Ape Safe: Gnosis Safe tx builder

Ape Safe allows you to iteratively build complex multi-step Gnosis Safe transactions and safely preview their side effects from the convenience of a locally forked mainnet environment.

Installation

pip install -U ape-safe

Quickstart

brownie console --network mainnet-fork
from ape_safe import ApeSafe
safe = ApeSafe('ychad.eth')

dai = safe.contract('0x6B175474E89094C44Da98b954EedeAC495271d0F')
vault = safe.contract('0x19D3364A399d251E894aC732651be8B0E4e85001')

amount = dai.balanceOf(safe.account)
dai.approve(vault, amount)
vault.deposit(amount)

safe_tx = safe.multisend_from_receipts()
safe.preview(safe_tx)
safe.post_transaction(safe_tx)

See Documentation for more examples and full reference.

Comments
  • Question: Is there a workflow to sign the safe tx using a ledger based account?

    Question: Is there a workflow to sign the safe tx using a ledger based account?

    Considering the security focus of Gnosis Safes it seems counterproductive to require the private key to reside on the machine where the ape-safe tools are used.

    opened by jo-tud 6
  • When invoking method on contract I receive ValueError: eth_sendTransaction does not exist

    When invoking method on contract I receive ValueError: eth_sendTransaction does not exist

    I am trying to have a gnosis safe invoke the mint function on an ERC20 to which it has the permissions to do so.

    Below is my code in which I follow the way presented in the quickstart of the documentation.

    When I run this code, it errors out at ovl.mint with the error ValueError: The method eth_sendTransaction does not exist/is not available

    def main():    
      gov = dotenv_values()['GOVERNANCE']    
      safe = ApeSafe(gov)            
      ovl = safe.contract("0xfa474A313BDBF69E287dbef667e2f626ea2574Df") # Must have a checksummed address          
      ovl.mint("0xA600AdF7CB8C750482a828712849ee026446aA66", 1e18) # method takes (address,uint) 
    

    When I run this code, I get this stack trace at ovl.mint()

      File "brownie/_cli/run.py", line 51, in main
        return_value, frame = run(
      File "brownie/project/scripts.py", line 110, in run
        return_value = f_locals[method_name](*args, **kwargs)
      File "./scripts/token/mint.py", line 27, in main
        ovl.mint(to, amt)
      File "brownie/network/contract.py", line 1861, in __call__
        return self.transact(*args)
      File "brownie/network/contract.py", line 1734, in transact
        return tx["from"].transfer(
      File "brownie/network/account.py", line 644, in transfer
        receipt, exc = self._make_transaction(
      File "brownie/network/account.py", line 752, in _make_transaction
        exc = VirtualMachineError(e)
      File "brownie/exceptions.py", line 96, in __init__
        raise ValueError(exc["message"]) from None
    ValueError: The method eth_sendTransaction does not exist/is not available
    
    opened by realisation 1
  • Cannot find module after quickstart instructions

    Cannot find module after quickstart instructions

    I followed these https://safe.ape.tax/quickstart.html instructions and when I try to run scripts or a brownie console to import ApeSafe from ape_safe, it gives me an error saying there is no module named ape_safe.

    Python version in the brownie console is 3.8.9 Python3 version is 3.9.10 Python version is 2.7.18 Brownie version 1.17.2 Pip3 version is 22.2.2 Pipx version is 1.0.0 Pip version is 22.0.4

    Operating system is MacOS Monterey 12.2.1

    opened by realisation 1
  • non descriptive error when passing non checksummed address

    non descriptive error when passing non checksummed address

      File "./ape_safe.py", line 56, in contract
        return Contract(address, owner=self.account)
      File "brownie/network/contract.py", line 916, in __init__
        address_or_alias = address_or_alias.strip()
    AttributeError: 'NoneType' object has no attribute 'strip'
    
    opened by gosuto-inzasheru 1
  • Can't sign tx to test if I am not part of the ms

    Can't sign tx to test if I am not part of the ms

    CMO allowed me to test a tx and sign even when I was not an owner of a delegate of the ms. With ape-safe I get:

    ApiError: Error posting transaction: b'{"nonFieldErrors":["Sender=0x0 is not an owner or delegate. Current owners=[\'0x0\', \'0x0\', \'0x6F2A8Ee9452ba7d336b3fba03caC27f7818AeAD6\']. Delegates=[]"]}'

    At the beginning I thought it was a gnosis upgrade, but I just run a tx with ape-safe installed and I could sign to test without issues.

    I guess ms.preview(tx) is not doing the same thing as estimate_safe_tx(safe_tx)

    opened by poolpitako 1
  • Installation fails

    Installation fails

    Trying to install with pip install -U ape-safe fails with the following error:

    ERROR: trie 2.0.0a5 has requirement typing-extensions<4,>=3.7.4, but you'll have typing-extensions 4.2.0 which is incompatible.
    ERROR: eth-brownie 1.19.0 has requirement requests==2.27.1, but you'll have requests 2.28.0 which is incompatible.
    

    Using linux and python 3.8.10.

    Maybe related to issue #27?

    opened by bingen 0
  • simulate all pending txs before preview

    simulate all pending txs before preview

    problem

    it feels bad when a tx in the queue rugs a tx you have carefully crafted.

    solution

    add a flag to preview to simulate all the txs in the queue, so you arrive at a more correct state.

    good first issue 
    opened by banteg 0
  • feat: add Trezor eip-712 signing support

    feat: add Trezor eip-712 signing support

    Trezor T now has support for EIP-712 clear signing; this adds Trezor + EIP-712 sig support in Ape Safe

    Changes (in sign_with_trezor()):

    • added EIP-712 support
    • added force_eth_sign param to force use of eth_sign instead of EIP-712 signatures
    • sign_with_trezor() will now prefer EIP-712 signatures if the connected Trezor is compatible (based on model + fw version). Otherwise (or if force_eth_sign is truthy), it'll stick with eth_sign signatures.

    This might need another update if and when Trezor adds EIP-712 signing support in Trezor One (client.features.model == "1") -- plus, it seems like Trezor is planning on only having blind-signing support on the T1 (trezor/trezor-firmware#1970), so a bit of extra work might be needed for future T1 support

    Tested on Trezor T with fw version v2.4.3; both EIP-712 and eth_sign signatures work fine.

    opened by zhongfu 0
  • feat: add Trezor signing support (through trezorlib)

    feat: add Trezor signing support (through trezorlib)

    Added ability to create eth_sign SafeTx signatures with trezorlib. Adds new function sign_with_trezor(safe_tx, derivation_path, use_passphrase)

    Passphrase support is kind of rudimentary; I believe it might not work on the Trezor One because you can't enter a passphrase on-device with it. We could probably do on-host passphrase input though. Otherwise, it defaults to no passphrase (and skips any passphrase prompts), which will probably work on a T1

    Tested w/ a Trezor T on fw v2.4.2.

    (also, worth noting that EIP-712 support is now in master for TT; we can probably add signTypedData support too)

    (would also appreciate if someone with a T1 could test it out)

    opened by zhongfu 0
  • feat: hardware wallet support via frame signer

    feat: hardware wallet support via frame signer

    Add ability to sign Safe transactions using Ledger, Trezor and Lattice1 via Frame.

    Tested on Ethereum Mainnet with Ledger Nano X.

    New API:

    • get_signer()
    • sign_with_frame(safe_tx)
    • post_signature(safe_tx, signature_
    • pending_transactions
    • confirmations_to_signatures(confirmations)
    • execute_transaction

    Some specific combinations I want tested:

    • [ ] safe on any network but eth mainnet which has a ledger as owner (ledger doesn't support eip155 and i want to see if i implemented the fix for it correctly)
    • [ ] safe on any network with any trezor model as owner
    • [ ] safe on any network with lattice1 as owner
    opened by banteg 0
  • May not work for some installation with the trezor from `0.13.0`

    May not work for some installation with the trezor from `0.13.0`

    The problem is in simple-rlp dependency introduced by trezor, see the issue.

    <...>
        class HashableRLP(rlp.Serializable):
    AttributeError: module 'rlp' has no attribute 'Serializable'
    

    Possible workaround ~~for those who doesn't rely on trezor~~:

    rm -r .direnv/python-3.9.16/lib/python3.9/site-packages/rlp-2.0.1.dist-info
    rm -r .direnv/python-3.9.16/lib/python3.9/site-packages/rlp
    pip install rlp==2.0.1
    

    By the way, simple running pip install ape-safe from scratch does the thing because of order of packages installation.

    opened by madlabman 0
  • feat: support renaming of `Safe.get_contract` to `Safe.contract` in `safe-eth-py>=4.4.0`

    feat: support renaming of `Safe.get_contract` to `Safe.contract` in `safe-eth-py>=4.4.0`

    function was renamed in safe-eth-py>=v4.4.0 (https://github.com/safe-global/safe-eth-py/pull/339/commits/95f6dab52cbf6a6c7462158538593f51bc6b62e0), which now collides with our ApeSafe.contract

    solves #43

    opened by gosuto-inzasheru 0
  • chore: update safe global api urls

    chore: update safe global api urls

    old docs here, but urls redirect to the new ones: https://docs.gnosis-safe.io/backend/available-services#safe-transaction-service

    rinkeby has been deprecated

    opened by gosuto-inzasheru 0
  • Most recent version of safe-eth-py isn't working with addresses

    Most recent version of safe-eth-py isn't working with addresses

    Using ape-safe 0.5.1 with safe-eth-py="4.3.0" and above or 0.6.0 with safe-eth-py="^4.5.0" isn't working.

    Here is the error.

    File "brownie/_cli/run.py", line 51, in main
        return_value, frame = run(
      File "brownie/project/scripts.py", line 110, in run
        return_value = f_locals[method_name](*args, **kwargs)
      File "./scripts/33_test_ape_safe.py", line 10, in main
        safe_tx = safe.multisend_from_receipts()
      File "ape_safe.py", line 115, in multisend_from_receipts
        data = MultiSend(self.multisend, self.ethereum_client).build_tx_data(txs)
      File "gnosis/safe/multi_send.py", line 199, in __init__
        assert fast_is_checksum_address(address), (
    AssertionError: EthereumClient for url=http://127.0.0.1:8545 proxy factory address not valid
    Terminating local RPC client...
    
    opened by pandadefi 1
  • parameter flip in gnosis py

    parameter flip in gnosis py

    https://github.com/safe-global/safe-eth-py/commit/8848f1660f6a04995ebb808f4cc946bd060915c2#diff-8a8473acf2213f63824bdb6022b690acfd1fab752f657301175b01c2cd9e0cf0

    opened by banteg 0
Releases(v0.5.0)
  • v0.5.0(Dec 16, 2021)

    What's Changed

    • Add execute_transaction_with_frame by @OwlOfMoistness in https://github.com/banteg/ape-safe/pull/21
    • feat: add Trezor eip-712 signing support by @zhongfu in https://github.com/banteg/ape-safe/pull/22

    New Contributors

    • @OwlOfMoistness made their first contribution in https://github.com/banteg/ape-safe/pull/21

    Full Changelog: https://github.com/banteg/ape-safe/compare/v0.4.0...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Nov 30, 2021)

  • v0.3.2(Nov 10, 2021)

    • hardware wallet support via frame
    • submit signatures to transaction service
    • retrieve pending transactions from transaction service
    • execute signed transactions
    • convert confirmations to signatures
    • expanded documentation about signing
    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Sep 13, 2021)

  • v0.2.0(Jul 22, 2021)

    • add support for safe contracts 1.3.0
    • switch to multicall 1.3.0 call only
    • support multiple networks
    • autodetect transaction service from chain id
    Source code(tar.gz)
    Source code(zip)
Owner
core dev, yearn.finance
null
PR Changes Matrix Builder

Pr-changes-matrix-builder - A Github Action that will output a variable to be used in a matrix strategy job based on a PR&'s changes

Kyle James Walker (he/him) 21 Oct 4, 2022
An Anime Themed Fast And Safe Group Managing Bot.

Ξ L I N Λ ?? A Powerful, Smart And Simple Group Manager bot Avaiilable a latest version as Ξ L I N Λ ?? on Telegram Self-hosting (For Devs) vps # Inst

null 7 Nov 12, 2022
Project glow is an open source bot worked on by many people to create a good and safe moderation bot for all

Project Glow Greetings, I see you have stumbled upon project glow. Project glow is an open source bot worked on by many people to create a good and sa

Glowstikk 24 Sep 29, 2022
an API to check if a url or IP address is safe or phishing

an API to check if a url or IP address is safe or phishing. Using a ML model. The API created using FastAPI.

Adel Dahani 1 Feb 16, 2022
Thread-safe Python RabbitMQ Client & Management library

AMQPStorm Thread-safe Python RabbitMQ Client & Management library. Introduction AMQPStorm is a library designed to be consistent, stable and thread-sa

Erik Olof Gunnar Andersson 167 Nov 20, 2022
Gnosis-py includes a set of libraries to work with Ethereum and Gnosis projects

Gnosis-py Gnosis-py includes a set of libraries to work with Ethereum and Gnosis projects: EthereumClient, a wrapper over Web3.py Web3 client includin

Gnosis 93 Dec 23, 2022
Infrastructure as Code (IaC) for a self-hosted version of Gnosis Safe on AWS

Welcome to Yearn Gnosis Safe! Setting up your local environment Infrastructure Deploying Gnosis Safe Prerequisites 1. Create infrastructure for secret

Numan 16 Jul 18, 2022
Main repository for the Sphinx documentation builder

Sphinx Sphinx is a tool that makes it easy to create intelligent and beautiful documentation for Python projects (or other documents consisting of mul

null 5.1k Jan 2, 2023
Virtual Python Environment builder

virtualenv A tool for creating isolated virtual python environments. Installation Documentation Changelog Issues PyPI Github Code of Conduct Everyone

Python Packaging Authority 4.3k Dec 30, 2022
PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.

PyPika - Python Query Builder Abstract What is PyPika? PyPika is a Python API for building SQL queries. The motivation behind PyPika is to provide a s

KAYAK 1.9k Jan 4, 2023
Main repository for the Sphinx documentation builder

Sphinx Sphinx is a tool that makes it easy to create intelligent and beautiful documentation for Python projects (or other documents consisting of mul

null 5.1k Jan 4, 2023
sphinx builder that outputs markdown files.

sphinx-markdown-builder sphinx builder that outputs markdown files Please ★ this repo if you found it useful ★ ★ ★ If you want frontmatter support ple

Clay Risser 144 Jan 6, 2023
A URL builder for genius :D

genius-url A URL builder for genius :D Usage from gurl import genius_url

ꌗᖘ꒒ꀤ꓄꒒ꀤꈤꍟ 12 Aug 14, 2021
Piccolo - A fast, user friendly ORM and query builder which supports asyncio.

A fast, user friendly ORM and query builder which supports asyncio.

null 919 Jan 4, 2023
This open-source python3 script is a builder to the very popular token logger that is on my github that many people use.

Discord-Logger-Builder This open-source python3 script is a builder to the very popular token logger that is on my github that many people use. This i

Local 4 Nov 17, 2021
Que es S4K Builder?, Fácil un constructor de tokens grabbers con muchas opciones, como BTC Miner, Clipper, shutdown PC, Y más! Disfrute el proyecto. <3

S4K Builder Este script Python 3 de código abierto es un constructor del muy popular registrador de tokens que está en [mi GitHub] (https://github.com

SadicX 1 Oct 22, 2021
Brute-forcing (or not!) deck builder for Pokemon Trading Card Game.

PokeBot Deck Builder Brute-forcing (or not!) deck builder for Pokemon Trading Card Game. Warning: intensely not optimized and spaghetti coded Credits

Hocky Harijanto 0 Jan 10, 2022
🤕 spelling exceptions builder for lazy people

?? spelling exceptions builder for lazy people

Vlad Bokov 3 May 12, 2022