# CREATE2 Factory **Published by:** [m0t0k1ch1](https://paragraph.com/@m0t0k1ch1/) **Published on:** 2021-12-13 **URL:** https://paragraph.com/@m0t0k1ch1/create2-factory ## Content pragma solidity ^0.8.10; contract Factory { event Created(address indexed addr); function create( bytes memory code, uint256 salt, bytes calldata data ) external returns (address) { address addr; assembly { addr := create2(0, add(code, 0x20), mload(code), salt) if iszero(extcodesize(addr)) { revert(0, 0) } } if (data.length > 0) { (bool success, ) = addr.call(data); if (!success) { assembly { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } } emit Created(addr); return addr; } } ## Publication Information - [m0t0k1ch1](https://paragraph.com/@m0t0k1ch1/): Publication homepage - [All Posts](https://paragraph.com/@m0t0k1ch1/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@m0t0k1ch1): Subscribe to updates - [Twitter](https://twitter.com/m0t0k1ch1): Follow on Twitter