# clones-with-immutable-args

> Factory for deploying clones with immutable parameters.

Latest version **2.0.2** (published 2026-08-19) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install clones-with-immutable-args
pnpm add clones-with-immutable-args
yarn add clones-with-immutable-args
bun add clones-with-immutable-args
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2026-08-19 |
| First published | 2022-01-21 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 43.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 236 |
| Author | wighawag |
| Maintainers | wighawag |
| Keywords | solidity, ethereum, evm, smart-contracts, proxy, minimal-proxy, clone, eip-1167, immutable-args, create2, create3 |

## Links

- npm: https://www.npmjs.com/package/clones-with-immutable-args
- Repository: https://github.com/wighawag/clones-with-immutable-args
- Homepage: https://github.com/wighawag/clones-with-immutable-args#readme
- Issues: https://github.com/wighawag/clones-with-immutable-args/issues
- npm.io page: https://npm.io/package/clones-with-immutable-args

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2026-08-19
- 2.0.1 — 2026-08-19
- 2.0.0 — 2026-08-18
- 1.2.0 — 2026-08-18
- 1.1.2 — 2024-02-20
- 1.1.1 — 2024-01-17
- 1.1.0 — 2023-10-31
- 1.0.0 — 2022-01-21

## README

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wighawag/clones-with-immutable-args/master/assets/logo/cwia-wordmark-dark.svg">
    <img alt="clones with immutable args" src="https://raw.githubusercontent.com/wighawag/clones-with-immutable-args/master/assets/logo/cwia-wordmark.svg" width="420">
  </picture>
</p>

# 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](https://eips.ethereum.org/EIPS/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`](src/ClonesWithImmutableArgs.sol) library. `ClonesWithImmutableArgs.clone()` is the main function for creating clones.

Contracts intended to be cloned should inherit from [`Clone`](src/Clone.sol) to get access to the helper functions for reading immutable args.

To see an example usage of the library, check out [`ExampleClone`](src/ExampleClone.sol) and [`ExampleCloneFactory`](src/ExampleCloneFactory.sol).

## Installation

To install with [DappTools](https://github.com/dapphub/dapptools):

```
dapp install wighawag/clones-with-immutable-args
```

To install with [Foundry](https://github.com/gakonst/foundry):

```
forge install wighawag/clones-with-immutable-args
```

To install with [Hardhat](https://hardhat.org):

```
npm i -D clones-with-immutable-args
```

## Local development

This project uses [Foundry](https://github.com/gakonst/foundry) as the development framework.

### Dependencies

```
make update
```

### Compilation

```
make build
```

### Testing

```
make test
```

---
_Source: https://npm.io/package/clones-with-immutable-args · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
