GithubHelp home page GithubHelp logo

isabella232 / module-factory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gnosis/module-factory

0.0 0.0 0.0 504 KB

A factory for gnosis safe modules, deployed as minimal proxies.

Solidity 9.16% TypeScript 81.61% JavaScript 6.38% Shell 2.85%

module-factory's Introduction

Module Factory

Build Status Coverage Status

The purpose of the Module Factory repository is to make the deployment of Safe Modules easier. Applying the Minimal Proxy Pattern, this module reduces the gas cost and simplifies the track of deployed modules. The Minimal Proxy Pattern has been used because the modules do not need to be upgradeable since a safe can deploy a new one. It's worth mentioning that it costs roughly 5k additional gas for each transaction when using a proxy. Thus, after a certain number of transactions (~700) it would likely be cheaper to deploy the module from the constructor rather than the proxy.

There's also a JS API, allowing the developers to interact with the ProxyFactory Contract more easily. You can check the factory file to see more details, it consists of 4 methods, described individually in the following sections:

1. Deploy and set up module

  • Interface: deployAndSetUpModule(moduleName, args, provider, chainId)
  • Arguments:
    • moduleName: Name of the module to be deployed, note that it needs to exist as a key in the CONTRACT_ADDRESSES object
    • args: Arguments of the setUp function of the module to deploy
    • provider: Ethereum provider, expects an instance of JsonRpcProvider from ethers
    • chainId: Number of network to interact with
  • Returns: An object with the transaction built in order to be executed by the Safe, and the expected address of the new module, this will allow developers to batch the transaction of deployment + enable module on safe. Example:
{
  "transaction": {
    "data": "0x",
    "to": "0x",
    "value": "0x"
  },
  "expectedModuleAddress": "0x"
}

2. Calculate new module address

  • Interface: calculateProxyAddress(factory, masterCopy, initData)
  • Arguments:
    • factory: Address of the Module Proxy Factory contract
    • masterCopy: Address of the Master Copy of the Module
    • initData: Encoded function data that is used to set up the module
  • Returns: A string with the expected address

3. Get Module

  • Interface: getModuleInstance(moduleName, address, provider)

  • Arguments:

    • moduleName: Name of the module to be deployed, note that it needs to exist as a key in the CONTRACT_ADDRESSES object
    • address: Address of the Module contract
    • provider: Ethereum provider, expects an instance of JsonRpcProvider from ethers
  • Returns: A Contract instance of the Module

4. Get Factory and Master Copy

  • Interface: getFactoryAndMasterCopy(moduleName, provider, chainId)
  • Arguments:
    • moduleName: Name of the module to be deployed, note that it needs to exist as a key in the CONTRACT_ADDRESSES object
    • provider: Ethereum provider, expects an instance of JsonRpcProvider from ethers
    • chainId: Number of network to interact with
  • Returns: An object with the the factory contract instance and with the module contracts instance. Example:
{
    "factory": Contract,
    "module": Contract,
}

Deployments

The latest deployments for each network (supported on mainnet and rinkeby) can be found in the constants file

module-factory's People

Contributors

auryn-macmillan avatar bh2smith avatar carlosfebres avatar cbrzn avatar

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.