Skip to content

Instantly share code, notes, and snippets.

function create2Address(address deployer, bytes32 salt, bytes32 codeHash) pure returns (address) {
return address(uint160(uint256(keccak256(abi.encodePacked(hex"ff", deployer, salt, codeHash)))));
}
contract Factory {
address public caller;
function fetch(bytes32 salt) public {
caller = msg.sender;
new Funder{salt: salt}();
@0xPhaze
0xPhaze / TestGasLimit.sol
Created February 5, 2025 16:16
Solidity: Binary search minimum upper gas limit
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.25;
import {Test, console2 as console} from "forge-std/Test.sol";
contract ABCTest is Test {
event VaultAuxiliary1(address, string, bytes);
function test_xxx() public {
binarySearchMinUpperGasLimit(this.process, 100_000_000);
@0xPhaze
0xPhaze / StaticProxy.sol
Created September 11, 2022 21:14
Solidity StaticProxy (replaces PausableUpgradeable)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {OwnableUDS} from "UDS/auth/OwnableUDS.sol";
import {UUPSUpgrade} from "UDS/proxy/UUPSUpgrade.sol";
import {ERC1967_PROXY_STORAGE_SLOT} from "UDS/proxy/ERC1967Proxy.sol";
// ------------- storage
bytes32 constant DIAMOND_STORAGE_STATIC_PROXY = keccak256("diamond.storage.static.proxy");