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
Based on nonebot, a common bot framework for maimai.

mai bot 使用指南 此 README 提供了最低程度的 mai bot 教程与支持。 Step 1. 安装 Python 请自行前往 https://www.python.org/ 下载 Python 3 版本( 3.7)并将其添加到环境变量(在安装过程中勾选 Add to system P

Diving-Fish 150 Jan 01, 2023
An all-purpose Discord bot written in Python featuring a diverse collection of practical utilities.

GlazeGlopBot Table of Contents About Setup Usage Commands Command Errors Cog Management Local Sound Files Cogs Mod QR RNG VC Weather Proposed Features

Edison Ye 0 May 12, 2022
Python: Asynchronous client for the Tailscale API

Python: Asynchronous client for the Tailscale API Asynchronous client for the Tailscale API. About This package allows you to control and monitor Tail

Franck Nijhof 9 Nov 22, 2022
A Open source Discord Token Grabber with several very useful features coded in python 3.9

Kiwee-Grabber A Open source Discord Token Grabber with several very useful features coded in python 3.9 This only works on any python 3.9 versions. re

Vesper 40 Jan 01, 2023
inventory replenishment for a hospital.

Inventory-Replenishment Inventory-Replenishment for a hospital that would like to explore how advanced anlytics may help automate their decision proce

1 Jan 09, 2022
This project checks the weather in the next 12 hours and sends an SMS to your phone number if it's going to rain to remind you to take your umbrella.

RainAlert-Request-Twilio This project checks the weather in the next 12 hours and sends an SMS to your phone number if it's going to rain to remind yo

9 Apr 15, 2022
A discord program that will send a message to nearly every user in a discord server

Discord Mass DM Scrapes users from a discord server to promote/mass dm Report Bug · Request Feature Features Asynchronous Easy to use Free Auto scrape

dropout 56 Jan 02, 2023
A python oriented telegram with API of yobit.net

YoBit-BTC A python oriented telegram bot with API of https://yobit.net/ Developed By @riz4d What is Yobit? ➪ YoBit is a cryptocurrency exchange that w

Muhammed Rizad 6 Apr 02, 2022
Python script to decode the EU Covid-19 vaccine certificate

vacdec Python script to decode the EU Covid-19 vaccine certificate This script takes an image with a QR code of a vaccine certificate as the parameter

Hanno Böck 244 Nov 30, 2022
Aula-API - a school system widely used in Denmark, as you can see and read about in the python file

Information : Hello, thank you for reading this first of all. This is a Aula-API

Binary.club 2 May 28, 2022
Please Do Not Throw Sausage Pizza Away - Side Scrolling Up The OSI Stack

Please Do Not Throw Sausage Pizza Away - Side Scrolling Up The OSI Stack

John Capobianco 2 Jan 25, 2022
Python library for Spurwing API to schedule appointments, manage calendars and custom integrations.

Spurwing API Python Library Lightweight Python library for Spurwing's API. Spurwing's API makes it easy to add robust scheduling and booking to your a

Spurwing 1 Jul 14, 2021
A simple Python wrapper for the archive.is capturing service

archiveis A simple Python wrapper for the archive.is capturing service. Installation pipenv install archiveis Python Usage Import it. import archi

Ben Welsh 157 Dec 28, 2022
Powerful and Async API for AnimeWorld.tv 🚀

Powerful and Async API for AnimeWorld.tv 🚀

1 Nov 13, 2021
A Python Library to interface with Flickr REST API, OAuth & JSON Responses

Python-Flickr Python-Flickr is A Python library to interface with Flickr REST API & OAuth Features Photo Uploading Retrieve user information Common Fl

Mike Helmick 40 Sep 25, 2021
Analyzed the data of VISA applicants to build a predictive model to facilitate the process of VISA approvals.

Analyzed the data of Visa applicants, built a predictive model to facilitate the process of visa approvals, and based on important factors that significantly influence the Visa status recommended a s

Jesus 1 Jan 08, 2022
A python library for anti-captcha.com

AntiCaptcha A python library for anti-captcha.com Documentation for the API Requirements git Install git clone https://github.com/ShayBox/AntiCaptcha.

Shayne Hartford 3 Dec 16, 2022
Send automated wishes to your contacts at scheduled time through WhatsApp. Written for Raspberry pi.

Whatsapp Automated Wishes Helps to send automated wishes to your contacts in Whatsapp at scheduled time using pywhatkit . Written for Raspberry pi. Wi

Uthayamurthy 2 Dec 13, 2022
The open source version of Tentro - A multipurpose Discord bot.

Welcome to Tentro 👋 A multipurpose Discord bot. 🏠 Homepage Install pip install -r requirements.txt Usage py Tentro.py Contributors 👤 Tentro Dev Tea

6 Jul 14, 2022
CSUL Discord Bot

Cruzeiro This is the same old bot running on the Discord Server of CSUL, but i've changed the code. It's better now. Discord.py Heroku How i did The b

Operaho 6 Jan 31, 2022