SingletonFactory.sol
1 pragma solidity >=0.5.0 <0.7.0; 2 3 /** 4 * @author Ricardo Guilherme Schmidt (Status Research & Development GmbH) 5 * @notice Singleton Factory (ERC-2470) deploys deterministic addresses based on it's initialization code. 6 */ 7 contract SingletonFactory { 8 /** 9 * @notice Deploys a deterministic address based on `_initCode`. 10 * @param _initCode Initialization code. 11 * @return Created contract address. 12 */ 13 function deploy(bytes memory _initCode) 14 public 15 returns (address payable createdContract) 16 { 17 assembly { 18 createdContract := create2(0, add(_initCode, 0x20), mload(_initCode), 0) 19 } 20 } 21 // IV is value needed to have a vanity address starting with '0x2470'. 22 // IV: 0 23 }