# create2_predict

Computes the EIP-1014 CREATE2 address from the executing deployer, exact salt, and complete init-code hash. This is deterministic local arithmetic and does not query or mutate chain state.

Canonical HTML: <https://determica.com/docs/functions/create2_predict>

- Kind: scalar function
- Category: [Development and bytecode](/docs/category/development-and-bytecode.md)
- Tags: CREATE2

Computes the EIP-1014 CREATE2 address from the executing deployer, exact salt, and complete init-code hash. This is deterministic local arithmetic and does not query or mutate chain state.

## Overload 1: create2_predict(ADDRESS, BYTES32, BYTES32)

```sql
create2_predict(ADDRESS, BYTES32, BYTES32)
```

Expects salt as exact BYTES32 and init_hash as keccak256(init_code).

- Kind: scalar
- Execution context: Offline
- Behavior: Create2 Prediction Exact Salt
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Risks

- collision_not_checked
- factory_behavior_not_proven
- deployment_not_attempted

### Inputs

- `deployer` (ADDRESS; required; positional) — Address that will execute CREATE2. For factory deployments, this is the factory address, not the future contract owner, transaction caller, or deployer key.
- `salt` (BYTES32; required; positional) — All 32 bytes are used exactly in the CREATE2 formula.
- `init_hash` (BYTES32; required; positional) — `keccak256(init_code)`, where complete init code is linked creation bytecode plus ABI-encoded constructor arguments. Runtime bytecode hashes are invalid substitutes.

### Returns

Predicted deployment address

Returns keccak256(0xff ++ deployer20 ++ salt32 ++ keccak256(init_code))[12:]. NULL or incorrectly sized raw blobs currently return NULL.

- `address` (ADDRESS)

Predicted deployment address. Returns keccak256(0xff ++ deployer20 ++ salt32 ++ keccak256(init_code))[12:]. NULL or incorrectly sized raw blobs currently return NULL.

### Examples

_Local SQL · Local_

```sql
-- CREATE2 address for a BYTES32 salt and init-code hash
SELECT create2_predict(
  '0x00000000000000000000000000000000deadbeef'::ADDRESS,
  '0x00000000000000000000000000000000000000000000000000000000cafebabe'::BYTES32,
  keccak256('0xdeadbeef'::BYTES)
)::VARCHAR AS address;
-- => [{"address":"0x60f3f640a8508fc6a86d45df051962668e1e8ac7"}]
```

## Overload 2: create2_predict(ADDRESS, BIGINT, BYTES32)

```sql
create2_predict(ADDRESS, BIGINT, BYTES32)
```

Converts the signed BIGINT to its lower unsigned 64 bits and left-pads those bytes to salt32. Negative values map modulo 2^64; use BYTES32 when exact or full-width salt bytes matter.

- Kind: scalar
- Execution context: Offline
- Behavior: Create2 Prediction Bigint Salt
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Risks

- collision_not_checked
- factory_behavior_not_proven
- deployment_not_attempted
- negative_salt_modulo_2_64

### Inputs

- `deployer` (ADDRESS; required; positional) — Address that will execute CREATE2. For factory deployments, this is the factory address, not the future contract owner, transaction caller, or deployer key.
- `salt` (BIGINT; required; positional) — Signed SQL BIGINT converted to its lower unsigned 64-bit representation and left-padded to 32 bytes. Negative values therefore map modulo 2^64; use BYTES32 for exact or full-width salts.
- `init_hash` (BYTES32; required; positional) — `keccak256(init_code)`, where complete init code is linked creation bytecode plus ABI-encoded constructor arguments. Runtime bytecode hashes are invalid substitutes.

### Returns

Predicted deployment address

Returns keccak256(0xff ++ deployer20 ++ salt32 ++ keccak256(init_code))[12:]. NULL or incorrectly sized raw blobs currently return NULL.

- `address` (ADDRESS)

Predicted deployment address. Returns keccak256(0xff ++ deployer20 ++ salt32 ++ keccak256(init_code))[12:]. NULL or incorrectly sized raw blobs currently return NULL.

### Examples

_Local SQL · Local_

```sql
-- CREATE2 address for numeric salt 0
SELECT create2_predict(
  '0x0000000000000000000000000000000000000000'::ADDRESS,
  0::BIGINT,
  keccak256('0x00'::BYTES)
)::VARCHAR AS address;
-- => [{"address":"0x4d1a2e2bb4f88f0250f26ffff098b0b30b26bf38"}]
```

## Guidance

### EIP-1014 inputs

The exact formula is `keccak256(0xff ++ deployer20 ++ salt32 ++ keccak256(init_code))[12:]`.

- The deployer is the account executing CREATE2, commonly a factory.
- Hash complete init code after constructor ABI encoding and library linking.
- Never substitute a runtime-bytecode hash.

### Boundary

Prediction is pure address arithmetic.

- It does not inspect chain state, detect collisions, prove factory behavior, deploy code, or guarantee successful initialization.

## Related functions

- [keccak256](/docs/functions/keccak256.md) — Usually After
- [create2_mine](/docs/functions/create2_mine.md) — Alternative
