Skip to main content

Module factory

Module factory 

Source
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§

FactoryGenesis
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§

CREATE2_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.
CREATE2_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.
CREATE2_DEPLOYER_INSTALL_TX
The canonical presigned transaction that installs the CREATE2 deployer.
CREATE2_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.
CREATE3_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_code under name through the factory (the provider’s wallet must be the factory owner). Returns the deployed address, which always equals predict_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 under keccak256(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.