Skip to main content

Module deploy

Module deploy 

Source
Expand description

Generic deploy and upgrade primitives, usable over any alloy Provider that has a wallet wired in. Signing is the consumer’s concern; nothing here constructs or holds keys.

Structs§

Libraries
External libraries deployed once per distinct bytecode, and the address each linked contract substitutes for its placeholders.

Constants§

LIBRARY_SALT
The salt every shared library deploys under. Fixed and empty on purpose: a CREATE2 address is a function of the deployer, the salt and the hash of the init code, and the init code is the whole key — the salt has nothing to add.

Functions§

deploy_behind_proxy
Deploy an implementation from artifacts and put it behind a fresh ERC1967 proxy whose init data is init_call ABI-encoded. Returns the proxy address. The common shape of every UUPS deploy in the stack.
deploy_contract
Deploy a contract and return its address.
deploy_contract_from
Deploy a contract, optionally fetching the sender’s nonce explicitly.
deploy_proxy
Deploy an ERC1967 proxy pointing at implementation with init_data (the ABI-encoded initializer call).
deploy_with_ctor
Deploy bytecode with ABI-encoded constructor args appended.
library_address
Where a library with this creation code lands, on every chain: through the canonical CREATE2_DEPLOYER under LIBRARY_SALT. A pure function of the bytes, computable before anything is deployed.
load_linked_bytecode
The creation bytecode of <file>.sol:<contract> with every library it links deployed and substituted: Libraries::deploy over the one contract, then Libraries::link. Mirrors what forge does automatically, except that a library already at its address is reused rather than deployed again. For artifacts with no linkReferences this behaves like Artifacts::bytecode_named and sends nothing.
upgrade_uups
Upgrade a UUPS proxy: deploy contract’s current implementation from artifacts, then call upgradeToAndCall(new_impl, data) on the proxy. Returns the new implementation address. data is usually empty (state is already initialized); pass a re-initializer call when the upgrade needs one.