Skip to main content

foundry_evm_core/
constants.rs

1use alloy_primitives::{Address, B256, address, b256, hex};
2
3pub use foundry_evm_networks::MONAD_CHEATCODE_ADDRESS;
4
5/// The cheatcode handler address.
6///
7/// This is the same address as the one used in DappTools's HEVM.
8///
9/// This is calculated as:
10/// `address(bytes20(uint160(uint256(keccak256('hevm cheat code')))))`
11pub const CHEATCODE_ADDRESS: Address = address!("0x7109709ECfa91a80626fF3989D68f67F5b1DD12D");
12
13/// The contract hash at [`CHEATCODE_ADDRESS`].
14///
15/// This is calculated as:
16/// `keccak256(abi.encodePacked(CHEATCODE_ADDRESS))`.
17pub const CHEATCODE_CONTRACT_HASH: B256 =
18    b256!("0xb0450508e5a2349057c3b4c9c84524d62be4bb17e565dbe2df34725a26872291");
19
20/// The Hardhat console address.
21///
22/// See: <https://github.com/NomicFoundation/hardhat/blob/main/v-next/hardhat/console.sol>
23pub const HARDHAT_CONSOLE_ADDRESS: Address = address!("0x000000000000000000636F6e736F6c652e6c6f67");
24
25/// Stores the caller address to be used as *sender* account for:
26/// - deploying Test contracts
27/// - deploying Script contracts
28///
29/// Derived from `address(uint160(uint256(keccak256("foundry default caller"))))`,
30/// which is equal to `0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38`.
31pub const CALLER: Address = address!("0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38");
32
33/// The default test contract address.
34///
35/// Derived from `CALLER.create(1)`.
36pub const TEST_CONTRACT_ADDRESS: Address = address!("0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496");
37
38/// Magic return value returned by the `assume` cheatcode.
39pub const MAGIC_ASSUME: &[u8] = b"FOUNDRY::ASSUME";
40
41/// Magic return value returned by the `skip` cheatcode. Optionally appended with a reason.
42pub const MAGIC_SKIP: &[u8] = b"FOUNDRY::SKIP";
43
44/// The address that deploys the default CREATE2 deployer contract.
45pub const DEFAULT_CREATE2_DEPLOYER_DEPLOYER: Address =
46    address!("0x3fAB184622Dc19b6109349B94811493BF2a45362");
47/// The default CREATE2 deployer.
48pub const DEFAULT_CREATE2_DEPLOYER: Address =
49    address!("0x4e59b44847b379578588920ca78fbf26c0b4956c");
50/// The initcode of the default CREATE2 deployer.
51pub const DEFAULT_CREATE2_DEPLOYER_CODE: &[u8] = &hex!(
52    "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
53);
54/// The runtime code of the default CREATE2 deployer.
55pub const DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE: &[u8] = &hex!(
56    "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
57);
58/// The hash of the default CREATE2 deployer code.
59///
60/// This is calculated as `keccak256([`DEFAULT_CREATE2_DEPLOYER_RUNTIME_CODE`])`.
61pub const DEFAULT_CREATE2_DEPLOYER_CODEHASH: B256 =
62    b256!("0x2fa86add0aed31f33a762c9d88e807c475bd51d0f52bd0955754b2608f7e4989");
63
64#[cfg(test)]
65mod tests {
66    use super::*;
67
68    #[test]
69    fn create2_deployer() {
70        assert_eq!(DEFAULT_CREATE2_DEPLOYER_DEPLOYER.create(0), DEFAULT_CREATE2_DEPLOYER);
71    }
72}