Command Palette

Search for a command to run...

Docs
Create2

A utility for predicting deterministic contract addresses using CREATE2 deployment.

Installation

pnpm dlx shadcn@latest add "https://ui.ednesdayw.com/r/create2.json"

Usage

import { predictDeterministicAddress } from "@/lib/create2";
 
// Predict a deterministic contract address
const predictedAddress = predictDeterministicAddress({
  implementation: "0x47deB22A87D12c8BE5F638AFC7DE48b52968205b",
  deployer: "0x6a569215be90A55B4c615368fCB13F75d99c8A60",
  salt: "my-unique-salt",
});
 
console.log(predictedAddress);
// Output: 0x... (predicted contract address)

API

predictDeterministicAddress

Predicts the deterministic address for a contract deployed using CREATE2 with minimal proxy pattern (EIP-1167).

predictDeterministicAddress(params: Create2PredictAddressParams): `0x${string}`
Parameters
  • params - An object containing:
    • implementation - The implementation contract address (0x${string})
    • deployer - The deployer contract address (0x${string})
    • salt - A unique string salt (max 32 characters) used for address generation
Returns

0x${string} - Returns the predicted deterministic contract address.

Errors
  • Throws if the implementation address is invalid
  • Throws if the deployer address is invalid
  • Throws if the salt exceeds 32 characters

How it works

This utility implements the CREATE2 address prediction algorithm using the minimal proxy pattern (EIP-1167). The minimal proxy is a standardized bytecode pattern that delegates all calls to an implementation contract, allowing for gas-efficient contract deployments.

The address is calculated by:

  1. Constructing the minimal proxy bytecode with the implementation address
  2. Combining it with the deployer address and salt
  3. Computing the keccak256 hash of the encoded parameters
  4. Extracting the last 20 bytes as the predicted address

Example

Create2 Address
Predict the address of the contract using the implementation, deployer, and salt