# Overview
Account plugin for the [Safe](https://safe.global/) multisig wallet (previously known as Gnosis Safe) for the [Ape Framework](https://github.com/ApeWorX/ape).
## Features
- **Safe Account Management**: Add, list, and remove Safe multisig wallets
- **Transaction Management**: Create, propose, sign, and execute Safe transactions
- **Multisig Workflows**: Manage transaction approval workflows with multiple signers
- **MultiSend Support**: Batch multiple transactions together efficiently
- **CLI Interface**: Comprehensive command line tools for Safe management
- **Python API**: Programmatic access to all Safe functionality
## Dependencies
- [python3](https://www.python.org/downloads) version 3.9 or newer
## Installation
### via `ape`
You can install using the [ape](https://github.com/ApeWorX/ape) built-in plugin manager:
```bash
$ ape plugins install safe
```
### via `pip`
You can install the latest release via [`pip`](https://pypi.org/project/pip/):
```bash
$ pip install ape-safe
```
You can also install from source:
```shell
# Clone the source code.
git clone git@github.com:ApeWorX/ape-safe.git
cd ape-safe
# Build the Safe manifests.
ape pm compile
ape run build
# Install.
pip install .
```
### via `setuptools`
You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:
```bash
$ git clone https://github.com/ApeWorX/ape-safe.git
$ cd ape-safe
$ python3 setup.py install
```
## Quick Usage
To use the plugin, first use the Ape CLI extension to add a safe you want to control:
```sh
# ape safe add ADDRESS ALIAS
ape safe add --network ethereum:mainnet my-safe.eth my-safe
```
If you made a mistake or just need to remove the safe, use the `remove` command:
```sh
# ape safe remove ALIAS
ape safe remove my-safe --yes
```
```{note}
`--yes` is a way to skip the prompt.
```
If you only have one safe, you will not have to specify which safe to use other commands.
Otherwise, for most `pending` commands, you specify the safe to use (by alias) via the `--safe` option.
Additionally, you can configure a safe to use as the default when no `--safe` argument is present by configuring the following in your `ape-config.yaml` file:
```yaml
safe:
default_safe: my-safe
```
or via `pyproject.toml`:
```toml
[tool.ape.safe]
default_safe = "my-safe"
```
or specify via environment variable:
```sh
export APE_SAFE_DEFAULT_SAFE="my-safe"
```
```{note}
To avoid always needing to specify `--network`, you can set a default ecosystem, network, and provider in your config file.
The rest of the guide will not specify `--network` on each command but assume it matches the network your Safe is on.
```
Once you have a safe, you can view pending transactions:
```sh
ape safe pending list
```
```{note}
You must specify the environment variable `APE_SAFE_GATEWAY_API_KEY=` to use the Safe Gateway API.
Get an API key at the [Safe Developer Portal](https://developer.safe.global).
```
It should show transactions like this:
```sh
Transaction 8 rejection (1/2) safe_tx_hash=0x09ab...a9a7
Transaction 8 transfer (1/2) safe_tx_hash=0xed43...0a5b
```
Use the `--verbose` flag to see more information about each transaction:
```sh
ape safe pending list --verbose
```
There are several operations you can do on a pending transaction:
```sh
# Add more signatures using locally-configured Ape signer(s)
# NOTE: can specify either SafeTxID or Nonce
ape safe pending approve 0x09ab...a9a7
# Add remaining signatures and execute transction w/ account alias `submitter`
# NOTE: can specify either SafeTxID or Nonce
ape safe pending approve 2 --execute submitter
# Execute an already-signed transaction using `submitter`
ape safe pending execute 2 --account submitter
# Create an on-chain rejection for an existing transaction queue item
ape safe pending reject 2
```
### MultiSend Support
Ape Safe allows sending "batched transactions" using the `MultiSend` module:
```python
from ape import accounts
from ape_safe import multisend
from ape_tokens import tokens
me = accounts.load("my-key")
safe = accounts.load("my-safe")
# Load some contracts using ape-tokens
dai = tokens["DAI"]
vault = tokens["yvDAI"]
amount = dai.balanceOf(safe) # How much we want to deposit
# Create a multisend batch transaction
batch = safe.create_batch()
batch.add(dai.approve, vault, amount)
batch.add(vault.deposit, amount)
# Fetch signatures from local signer(s)
# NOTE: will broadcast unless `submit=False`
batch(submitter=me)
# OR add to the Safe Gateway for later execution
batch.propose()
```
### Cloud Environment
To use this plugin in a cloud environment, such as with the [Silverback Platform](https://silverback.apeworx.io), you will need to make sure that you have configured your Safe to exist within the environment.
The easiest way to do this is to use the `require` configuration item.
To specify a required Safe in your `ape-config.yaml` (which adds it into your `~/.ape/safe` folder if it doesn't exist), use:
```yaml
safe:
require:
my-safe:
address: "0x1234...AbCd"
deployed_chain_ids: [1, 10] # Add all deployed chains here
```
or in `pyproject.toml`:
```toml
[tool.ape.safe.require."my-safe"]
address = "0x1234...AbCd"
deployed_chain_ids = [1, 10] # Add all deployed chains here
```
To specify via environment variable, do:
```sh
APE_SAFE_REQUIRE='{"my-safe":{"address":"0x1234...AbCd","deployed_chain_ids":[1,...]}}'
```
```{note}
If a safe with the same alias as an entry in `require` exists in your local environment, this will skip adding it, even if the existing alias points to a different address than the one in the config item.
```
## Development
Please see the [contributing guide](CONTRIBUTING.md) to learn more how to contribute to this project.
Comments, questions, criticisms and pull requests are welcomed.
## Acknowledgements
This package was inspired by the original ape-safe, now [brownie-safe](https://github.com/banteg/brownie-safe) by [banteg](https://github.com/banteg).
For versions prior to v0.6.0, the original package should be referenced.
Raw data
{
"_id": null,
"home_page": "https://github.com/ApeWorX/ape-safe",
"name": "ape-safe",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": "ethereum",
"author": "ApeWorX Ltd.",
"author_email": "admin@apeworx.io",
"download_url": "https://files.pythonhosted.org/packages/01/f5/60f2da8621a76f69ba83564f2a7b998df34f43eda0e4e8bd0e4324303c55/ape_safe-0.8.18.tar.gz",
"platform": null,
"description": "# Overview\n\nAccount plugin for the [Safe](https://safe.global/) multisig wallet (previously known as Gnosis Safe) for the [Ape Framework](https://github.com/ApeWorX/ape).\n\n## Features\n\n- **Safe Account Management**: Add, list, and remove Safe multisig wallets\n- **Transaction Management**: Create, propose, sign, and execute Safe transactions\n- **Multisig Workflows**: Manage transaction approval workflows with multiple signers\n- **MultiSend Support**: Batch multiple transactions together efficiently\n- **CLI Interface**: Comprehensive command line tools for Safe management\n- **Python API**: Programmatic access to all Safe functionality\n\n## Dependencies\n\n- [python3](https://www.python.org/downloads) version 3.9 or newer\n\n## Installation\n\n### via `ape`\n\nYou can install using the [ape](https://github.com/ApeWorX/ape) built-in plugin manager:\n\n```bash\n$ ape plugins install safe\n```\n\n### via `pip`\n\nYou can install the latest release via [`pip`](https://pypi.org/project/pip/):\n\n```bash\n$ pip install ape-safe\n```\n\nYou can also install from source:\n\n```shell\n# Clone the source code.\ngit clone git@github.com:ApeWorX/ape-safe.git\ncd ape-safe\n\n# Build the Safe manifests.\nape pm compile\nape run build\n\n# Install.\npip install .\n```\n\n### via `setuptools`\n\nYou can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:\n\n```bash\n$ git clone https://github.com/ApeWorX/ape-safe.git\n$ cd ape-safe\n$ python3 setup.py install\n```\n\n## Quick Usage\n\nTo use the plugin, first use the Ape CLI extension to add a safe you want to control:\n\n```sh\n# ape safe add ADDRESS ALIAS\nape safe add --network ethereum:mainnet my-safe.eth my-safe\n```\n\nIf you made a mistake or just need to remove the safe, use the `remove` command:\n\n```sh\n# ape safe remove ALIAS\nape safe remove my-safe --yes\n```\n\n```{note}\n`--yes` is a way to skip the prompt.\n```\n\nIf you only have one safe, you will not have to specify which safe to use other commands.\nOtherwise, for most `pending` commands, you specify the safe to use (by alias) via the `--safe` option.\n\nAdditionally, you can configure a safe to use as the default when no `--safe` argument is present by configuring the following in your `ape-config.yaml` file:\n\n```yaml\nsafe:\n default_safe: my-safe\n```\n\nor via `pyproject.toml`:\n\n```toml\n[tool.ape.safe]\ndefault_safe = \"my-safe\"\n```\n\nor specify via environment variable:\n\n```sh\nexport APE_SAFE_DEFAULT_SAFE=\"my-safe\"\n```\n\n```{note}\nTo avoid always needing to specify `--network`, you can set a default ecosystem, network, and provider in your config file.\nThe rest of the guide will not specify `--network` on each command but assume it matches the network your Safe is on.\n```\n\nOnce you have a safe, you can view pending transactions:\n\n```sh\nape safe pending list\n```\n\n```{note}\nYou must specify the environment variable `APE_SAFE_GATEWAY_API_KEY=` to use the Safe Gateway API.\nGet an API key at the [Safe Developer Portal](https://developer.safe.global).\n```\n\nIt should show transactions like this:\n\n```sh\nTransaction 8 rejection (1/2) safe_tx_hash=0x09ab...a9a7\nTransaction 8 transfer (1/2) safe_tx_hash=0xed43...0a5b\n```\n\nUse the `--verbose` flag to see more information about each transaction:\n\n```sh\nape safe pending list --verbose\n```\n\nThere are several operations you can do on a pending transaction:\n\n```sh\n# Add more signatures using locally-configured Ape signer(s)\n# NOTE: can specify either SafeTxID or Nonce\nape safe pending approve 0x09ab...a9a7\n\n# Add remaining signatures and execute transction w/ account alias `submitter`\n# NOTE: can specify either SafeTxID or Nonce\nape safe pending approve 2 --execute submitter\n\n# Execute an already-signed transaction using `submitter`\nape safe pending execute 2 --account submitter\n\n# Create an on-chain rejection for an existing transaction queue item\nape safe pending reject 2\n```\n\n### MultiSend Support\n\nApe Safe allows sending \"batched transactions\" using the `MultiSend` module:\n\n```python\nfrom ape import accounts\nfrom ape_safe import multisend\nfrom ape_tokens import tokens\n\nme = accounts.load(\"my-key\")\nsafe = accounts.load(\"my-safe\")\n\n# Load some contracts using ape-tokens\ndai = tokens[\"DAI\"]\nvault = tokens[\"yvDAI\"]\namount = dai.balanceOf(safe) # How much we want to deposit\n\n# Create a multisend batch transaction\nbatch = safe.create_batch()\nbatch.add(dai.approve, vault, amount)\nbatch.add(vault.deposit, amount)\n\n# Fetch signatures from local signer(s)\n# NOTE: will broadcast unless `submit=False`\nbatch(submitter=me)\n# OR add to the Safe Gateway for later execution\nbatch.propose()\n```\n\n### Cloud Environment\n\nTo use this plugin in a cloud environment, such as with the [Silverback Platform](https://silverback.apeworx.io), you will need to make sure that you have configured your Safe to exist within the environment.\nThe easiest way to do this is to use the `require` configuration item.\nTo specify a required Safe in your `ape-config.yaml` (which adds it into your `~/.ape/safe` folder if it doesn't exist), use:\n\n```yaml\nsafe:\n require:\n my-safe:\n address: \"0x1234...AbCd\"\n deployed_chain_ids: [1, 10] # Add all deployed chains here\n```\n\nor in `pyproject.toml`:\n\n```toml\n[tool.ape.safe.require.\"my-safe\"]\naddress = \"0x1234...AbCd\"\ndeployed_chain_ids = [1, 10] # Add all deployed chains here\n```\n\nTo specify via environment variable, do:\n\n```sh\nAPE_SAFE_REQUIRE='{\"my-safe\":{\"address\":\"0x1234...AbCd\",\"deployed_chain_ids\":[1,...]}}'\n```\n\n```{note}\nIf a safe with the same alias as an entry in `require` exists in your local environment, this will skip adding it, even if the existing alias points to a different address than the one in the config item.\n```\n\n## Development\n\nPlease see the [contributing guide](CONTRIBUTING.md) to learn more how to contribute to this project.\nComments, questions, criticisms and pull requests are welcomed.\n\n## Acknowledgements\n\nThis package was inspired by the original ape-safe, now [brownie-safe](https://github.com/banteg/brownie-safe) by [banteg](https://github.com/banteg).\nFor versions prior to v0.6.0, the original package should be referenced.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "ape-safe: Gnosis Safe account plugin for Ape",
"version": "0.8.18",
"project_urls": {
"Homepage": "https://github.com/ApeWorX/ape-safe"
},
"split_keywords": [
"ethereum"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "10d333d65fa6d6088862018f58877cb33368eec11852eea0081b04943f5008c5",
"md5": "6ae939a218235b84c6793c022db7fb6e",
"sha256": "9a21162cf3a6107928b84ecd2638543dd6aeb36e605374dba13cc1af760d4f5d"
},
"downloads": -1,
"filename": "ape_safe-0.8.18-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6ae939a218235b84c6793c022db7fb6e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 241246,
"upload_time": "2025-10-30T19:32:34",
"upload_time_iso_8601": "2025-10-30T19:32:34.078308Z",
"url": "https://files.pythonhosted.org/packages/10/d3/33d65fa6d6088862018f58877cb33368eec11852eea0081b04943f5008c5/ape_safe-0.8.18-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "01f560f2da8621a76f69ba83564f2a7b998df34f43eda0e4e8bd0e4324303c55",
"md5": "c0a16e3891c4320293d1459678c25669",
"sha256": "b0f309202f2b06e81759d1cb7ec22713a913df2e7cfd8b8215df3d542401a0e0"
},
"downloads": -1,
"filename": "ape_safe-0.8.18.tar.gz",
"has_sig": false,
"md5_digest": "c0a16e3891c4320293d1459678c25669",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 306804,
"upload_time": "2025-10-30T19:32:35",
"upload_time_iso_8601": "2025-10-30T19:32:35.543959Z",
"url": "https://files.pythonhosted.org/packages/01/f5/60f2da8621a76f69ba83564f2a7b998df34f43eda0e4e8bd0e4324303c55/ape_safe-0.8.18.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-30 19:32:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ApeWorX",
"github_project": "ape-safe",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ape-safe"
}