Deploying and fees
The deploy call
The builder sends one transaction from your wallet to the factory at 0x227a41C9b869f7cE396337C88ffd0226917aBF4a: the creation code with its constructor arguments, a mined salt, the kind (0 for an own v4 hook, 1 for a stacked hook) and the recipe string.
function deploy(bytes calldata initCode, bytes32 salt, uint8 kind, string calldata recipe)
external
payable
returns (address hook);
/// The salt CREATE2 actually uses.
function effectiveSalt(address builder, bytes32 salt) public pure returns (bytes32) {
return keccak256(abi.encode(builder, salt));
}
/// What `builder` pays for one deploy right now.
function priceFor(address builder) public view returns (uint256);A salt bound to the sender
CREATE2 does not use the salt you send: it uses keccak256(abi.encode(sender, salt)). A deploy seen in the mempool cannot be copied by another wallet to take the address, because from any other sender the same salt lands somewhere else. This is also why the builder mines the salt for the wallet you connect, and why addressOf(builder, salt, initCodeHash) gives the address before you send anything.
What the factory checks
- The payment is exactly
priceFor(sender), or the call reverts withWrongPayment(expected). - For an own v4 hook, the low 14 bits of the new address must equal the permissions the code declares in
getHookPermissions(), or the deploy reverts withBadPermissions(declared, address_). A return-delta permission without the call it rides on is refused too, since such a hook could never open a pool. - A failed creation reverts with
DeployFailed(reason), carrying the constructor's own revert data.
What it records
Each hook gets a record in built(hook): the builder, the time, the kind, the flags and keccak256 of the recipe. The full recipe string goes into the Built event, so anyone can rebuild the exact source from the event alone. See rebuilding a hook.
event Built(
address indexed hook,
address indexed builder,
uint8 indexed kind,
uint16 flags,
bytes32 recipeHash,
string recipe,
uint256 paid
);The fee
$V4B is the token of v4 Builder. Staking it earns the deploy fees of every hook built here. The balance for the free tier is read on chain at deploy time; a balance call that fails counts as no balance, so the deploy is simply priced at the fee.
After the deploy
- An own v4 hook: open a pool with it. If it sets fees, the pool takes the dynamic fee flag
0x800000; if not, the recipe's base fee is the pool's fee. The builder opens it and adds a first full-range position from your wallet in one PositionManager call. - A stacked hook: list it on v4 Marketplace. See listing.
- Either way, the builder publishes the source on Sourcify right after the deploy, from the recipe on chain, so the explorer shows verified code. The verify endpoint that does it works for any hook built through the factory.
