Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/utils/Create2Factory.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
/**
* @title Create2Factory
* @notice Minimal CREATE2 factory for deterministic deployments
* @dev Deploy this contract once, then use it to deploy contracts with predictable addresses
*/
contract Create2Factory {
event Deployed(address addr, bytes32 salt);
/**
* @notice Deploy a contract using CREATE2
* @param salt Salt for CREATE2 address derivation
* @param creationCode Contract creation bytecode (constructor code + abi.encode(args))
* @return addr The deployed contract address
*/
function deploy(bytes32 salt, bytes memory creationCode)
external
payable
returns (address addr)
{
assembly {
addr := create2(
callvalue(),
add(creationCode, 0x20),
mload(creationCode),
salt
)
if iszero(extcodesize(addr)) {
// Bubble up creation revert if any
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}
emit Deployed(addr, salt);
}
/**
* @notice Predict the address of a contract deployed with CREATE2
* @param salt Salt for CREATE2 address derivation
* @param creationCode Contract creation bytecode
* @return predicted The predicted contract address
*/
function predictAddress(bytes32 salt, bytes memory creationCode)
external
view
returns (address predicted)
{
bytes32 codeHash = keccak256(creationCode);
bytes32 hash = keccak256(
abi.encodePacked(bytes1(0xff), address(this), salt, codeHash)
);
predicted = address(uint160(uint256(hash)));
}
}
"
}
},
"settings": {
"remappings": [
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"permit2/=lib/v4-periphery/lib/permit2/",
"solmate/=lib/solmate/src/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}
}}
Submitted on: 2025-10-21 16:55:31
Comments
Log in to comment.
No comments yet.