Skip to content

Instantly share code, notes, and snippets.

@ademidun
Last active January 6, 2023 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ademidun/2ac5173f84e57484f5187d23198cc1c1 to your computer and use it in GitHub Desktop.
Save ademidun/2ac5173f84e57484f5187d23198cc1c1 to your computer and use it in GitHub Desktop.
Different Ways to Create Safe Accounts

Different Ways to Create Safe Accounts

Bloomberg Businessweek famously said that businesses could receive payments on Stripe in 7 lines of code.

Now: anyone can receive payments on Safe in 5 lines of code.

Command Line

Safe CLI: Python

pip3 install -U safe-cli
safe-cli <checksummed_safe_address> <ethereum_node_url>
load_cli_owners <account_private_key>
safe-creator <node_url> <private_key> --owners <checksummed_address_1> <checksummed_address_2>\
  --threshold <uint> --salt-nonce <uint256>
tx-service asign-tx <safe-tx-hash>
git clone https://github.com/5afe/safe-tasks
yarn install
cat "export PK=<YOUR_NODE_URL>" > .env
cat "export NODE_URL=<YOUR_NODE_URL>" > .env


yarn safe create
yarn safe propose <address> --to <target>
yarn safe sign-proposal <safeTxHash>
yarn safe submit-proposal <safeTxHash>
// yarn install ethers @safe-global/safe-core-sdk @safe-global/safe-ethers-lib
import { ethers } from 'ethers'
import Safe, { SafeFactory } from '@safe-global/safe-core-sdk'
import EthersAdapter from '@safe-global/safe-ethers-lib'

const provider = new ethers.providers.JsonRpcProvider("..."); //1
const signerWallet = new ethers.Wallet("<PRIVATE_KEY>", provider); //2
const ethAdapter = new EthersAdapter({ethers, signerOrProvider: signerWallet}); //3

const safeFactory = await SafeFactory.create({ ethAdapter }); //4
const safeSdk: Safe = await safeFactory.deploySafe({ safeAccountConfig: { threshold: 2, owners: ['0x...', '0x...', '0x..'] }}); //5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment