JSPM

@emo-eth/create2-clones-with-immutable-args

0.1.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • 0
    • Score
      100M100P100Q33376F
    • License BSD

    Factory for deploying clones with immutable parameters to deterministic addresses.

    Package Exports

      This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@emo-eth/create2-clones-with-immutable-args) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

      Readme

      Create2ClonesWithImmutableArgs

      Enables creating clone contracts with immutable arguments to deterministic addresses.

      The immutable arguments are stored in the code region of the created proxy contract, and whenever the proxy is called, it reads the arguments into memory, and then appends them to the calldata of the delegate call to the implementation contract. The implementation contract can thus read the arguments straight from calldata.

      By doing so, the gas cost of creating parametrizable clones is reduced, since there's no need to store the parameters in storage, which you need to do with EIP-1167. The cost of using such clones is also reduced, since storage loads are replaced with calldata reading, which is far cheaper.

      In other word, if you know you are not gonna need parametrization and just want exact copies, then you can keep using EIP-1167, otherwise, clones-with-immutables is cheaper.

      Usage

      Clone factory contracts should use the Create2ClonesWithImmutableArgs library. Create2ClonesWithImmutableArgs.clone() is the main function for creating clones.

      Contracts intended to be cloned should inherit from Clone to get access to the helper functions for reading immutable args.

      To see an example usage of the library, check out ExampleClone and ExampleCloneFactory.

      Installation

      To install with DappTools:

      dapp install jameswenzel/clones-with-immutable-args

      To install with Foundry:

      forge install jameswenzel/clones-with-immutable-args

      To install with Hardhat:

      coming soon? :)

      Local development

      This project uses Foundry as the development framework.

      Dependencies

      make update

      Compilation

      make build

      Testing

      make test