# create2_mine

Scans a bounded local CPU salt range for EIP-1014 CREATE2 addresses. It performs no network I/O, deployment, chain-state lookup, collision check, or vanity-address safety proof.

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

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

Scans a bounded local CPU salt range for EIP-1014 CREATE2 addresses. It performs no network I/O, deployment, chain-state lookup, collision check, or vanity-address safety proof.

## Overload 1: create2_mine(ADDRESS, BYTES32, BIGINT, BIGINT, ADDRESS, ADDRESS, BIGINT)

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

Applies bytewise `(address & mask) = (target & mask)` filtering and a positive result cap. The cap does not promise the lowest matching salts in a parallel scan.

- Kind: table
- Execution context: Offline
- Behavior: Capped Masked Create2 Scan
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Bind Time Range
- Cardinality: Zero Or More
- Determinism: Conditional
- Return shape: Table
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Requirements

- bounded_non_negative_uint64_range

### Risks

- cpu_bound_scan
- host_parallelism
- collision_not_checked
- capped_subset

### 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.
- `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.
- `salt_start` (BIGINT; required; positional) — Inclusive non-negative uint64-compatible BIGINT start; NULL defaults to 0.
- `salt_count` (BIGINT; required; positional) — Non-negative uint64-compatible BIGINT count defining `[start, start + count)`; NULL defaults to 100.
- `mask` (ADDRESS; required; positional) — 20-byte address mask selecting which output address bits must match.
- `target` (ADDRESS; required; positional) — 20-byte target; comparison uses only bits selected by mask.
- `max_results` (BIGINT; required; positional) — Positive result cap; NULL leaves 100 and zero errors.

### Result columns

CREATE2 address candidates

Returns deployer, UBIGINT salt, and predicted address sorted by salt. `salt_start` is inclusive and `salt_count` defines `[start, start + count)`. A zero count returns no rows.

- `deployer` (ADDRESS) — Deployer address used in the CREATE2 formula
- `salt` (UBIGINT) — Integer salt in the scanned range, interpreted as a left-padded 32-byte salt
- `address` (ADDRESS) — Predicted CREATE2 address for deployer, salt, and init_hash

CREATE2 address candidates. Returns deployer, UBIGINT salt, and predicted address sorted by salt. `salt_start` is inclusive and `salt_count` defines `[start, start + count)`. A zero count returns no rows.

### Examples

_Local SQL · Local_

```sql
-- First salt in 0..255 whose address ends in 0x38
SELECT salt, address::VARCHAR AS address
FROM create2_mine(
  '0x0000000000000000000000000000000000000000'::ADDRESS,
  keccak256('0x00'::BYTES),
  0::BIGINT,
  256::BIGINT,
  '0x00000000000000000000000000000000000000ff'::ADDRESS,
  '0x0000000000000000000000000000000000000038'::ADDRESS,
  1::BIGINT
);
-- => [{"salt":"0","address":"0x4d1a2e2bb4f88f0250f26ffff098b0b30b26bf38"}]
```

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

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

Scans a contiguous salt range and emits one row per salt in that window for post-processing in SQL.

- Kind: table
- Execution context: Offline
- Behavior: Complete Create2 Range Scan
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Bind Time Range
- Cardinality: Zero Or More
- Determinism: Deterministic
- Return shape: Table
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Requirements

- bounded_non_negative_uint64_range

### Risks

- cpu_bound_scan
- host_parallelism
- collision_not_checked

### 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.
- `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.
- `salt_start` (BIGINT; required; positional) — Inclusive non-negative uint64-compatible BIGINT start; NULL defaults to 0.
- `salt_count` (BIGINT; required; positional) — Non-negative uint64-compatible BIGINT count defining `[start, start + count)`; NULL defaults to 100.

### Result columns

CREATE2 address candidates

Returns deployer, UBIGINT salt, and predicted address sorted by salt. `salt_start` is inclusive and `salt_count` defines `[start, start + count)`. A zero count returns no rows.

- `deployer` (ADDRESS) — Deployer address used in the CREATE2 formula
- `salt` (UBIGINT) — Integer salt in the scanned range, interpreted as a left-padded 32-byte salt
- `address` (ADDRESS) — Predicted CREATE2 address for deployer, salt, and init_hash

CREATE2 address candidates. Returns deployer, UBIGINT salt, and predicted address sorted by salt. `salt_start` is inclusive and `salt_count` defines `[start, start + count)`. A zero count returns no rows.

### Examples

_Local SQL · Local_

```sql
-- CREATE2 address for each salt in a one-salt range
SELECT salt, address::VARCHAR AS address
FROM create2_mine(
  '0x0000000000000000000000000000000000000000'::ADDRESS,
  keccak256('0x00'::BYTES),
  0::BIGINT,
  1::BIGINT
);
-- => [{"salt":"0","address":"0x4d1a2e2bb4f88f0250f26ffff098b0b30b26bf38"}]
```

## Guidance

### Range and parallelism

BIGINT start/count must convert to non-negative uint64 values; negatives error. Scans below 10,000 salts use one worker, while larger scans may use host parallelism.

- The basic overload emits every candidate.
- The extended predicate is bytewise `(address & mask) = (target & mask)`.
- `max_results` is a positive result cap, not a guarantee of the lowest matching salts.
- When parallel scans have more matches than the cap, scheduling can affect which matches survive before final sorting.

### NULL compatibility and boundary

Current compatibility behavior is intentionally retained: NULL deployer/init_hash errors; NULL `salt_start` defaults to 0; NULL `salt_count` defaults to 100. In the extended overload, a NULL mask or target disables filtering and also bypasses the supplied cap, leaving the default cap 100; NULL `max_results` also leaves cap 100.

- Mining is local CPU work only.
- It does not deploy, query chain state, test address collisions, or prove vanity-address safety.

## Related functions

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