@backt/protocol
Version:
Backt smart contracts implementation
54 lines • 6.15 kB
JSON
{
"contractName": "ForwardFactory",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "forwarderAddress",
"type": "address"
},
{
"indexed": false,
"name": "targetContract",
"type": "address"
}
],
"name": "LogForwarderDeployed",
"type": "event"
},
{
"constant": false,
"inputs": [
{
"name": "_target",
"type": "address"
}
],
"name": "createForwarder",
"outputs": [
{
"name": "fwdContract",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5061023b806100206000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680639193ba0b14610046575b600080fd5b34801561005257600080fd5b50610087600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100c9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000806000807f602e600c600039602e6000f3366000600037610100600036600073000000000060010292507f5af41558576101006000f300000000000000000000000000000000000000000060010291506c010000000000000000000000008573ffffffffffffffffffffffffffffffffffffffff1602905060405183815281601b82015282602f820152603a816000f09450843b6000811461016c5761016e565bfe5b50507fe3b17932c50c6e05c2f75f7e045a5fc54b3ac85ce2c29134028227ba28b7d73e8486604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a15050509190505600a165627a7a723058207d9b8c67a37fe128475aa0218a042398f9953b9b035941d26307ac584815ef510029",
"deployedBytecode": "0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680639193ba0b14610046575b600080fd5b34801561005257600080fd5b50610087600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100c9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000806000807f602e600c600039602e6000f3366000600037610100600036600073000000000060010292507f5af41558576101006000f300000000000000000000000000000000000000000060010291506c010000000000000000000000008573ffffffffffffffffffffffffffffffffffffffff1602905060405183815281601b82015282602f820152603a816000f09450843b6000811461016c5761016e565bfe5b50507fe3b17932c50c6e05c2f75f7e045a5fc54b3ac85ce2c29134028227ba28b7d73e8486604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a15050509190505600a165627a7a723058207d9b8c67a37fe128475aa0218a042398f9953b9b035941d26307ac584815ef510029",
"sourceMap": "219:1755:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;219:1755:2;;;;;;;",
"deployedSourceMap": "219:1755:2:-;;;;;;;;;;;;;;;;;;;;;;;;333:1638;;8:9:-1;5:2;;;30:1;27;20:12;5:2;333:1638:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;391:19;1013:10;1126;1235:22;1026:66;1013:79;;;;1139:66;1126:79;;;;1280:14;1268:7;1260:16;;:35;1235:60;;1395:4;1389:11;1509:2;1495:12;1488:24;1621:14;1614:4;1600:12;1596:23;1589:47;1703:2;1696:4;1682:12;1678:23;1671:35;1796:4;1782:12;1779:1;1772:29;1757:44;;1864:11;1852:24;1882:1;1877:20;;;;1845:52;;1877:20;1886:9;1845:52;;1355:552;1922:42;1943:11;1956:7;1922:42;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;333:1638;;;;;;:::o",
"source": "pragma solidity ^0.4.23;\npragma experimental \"v0.5.0\";\n\n/**\n * Factory creating DELETECALL forwarding contracts.\n *\n * This implementation is from:\n * https://gist.github.com/izqui/7f904443e6d19c1ab52ec7f5ad46b3a8\n */\ncontract ForwardFactory {\n\n event LogForwarderDeployed(address forwarderAddress, address targetContract);\n\n function createForwarder(address _target) public returns (address fwdContract) {\n /*\n Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/\n\n CALLDATASIZE\n PUSH1 0x00\n PUSH1 0x00\n CALLDATACOPY\n PUSH2 0x1000\n PUSH1 0x00\n CALLDATASIZE\n PUSH1 0x00\n PUSH20 0xf00df00df00df00df00df00df00df00df00df00d // placeholder address\n GAS\n DELEGATE_CALL\n ISZERO\n PC\n JUMPI\n PUSH2 0x1000\n PUSH1 0x00\n RETURN\n */\n bytes32 b1 = 0x602e600c600039602e6000f33660006000376101006000366000730000000000; // length 27 bytes = 1b\n bytes32 b2 = 0x5af41558576101006000f3000000000000000000000000000000000000000000; // length 11 bytes\n\n uint256 shiftedAddress = uint256(_target) * ((2 ** 8) ** 12); // Shift address 12 bytes to the left\n\n assembly {\n let contractCode := mload(0x40) // Find empty storage location using \"free memory pointer\"\n mstore(contractCode, b1) // We add the first part of the bytecode\n mstore(add(contractCode, 0x1b), shiftedAddress) // Add target address\n mstore(add(contractCode, 0x2f), b2) // Final part of bytecode\n fwdContract := create(0, contractCode, 0x3A) // total length 58 dec = 3a\n switch extcodesize(fwdContract) case 0 { invalid() }\n }\n\n emit LogForwarderDeployed(fwdContract, _target);\n }\n\n}\n",
"sourcePath": "/home/julien/0xFutures/protocol/contracts/ForwardFactory.sol",
"compiler": {
"name": "solc",
"version": "0.4.24+commit.e67f0147.Emscripten.clang"
},
"networks": {},
"schemaVersion": "2.0.1",
"updatedAt": "2018-11-27T22:04:40.329Z"
}