---
eip: 2470
label: ERC-2470
title: Singleton Factory
status: Stagnant
type: Standards Track
category: ERC
created: 2020-01-15
requires: 1014
official: https://eips.ethereum.org/EIPS/eip-2470
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-2470.md
canonical: https://eips.huatuo.xyz/eip-2470/
lang: en
tldr: A keyless, permissionless CREATE2 factory deployed at the same address on every chain, so any contract can be given the same deterministic address everywhere.
tags: [create2, factory, deployment, singleton, deterministic]
---

# ERC-2470: Singleton Factory

> Some DApps needs one, and only one, instance of an contract, which have the same address on any chain.

**TL;DR:** A keyless, permissionless CREATE2 factory deployed at the same address on every chain, so any contract can be given the same deterministic address everywhere.

## What problem does it solve?

Some contracts should exist exactly once, at the same address on every chain: registries like [ERC-1820](/eip-1820/), shared libraries, or wallet infrastructure. Deploying them with an ordinary account gives an address that depends on that account's nonce, which differs from chain to chain.

ERC-2470 proposes one shared **Singleton Factory**: a tiny contract that wraps [CREATE2](/eip-1014/). If the factory itself sits at the same address on every chain, then anything it deploys with the same init code and salt also lands at the same address everywhere.

## How it works

**The factory** has a single function:

```solidity
function deploy(bytes memory _initCode, bytes32 _salt) public returns (address payable createdContract);
```

It calls `create2(0, initCode, salt)`. No ETH can be forwarded, so the result depends only on the code and the salt.

**Getting the factory to the same address everywhere** uses *Nick's method* (keyless deployment):

1. A deployment transaction is built with nonce 0, a fixed 100 gwei gas price and a 247,000 gas limit, and **without** [EIP-155](/eip-155/) chain-ID protection so it is valid on any chain.
2. Its signature is not real: `r` and `s` are the human-chosen values `0x247000` and `0x2470`. Recovering the "sender" gives an account whose private key nobody can know.
3. Anyone funds that one-time sender with 0.0247 ETH and broadcasts the raw transaction. The factory appears at the same address on that chain, and since the sender's nonce is now used, no other code can ever be put there.

The spec publishes the raw transaction, the single-use sender `0xBb6e024b9cFFACB947A71991E386681B1Cd1477D`, and the resulting factory address `0xce0042B868300000d44A59004Da54A005ffdcf9f`.

The address of anything deployed through it follows the CREATE2 rule:

```
address = keccak256(0xff ++ factory ++ salt ++ keccak256(initCode))[12:]
```

## Sample code

Predict and deploy through the factory (ethers v6):

```ts
import { Contract, Wallet, JsonRpcProvider, getCreate2Address, keccak256, ZeroHash } from "ethers";

const FACTORY = "0xce0042B868300000d44A59004Da54A005ffdcf9f";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const wallet = new Wallet(process.env.PRIVATE_KEY!, provider);

const initCode = "0x..."; // contract bytecode + ABI-encoded constructor args
const salt = ZeroHash;     // spec suggests zero salt unless you want a vanity address

const predicted = getCreate2Address(FACTORY, salt, keccak256(initCode));
console.log("will deploy to", predicted);

if ((await provider.getCode(predicted)) === "0x") {
  const factory = new Contract(FACTORY, ["function deploy(bytes,bytes32) returns (address)"], wallet);
  await (await factory.deploy(initCode, salt)).wait();
}
```

## Things to know

- Status is **Stagnant**. The idea is sound, but the factory must first be deployed on each chain by someone paying 0.0247 ETH to the one-time sender.
- Because the deploy transaction lacks EIP-155 protection and has a fixed gas price and gas limit, it can fail on chains or RPC nodes that reject unprotected transactions, or whose gas pricing differs. Check with `getCode` before relying on the factory on a given chain.
- Contracts deployed through it **must not use `msg.sender` in the constructor**: the factory would become their owner. Pass the owner as a constructor argument instead.
- Same address does not mean same state. A contract that must behave differently per chain can read the chain ID (`block.chainid`).
- Anyone can call `deploy`, so anyone can front-run your deployment with the same init code and salt. The result is identical code at the expected address, which is usually fine, but constructor arguments are part of the init code and are public.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2470
