CREATE2 Receipt Voucher

create2-receipt-voucher · receipt-attestation · 303 B runtime · registry-info

scores

source

pragma solidity ^0.8.13;

contract Create2ReceiptVoucher {
    event Receipt(
        address indexed from,
        bytes32 indexed salt,
        address indexed predicted,
        bytes32 initCodeHash
    );

    function commit(bytes32 salt, bytes32 initCodeHash) external {
        address predicted = address(
            uint160(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            bytes1(0xff),
                            address(this),
                            salt,
                            initCodeHash
                        )
                    )
                )
            )
        );
        emit Receipt(msg.sender, salt, predicted, initCodeHash);
    }
}