Package: canto-safe-cli
Safe-CLICommand line utility forGnosis Safecontracts. Use it to manage yourGnosis Safeeasily from the command lineInstallingPython >= 3.7is required.Python 3.10is recommended.pip3install-Usafe-cliUsingsafe-cli<checksummed_safe_address><ethereum_node_url>Then you should be on the prompt and see information about the Safe, like the owners, version, etc.
Next step would be loading some owners for the Safe. At leastthresholdowners need to be loaded to do operations
on the Safe and at least one of them should have funds for sending transactions.There're 3 operation modes:blockchain: The default mode, transactions are sent to blockchain.tx-service: Usetx-servicecommand to enable it. Transactions are sent to the Gnosis Transaction Service (if available on the network), so you will be able to see it on the Gnosis Safe web interface/mobile apps. At least one signer is needed to send transactions to the service. Txs arenot executed.relay-service: Userelay-service [optional-gas-token]to enable it. Sends transactions trough the Gnosis Relay Service (if available on the network). If a optional gas token is set, it will be used to send transactions. For mainnetyou can check available gas tokens here.Loading owners is not needed if you just want to doread-onlyoperations.To load owners:> load_cli_owners <account_private_key>
Loaded account 0xab...cd with balance=123 ether
Set account 0xab..cd as default sender of txsYou can also load owners from an environment variable. Before running thesafe-cli:exportMY_PRIVATE_KEY=YOUR_EOA_PRIVATE_KEYThen:> load_cli_owners MY_PRIVATE_KEY
Loaded account 0xab...cd with balance=123 ether
Set account 0xab..cd as default sender of txsTo check the loaded owners:> show_cli_ownersTo unload an owner:> unload_cli_owners <ethereum_checksummed_address>Operations currently supported:send_custom <address> <value-wei> <data-hex-str> [--delegate] [--safe-nonce <int>]:
Sends a custom transaction from the Gnosis Safe to a contract. If--delegateis set adelegatecallwill be triggered.send_ether <address> <value-wei> [--safe-nonce <int>]:
Sends ether from the Gnosis Safe to another accountsend_erc20 <address> <token_address> <value> [--safe-nonce <int>]:
Send ERC20 token from the Gnosis Safe to another accountapprove_hash <keccak-hexstr-hash> <sender-address>: Approves asafe-tx-hashfor the provided sender address.
Sender private key must be loaded first.add_owner <address>: Adds a new owneraddressto the Safe.remove_owner <address>: Removes an owneraddressfrom the Safe.change_threshold <integer>: Changes thethresholdof the Safe.enable_module <address>: Enable moduleaddressdisable_module <address>: Disable moduleaddresschange_fallback_handler <address>: Updates the fallback handler to beaddress. Supported by Safes withversion >= v1.1.0.WARNING: DON'T USE
THIS IF YOU DON'T KNOW WHAT YOU ARE DOING. ALL YOUR FUNDS COULD BE LOSTchange_guard <address>: Updates the guard to beaddress. Supported by Safes withversion >= v1.3.0.WARNING: DON'T USE
THIS IF YOU DON'T KNOW WHAT YOU ARE DOING. ALL YOUR FUNDS COULD BE LOSTchange_master_copy <address>: Updates the master copy to beaddress. It's used to update the Safe.WARNING: DON'T USE
THIS IF YOU DON'T KNOW WHAT YOU ARE DOING. ALL YOUR FUNDS COULD BE LOSTupdate: Updates the Safe to the latest version (if you are on a known network likeRinkebyorMainnet).WARNING: DON'T USE THIS IF YOU DON'T KNOW WHAT YOU ARE DOING. ALL YOUR FUNDS COULD BE LOSTOperations ontx-servicemode, requires a Gnosis Safe Transaction Service working on the network
(Mainnet, Gnosis Chain, Rinkeby, Polygon...):balances: Returns a list of balances for ERC20 tokens and ether.history: History of multisig transactions (including pending).execute-tx <safe-tx-hash>: Execute a pending tx with enough signatures.sign-tx <safe-tx-hash>: Sign a tx with the loaded owners for the providedSafeTxHash.batch-txs <safe-nonce> <safe-tx-hash> [ <safe-tx-hash> ... ]: Batch transactions into one Multisig
Transaction using the providedsafe-nonce.Any safe-tx can be used: transactions from other Safes, transactions
already executed, transactions pending for execution... Only limitation is thattransactions from other networks cannot be used. Batching order will follow the same order of thesafe-tx-hashesprovided.get_delegates: Returns a list of delegates for the Safe.add_delegate <address> <label> <signer-address>: Adds a new delegateaddressto the Safe.remove_delegate <address> <signer-address>: Removes a delegateaddressfrom the Safe.drain <address>: Sends all ether and ERC20 funds to the provided account.If the information in the information bar is outdated or there's any problem you can force thesafe-clito update
the information about the Safe using:> refreshCreating a new SafeUsesafe-creator <node_url> <private_key> --owners <checksummed_address_1> <checksummed_address_2> --threshold <uint> --salt-nonce <uint256>.Example:safe-creator https://rinkeby.infura.io/v3/token $PRIVATE_KEY --owners 0x848EF06Bb9d1bc79Bb3B04b7Ea0e251C6E788d7c --threshold 1DemoFor this demo,PRIVATE_KEYenvironment variable was set to aEOAprivate key (owner of a a previously created and outdated Safe)
andETHEREUM_NODE_URLto a http rinkeby node.
At first, Safe is updated to the last version and then123 Weiare sent to the owner of the Safe (it could be any other address).Don't useupdatecommand in mainnet, as it can leave your Gnosis Safe funds stuck. Safe CLI is still a betaUse custom contractsSafe-clicomes with the official Gnosis Safe contract addresses deployed on Mainnet, Rinkeby, Kovan and Goerli
configured by default. If you want to use your own you can edit the filecanto_safe_cli/safe_addresses.pyBe careful when modifying these addresses, the funds in a Safe can get stuck if an invalid address it's used when updating
to an invalid Safe Master Copy.Safe contractsSafe contractsSafe contracts deployment info and addresesSetting up for developingIf you miss something and want to send us a PR:gitclonehttps://github.com/gnosis/safe-cli.gitcdsafe-cli
statvenv2>/dev/null||python3-mvenvvenvsourcevenv/bin/activate&&pipinstall-rrequirements-dev.txt
pre-commitinstall-fContributorsPedro Arias RuizUxío Fuentefría(uxio@gnosis.io)