Giter Site home page Giter Site logo

safe-singleton-factory's Introduction

Safe Singleton Factory

Singleton factory used by Safe-related contracts based on https://github.com/Arachnid/deterministic-deployment-proxy

The original library used a pre-signed transaction without a chain ID to allow deployment on different chains. Some chains do not allow such transactions to be submitted (e.g. Celo and Avalanche); therefore, this repository will provide the same factory that can be deployed via a pre-signed transaction that includes the chain ID. The key that is used to sign is controlled by the Safe team.

User documentation

Explanation (from Arachnid's repo)

This repository contains a simple contract that can deploy other contracts with a deterministic address on any chain using CREATE2. The CREATE2 call will deploy a contract (like CREATE opcode), but instead of the address being keccak256(rlp([deployer_address, nonce])) it instead uses the hash of the contract's bytecode and a salt. This means that a given deployer address will deploy the same code to the same address no matter when or where they issue the deployment. The deployer is deployed with a one-time-use account, so its address will always be the same no matter what chain the deployer is on. This means the only variables in determining your contract's address are its bytecode hash and the provided salt.

Between the use of CREATE2 opcode and the one-time-use account for the deployer, we can ensure that a given contract will exist at the exact same address on every chain, but without using the exact gas pricing or limits every time.

Encoding the deployment transaction

The data should be the 32 byte 'salt' followed by the init code.

How to get the singleton deployed to your network

As the singleton is deployed with an EIP155 transaction, we must sign the deployment transaction for your network. But some prerequisites must be met before that, and the most important one is having funds on the deployer so we can deploy the contract.

  1. Make sure your network is on https://chainlist.org/ . We will not accept networks not present there.
  2. Create an issue following the request for a new network template.
  3. Once the issue is created, the issue will be automatically validated, and a bot will post a comment with the address of the deployer and the amount of funds needed to deploy the contract.
  4. After you have sent the funds to the deployer, mark the checkbox on the issue, and the Safe team will sign the transaction and deploy the contract.

The Safe team will aim to respond to new network requests within two weeks.

Expected Addresses

For all networks, the same deployer key is used. The address for this key is 0xE1CB04A0fA36DdD16a06ea828007E35e1a3cBC37.

This results in the address for the factory being 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7 for all bytecode-compatible EVM networks.

For zkSync-based networks, the same deployer is used, and the expected factory address is 0xaECDbB0a3B1C6D1Fe1755866e330D82eC81fD4FD, and the factory is deployed using the create2 method of the system deployer using the zero hash (0x0000000000000000000000000000000000000000000000000000000000000000).

NPM Package release cycle

The Safe team will aim to release a new version of the package every two weeks.

Please note that the package is not required for the factory to work. The package is only a convenience for developers to use the factory. Most libraries that support deterministic deployments accept the factory address as a parameter, so you can use the factory without the package. For example, see the documentation for the deterministicDeployment option in the hardhat-deploy plugin.

Safe developers documentation

Adding new networks

To generate the deployment data for a new network, the following steps are necessary:

  • Set RPC in the .env file for the new network.
  • Set MNEMONIC in the .env file.
  • Estimate transaction params via yarn estimate
  • Run yarn compile <chain_id> [--gasPrice <overwrite_gas_price>] [--gasLimit <overwrite_gas_limit>]

To do the estimate and compile steps together:

  • Run yarn estimate-compile ["$RPC"]

To submit a transaction after the deployment data is created:

  • Run yarn submit

For zkSync-based networks

  • Set MNEMONIC or PK in the .env file
  • Run yarn compile:zk

safe-singleton-factory's People

Contributors

federava avatar mmv08 avatar nick8319 avatar rmeissner avatar robriks avatar uxio0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

safe-singleton-factory's Issues

Arbitrum on Gnosis Chain (AOX)

Website

AOX - https://www.xdaichain.com/for-developers/developer-resources/aox-arbitrum-on-xdai
OOX - https://www.xdaichain.com/for-developers/optimism-optimistic-rollups-on-gc

ChainId

200 - AOX
300 - OOX

Custom Request

Since AOX is a layer 2 it has different gas requirements. The required gas limit on AOX to do an ERC20 transfer is about 17x higher than on xDAI. For this reason I propose compiling and signing a deployment transaction with 25-50x the gas (gas is so cheep on AOX) to ensure that the proxy does not run out of gas. Same thing for OOX.

https://www.loom.com/share/c4aba98cc262412fa99772696c06b730

Clean up scripts

Currently there are a couple scripts that have doStuff as a name and are not very descriptive. This should be properly setup and made easily usable.

Add support for Godwoken Mainnet

Thank you guys for getting Godwoken Testnet support merged into Safe repositories including safe-deployments.

Godwoken Mainnet has just been released and now we want to give users ability to secure their MAINNET funds instead of just playing on testnet.

Website

https://docs.godwoken.io/

ChainId

Network Name: Godwoken Mainnet v1
RPC URL: https://v1.mainnet.godwoken.io/rpc
Block Explorer: https://v1.gwscan.com or https://gw-mainnet-explorer.nervosdao.community/ (Blockscout)
Chain ID: 71402

https://chainlist.org/chain/71402

Additional information

I sent 1400 native tokens to signer account (0xE1CB04A0fA36DdD16a06ea828007E35e1a3cBC37). Ready to use. : )

Recommended gas price: 40000000000000 (or if rejected please use whatever eth_gasPrice returns)

cc @rmeissner

Add support for Boba/Avax and Boba/BNB Mainnet and Testnet

Website

Boba/Avax: https://docs.boba.network/for-developers/network-avalanche
Boba/BNB: https://docs.boba.network/for-developers/network-bnb

ChainId

Boba/Avax Testnet: 4328
Boba/Avax Mainnet: 43288

Boba/BNB Testnet: 9728
Boba/BNB Mainnet: 56288

RPC

Boba/Avax Testnet: https://testnet.avax.boba.network/
Boba/Avax Mainnet: https://replica.avax.boba.network/

Boba/BNB Testnet: https://testnet.bnb.boba.network/
Boba/BNB Mainnet: https://replica.bnb.boba.network/

Add support for Acala & Karura mainnets and testnet

Website

https://evmdocs.acala.network/

ChainId

Mandala TC7 (Public testnet): 595
Karura: 686
Acala: 787

RPC endpoints

Mandala TC7 (Public testnet): https://tc7-eth.aca-dev.network
Karura: https://eth-rpc-karura.aca-api.network/
Acala: https://eth-rpc-acala.aca-api.network/

Additional Info

In order to deploy contracts, a substrate account with a developer role should be linked to an EVM-account, as described here - https://evmdocs.acala.network/tooling/development-account

Gas parameters

Gas parameters shall be calculated prior deployment as described here - https://evmdocs.acala.network/network/gas-parameters
Default gas parameters should be ok and can be fetched with
curl https://tc7-eth.aca-dev.network -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getEthGas","params": [], "id": 1}'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.