Expand description
Bootstrap and use of the deterministic deployment factory.
An environment’s LibidFactory proxy lives at the same address on every
EVM network because every byte that feeds its address is frozen but one:
it is deployed through the canonical keyless CREATE2 deployer (Arachnid’s
deterministic-deployment proxy at CREATE2_DEPLOYER) with fixed salts
and init codes whose only input is the genesis admin, the environment’s
deployer key (FactoryGenesis), baked in so that initialization happens
atomically inside the deployment. Protocol proxies are then deployed
through the factory via CREATE3, which makes their addresses a function
of (factory, name) only — see solidity/contracts/factory/README.md.
FactoryGenesis::ensure is the whole bootstrap: check → install the
CREATE2 deployer if missing (via its well-known presigned transaction) →
deploy the factory impl and proxy at their canonical addresses. There is
deliberately no fallback deployment path: anything else would change the
factory address and defeat the cross-network guarantee, so a chain that
cannot take the presigned install transaction is a hard error.
Structs§
- Factory
Genesis - The factory of one environment, pinned by its genesis admin: the deployer key that owns the factory from its first block. The admin is the only varying input of the frozen proxy init code, so the factory’s address, and every address deployed through it, follow from the admin and nothing else. Testnet and mainnet have their own.
Constants§
- CREAT
E2_ DEPLOYER - Arachnid’s deterministic-deployment proxy — deployed from a keyless one-time account, so it has this address on every chain that has it. Calldata format: 32-byte salt ++ init code.
- CREAT
E2_ DEPLOYER_ FUNDING_ WEI - What the install transaction costs: 100 gwei gas price × 100 000 gas limit = 0.01 ETH. The keyless account can never refund the surplus, so fund it with exactly this.
- CREAT
E2_ DEPLOYER_ INSTALL_ TX - The canonical presigned transaction that installs the CREATE2 deployer.
- CREAT
E2_ DEPLOYER_ SIGNER - The keyless one-time account the presigned install transaction spends
from. It must hold the exact transaction cost (see
CREATE2_DEPLOYER_FUNDING_WEI) before the broadcast. - CREAT
E3_ PROXY_ INITCODE - The 16-byte CREATE3 proxy init code (
Create3.PROXY_INITCODE). Constant forever — its hash feeds every predicted address.
Functions§
- ensure_
create2_ deployer - Make sure the canonical CREATE2 deployer exists, installing it via the
keyless presigned transaction if absent: fund the one-time signer with
the exact transaction cost, then broadcast
CREATE2_DEPLOYER_INSTALL_TX. - factory_
deploy - Deploy
creation_codeundernamethrough the factory (the provider’s wallet must be the factory owner). Returns the deployed address, which always equalspredict_address(factory, name). - factory_
impl_ init_ code - The frozen implementation init code: LibidFactory’s creation code, no constructor args.
- factory_
impl_ salt - Fixed salt of the factory implementation (
FactoryDeployer.IMPL_SALT). - factory_
proxy_ salt - Fixed salt of the factory proxy (
FactoryDeployer.PROXY_SALT). - predict_
address - The CREATE3 address
factory.deploy(name, ·)lands on: the factory CREATE2-deploys the constant 16-byte proxy underkeccak256(name), and that proxy CREATE-deploys the target at its nonce 1. A pure function of(factory, name)— computable offline, before anything is deployed. - predict_
factory_ impl_ address - Where the factory implementation lands.