Skip to main content

Command Line Interface for Safe

Project description

PyPI version Build Status Coverage Status Python 3.10 Python 3.11 Python 3.12 Python 3.13 Docker Image Version (latest semver)

Safe CLI

Safe CLI is a command-line utility for Safe contracts. You can use it to manage your Safe account from the command line.

It does not rely on Safe{Core} API and can also be used in networks where Safe services are unavailable. Learn more through the documentation.

Using Docker

Prerequisite: Install Docker Desktop.

Once Docker is installed on your system, run the following command to create new Safe accounts:

docker run -it safeglobal/safe-cli safe-creator

You can also run the following command to run the Safe CLI with an existing Safe:

docker run -it safeglobal/safe-cli safe-cli <checksummed_safe_address> <ethereum_node_url>

Using Python PIP

Prerequisite: Python >= 3.10 (Python 3.13 is recommended).

Once Python is installed on your system, run the following command to install Safe CLI:

pip3 install -U safe-cli

Usage

Safe-Cli

usage:
 safe-cli [--history] [--get-safes-from-owner] address node_url

 Examples:
 safe-cli 0x0000000000000000000000000000000000000000 https://sepolia.drpc.org
 safe-cli --get-safes-from-owner 0x0000000000000000000000000000000000000000 https://sepolia.drpc.org

 safe-cli --history 0x0000000000000000000000000000000000000000 https://sepolia.drpc.org
 safe-cli --history --get-safes-from-owner 0x0000000000000000000000000000000000000000 https://sepolia.drpc.org

 safe-cli send-ether 0xsafeaddress https://sepolia.drpc.org 0xtoaddress wei-amount --private-key key1 --private-key key2 --private-key keyN [--non-interactive]
 safe-cli send-erc721 0xsafeaddress https://sepolia.drpc.org 0xtoaddress 0xtokenaddres id --private-key key1 --private-key key2 --private-key keyN [--non-interactive]
 safe-cli send-erc20 0xsafeaddress https://sepolia.drpc.org 0xtoaddress 0xtokenaddres wei-amount --private-key key1 --private-key key2 --private-key keyN [--non-interactive]
 safe-cli send-custom 0xsafeaddress https://sepolia.drpc.org 0xtoaddress value 0xtxdata --private-key key1 --private-key key2 --private-key keyN [--non-interactive]

 safe-cli tx-builder 0xsafeaddress https://sepolia.drpc.org  ./path/to/exported/tx-builder/file.json --private-key key1 --private-key keyN [--non-interactive]

╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    address       CHECKSUMADDRESS  The address of the Safe, or an owner address if --get-safes-from-owner is specified. [required]                                                                                                                                                                             │
│ *    node_url      TEXT             Ethereum node url. [required]                                                                                                                                                                                                                                               │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                                                                                                                                                                                                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Optional Arguments ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --history                 --no-history                   Enable history. By default it's disabled due to security reasons [default: no-history]                                                                                                                                                                 │
│ --get-safes-from-owner    --no-get-safes-from-owner      Indicates that address is an owner (Safe Transaction Service is required for this feature) [default: no-get-safes-from-owner]                                                                                                                          │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

 Commands available in unattended mode:

 send-ether
 send-erc20
 send-erc721
 send-custom
 tx-builder
 version

 Use the --help option of each command to see the usage options.

To execute transactions unattended, or execute transactions from a json exported from the tx_builder you can use:

safe-cli send-ether 0xsafeaddress https://sepolia.drpc.org 0xtoaddress wei-amount --private-key key1 --private-key key1 --private-key keyN --non-interactive
safe-cli send-erc721 0xsafeaddress https://sepolia.drpc.org 0xtoaddress 0xtokenaddres id --private-key key1 --private-key key2 --private-key keyN --non-interactive
safe-cli send-erc20 0xsafeaddress https://sepolia.drpc.org 0xtoaddress 0xtokenaddres wei-amount --private-key key1 --private-key key2 --private-key keyN --non-interactive
safe-cli send-custom 0xsafeaddress https://sepolia.drpc.org 0xtoaddress value 0xtxdata --private-key key1 --private-key key2 --private-key keyN --non-interactive

