Created
August 18, 2025 08:21
-
-
Save mablr/d741ea64ec927d7fd40b474744eb2f88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: WTFPL | |
| pragma solidity ^0.8.13; | |
| import {Script, console2} from "forge-std/Script.sol"; | |
| import {Counter} from "../src/Counter.sol"; | |
| contract CounterScript is Script { | |
| function setUp() public {} | |
| function run() public { | |
| bytes32 initCodeHash = keccak256(type(Counter).creationCode); | |
| bytes32 salt = 0xb58579034bf96404b2d6d0770d81cb4b536eae4756bf8a68500762d6bb272f2b; | |
| address create2_deployer = 0x4e59b44847b379578588920cA78FbF26c0B4956C; | |
| vm.startBroadcast(); | |
| // Dark wizardry | |
| Counter counter = new Counter{salt: salt}(); | |
| address new_contract_address = address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), create2_deployer, salt, initCodeHash))))); | |
| console2.log("Supposed deployment address:\t", new_contract_address); | |
| console2.log("Actual deployment address:\t", address(counter)); | |
| vm.stopBroadcast(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment