npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clones-with-immutable-args

v2.0.2

Published

Factory for deploying clones with immutable parameters.

Readme

clones-with-immutable-args

Enables creating clone contracts with immutable arguments.

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. An EIP-1167 clone shares its implementation's code, so its immutables are fixed when the implementation is deployed and cannot differ per clone: the only way to parametrize one is storage, which means paying to write the parameters at creation and to load them on every call. Here the parameters live in the clone's own code instead, so there is no storage write at creation, and reads are calldata reads.

Note the comparison is against a parametrized EIP-1167 clone, not against immutable variables on a regular contract. Solidity immutables are read from code and are already cheap, but they are the same for every clone of a given implementation, which is exactly what this library exists to work around.

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.

Status

This library is stable and maintained on demand: it is not under active feature development, but issues and security reports are addressed. The API is settled and in production use: no function signature has changed since 1.x, and none is planned to.

Note that the immutable args are appended to the calldata of every delegatecall, so an implementation inheriting Clone.sol reads them with a plain calldataload. This costs a small overhead on every call and makes arg reads very cheap. Other minimal-proxy libraries make different tradeoffs, including storing args in the runtime bytecode and reading them back with extcodecopy.

Compiler requirements

ClonesWithImmutableArgs.sol requires Solidity 0.8.13 or newer, because its inline assembly is annotated with the memory-safe dialect string, which lets the via-IR optimizer reason across those blocks.

Clone.sol still supports ^0.8.4. It is what a contract intended to be cloned inherits in order to read its immutable args, and it contains no assembly annotations, so implementations do not need a newer compiler than before. Only the factory side is affected.

If you are pinned below 0.8.13, use 1.2.0. It is the last release supporting ^0.8.4 throughout, and it contains the same fixes as 2.0.0.

Usage

Clone factory contracts should use the ClonesWithImmutableArgs library. ClonesWithImmutableArgs.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 wighawag/clones-with-immutable-args

To install with Foundry:

forge install wighawag/clones-with-immutable-args

To install with Hardhat:

npm i -D clones-with-immutable-args

Local development

This project uses Foundry as the development framework.

Dependencies

make update

Compilation

make build

Testing

make test