safe-cli tx-builder 0xsafeaddress https://sepolia.drpc.org  ./path/to/exported/tx-builder/file.json --private-key key1 --private-key keyN --non-interactive

It is possible to use the environment variable SAFE_CLI_INTERACTIVE=0 to avoid user interactions. The --non-interactive option have more priority than environment variable.

Note: To use tx-service mode, set your API key as follows:

export SAFE_TRANSACTION_SERVICE_API_KEY=your_api_key_here

You can obtain your API key from https://developer.safe.global.

Safe-Creator

usage: safe-creator [-h] [-v] [--no-confirm] [--threshold THRESHOLD] [--owners OWNERS [OWNERS ...]] [--safe-contract SAFE_CONTRACT] [--proxy-factory PROXY_FACTORY] [--callback-handler CALLBACK_HANDLER] [--salt-nonce SALT_NONCE] [--without-events] [--generate-vanity-addresses] node_url private_key

Example: safe-creator https://sepolia.drpc.org 0000000000000000000000000000000000000000000000000000000000000000

positional arguments:
  node_url              Ethereum node url
  private_key           Deployer private_key

options:
  -h, --help            show this help message and exit
  -v, --version         Show program's version number and exit.
  --no-confirm          Bypass any and all “Yes or no?” messages
  --threshold THRESHOLD
                        Number of owners required to execute transactions on the created Safe. It mustbe greater than 0 and less or equal than the number of owners
  --owners OWNERS [OWNERS ...]
                        Owners. By default it will be just the deployer
  --safe-contract SAFE_CONTRACT
                        Use a custom Safe master copy
  --proxy-factory PROXY_FACTORY
                        Use a custom proxy factory
  --callback-handler CALLBACK_HANDLER
                        Use a custom fallback handler. It is not required for Safe Master Copies with version < 1.1.0
  --salt-nonce SALT_NONCE
                        Use a custom nonce for the deployment. Same nonce with same deployment configuration will lead to the same Safe address
  --without-events      Use non events deployment of the Safe instead of the regular one. Recommended for mainnet to save gas costs when using the Safe
  --generate-vanity-addresses
                        Don't deploy the Safe, only generate addresses

Generate vanity addresses

safe-creator https://sepolia.drpc.org $PRIVATE_KEY --generate-vanity-addresses --no-confirm

Safe{Core} API/Protocol

Setting up for developing

If you miss something and want to send us a PR:

git clone https://github.com/safe-global/safe-cli.git
cd safe-cli
stat venv 2>/dev/null || python3 -m venv venv
source venv/bin/activate && pip install -r requirements-dev.txt
pre-commit install -f

To run the local version you can install it using:

pip install .

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safe_cli-1.9.0.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safe_cli-1.9.0-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file safe_cli-1.9.0.tar.gz.

File metadata

  • Download URL: safe_cli-1.9.0.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for safe_cli-1.9.0.tar.gz
Algorithm Hash digest
SHA256 b100bd5cc1f676bc433d88d34a733e8cd697a9ea08b8ee66d6bf91af5600b019
MD5 7c74d9d66266a29705a114da7c363c39
BLAKE2b-256 e974151d92ef825285e507152e5c41106315301b38b744679e445ac6542fce2b

See more details on using hashes here.

File details

Details for the file safe_cli-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: safe_cli-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for safe_cli-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d110e1afeea29ca32af60b999805c660996f1015534494388fb14476d868ddf
MD5 796c09a9caf15d14e965bb174fcdc0ca
BLAKE2b-256 2d1a6ef5d1837c5b576752c7762618a9883c4a013c83fcf61a262e9002d0e25d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page