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
Python client for Toyota North America service API

toyota-na Python client for Toyota North America service API Install pip install toyota-na[qt] [qt] is required for generating authorization code. Us

Gavin Ni 18 Sep 06, 2022
:evergreen_tree: Python module for communicating with the Taiga API

python-taiga A python wrapper for the Taiga REST API. Documentation: https://python-taiga.readthedocs.io/ Usage: : https://python-taiga.readthedocs.io

Nephila 87 Oct 12, 2022
For Help/Questions Join in discord

Simple-Nitro-Generator-Source Must have installed python! Discord: $MartoBossX#7777 Server: https://discord.gg/ErynDxTV5Y DONATE: (Crypto) BTC: bc1qg8

1 Jan 08, 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
A Bot, which observes your counting-abilities and controls your drinking-habits, too!

Discord Counting Bot with Beer-Counter Heavily inspired by AlexVerricos Counting_bot, but adjusted a lot for the beer drinking habits of students. Inv

Jakob Jung 3 Oct 18, 2022
Token Manager written in Python

Discord-API-Token-Entrance Description This is a Token Manager that allows your token to enter your discord server, written in python. Packages Requir

Tootle 1 Apr 15, 2022
Instagram story report with python

instagram-story-report Mass reports a victim stories. Made for fun, but can be used for chaos Single session and multi session support Login, choose a

Joshua Solo 8 May 08, 2022
Your custom slash commands Discord bot!

Slashy - Your custom slash-commands bot Hey, I'm Slashy - your friendly neighborhood custom-command bot! The code for this bot exists because I'm like

Omar Zunic 8 Dec 20, 2022
Simple-nft-tutorial - A simple tutorial on making nft/memecoins on algorand

nft/memecoin Tutorial on Algorand Let's make a simple NFT/memecoin on the Algora

2 Feb 05, 2022
A multi-tenant multi-client scalable product categorising demo stack

Better Categories 4All: A multi-tenant multi-client product categorising stack The steps to reproduce training and inference are in the end of this fi

7 Feb 15, 2022
Plays air warning sound when detects a certain phrase or a word in a specified Telegram chat.

Tryvoha Bot Disclaimer: this is more a convenient naming, rather than a real bot. It is designed to play air warning sound when detects a certain phra

Dmytro Novikov 2 Mar 02, 2022
PlexAutoSkip - Automatically skip content in Plex

PlexAutoSkip Automatically skip tagged content in Plex A background python scrip

Michael Higgins 97 Dec 21, 2022
Mini Tool to lovers of debe from eksisozluk (one of the most famous website -reffered as collaborative dictionary like reddit- in Turkey) for pushing debe (Most Liked Entries of Yesterday) to kindle every day via Github Actions.

debe to kindle Mini Tool to lovers of debe from eksisozluk (one of the most famous website -refered as collaborative dictionary like reddit- in Turkey

11 Oct 11, 2022
A Discord bot to allow people to create lists of random characters, with limit reroll options.

Mugen Bot A small bot I made to practice python and allow people to publically select random characters on a discord server. Uses py-cord, as that is

Haley 2 Feb 06, 2022
Simple Telegram bot to confess to your crush this Valentine's Day

Simple Telegram bot to confess to your crush this Valentine's Day! Steps pip install python-telegram-bot Register a Telegram bot & get the token by fo

3 Mar 18, 2022
Web3 Pancakeswap Sniper & honeypot detector Take Profit/StopLose bot written in python3, For ANDROID WIN MAC & LINUX

🏆 Pancakeswap BSC Sniper Bot web3 with honeypot detector (ANDROID WINDOWS MAC LINUX) 🥇 ⭐️ ⭐️ ⭐️ First SNIPER BOT for ANDROID & WINDOWS with honeypot

HYDRA 2 Dec 24, 2021
A Telegram Video Merge Bot by @AbirHasan2005

VideoMerge-Bot This is very simple Telegram Videos Merge Bot by @AbirHasan2005. Using FFmpeg for Merging Videos. Features: Merge Multiple Videos. User

Abir Hasan 57 Nov 12, 2022
❤️ DaisyX 2.0 ❤️ A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon...

❤️ DaisyX 2.0 ❤️ A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon... ⭐️ Thanks to everyone who starred Dais

TeamOfDaisyX 44 Oct 06, 2022
Based on falcondai and fenhl's Python snowflake tool, but with documentation and simliarities to Discord.

python-snowflake-2 Based on falcondai and fenhl's Python snowflake tool, but with documentation and simliarities to Discord. Docs make_snowflake This

2 Mar 19, 2022
JAWS Pankration 2021 - DDD on AWS Lambda sample

JAWS Pankration 2021 - DDD on AWS Lambda sample What is this project? This project contains sample code for AWS Lambda with domain models. I presented

Atsushi Fukui 21 Mar 30, 2022