Contract Overview
Balance:
0 Ether
EtherValue:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0xc53851a56f9231bef6c6d72854ad4c405666a8eed115df56c0d012b1055b9160 | Add Permitted Ca... | 418434 | 439 days 20 hrs ago | 0xc98469fd959d96722723dbc7dba58b36e7854386 | IN | 0x67fe1c6598c6213083d631c5246ce4b8ce54198b | 0 Ether | 0.000181163 | |
0xdf191c9cb1cf80868cdc245891277aa8747ec3c477013c6d8b9ec775fec8b6f6 | 0x60806040 | 418431 | 439 days 20 hrs ago | 0xc98469fd959d96722723dbc7dba58b36e7854386 | IN | Create: TuringHelper | 0 Ether | 0.00146086 |
[ Download CSV Export ]
Contract Name:
TuringHelper
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 10000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import '@openzeppelin/contracts/access/Ownable.sol'; import "./ITuringHelper.sol"; contract TuringHelper is ITuringHelper, Ownable { TuringHelper Self; // This protects your own credits for this helper contract mapping(address => bool) public permittedCaller; event AddPermittedCaller(address _callerAddress); event RemovePermittedCaller(address _callerAddress); event CheckPermittedCaller(address _callerAddress, bool permitted); event OffchainResponse(uint version, bytes responseData); event OffchainRandom(uint version, uint256 random); modifier onlyPermittedCaller() { require( permittedCaller[msg.sender], 'Invalid Caller Address' ); _; } constructor () public { Self = TuringHelper(address(this)); } function addPermittedCaller(address _callerAddress) public onlyOwner { permittedCaller[_callerAddress] = true; emit AddPermittedCaller(_callerAddress); } function removePermittedCaller(address _callerAddress) public onlyOwner { permittedCaller[_callerAddress] = false; emit RemovePermittedCaller(_callerAddress); } function checkPermittedCaller(address _callerAddress) public returns (bool) { bool permitted = permittedCaller[_callerAddress]; emit CheckPermittedCaller(_callerAddress, permitted); return permitted; } function GetErrorCode(uint32 rType) internal view returns (string memory) { if(rType == 1) return "TURING: Geth intercept failure"; if(rType == 10) return "TURING: Incorrect input state"; if(rType == 11) return "TURING: Calldata too short"; if(rType == 12) return "TURING: URL >64 bytes"; if(rType == 13) return "TURING: Server error"; if(rType == 14) return "TURING: Could not decode server response"; if(rType == 15) return "TURING: Could not create rpc client"; if(rType == 16) return "TURING: RNG failure"; if(rType == 17) return "TURING: API Response >322 chars"; if(rType == 18) return "TURING: API Response >160 bytes"; if(rType == 19) return "TURING: Insufficient credit"; if(rType == 20) return "TURING: Missing cache entry"; } /* This is the interface to the off-chain mechanism. Although marked as "public", it is only to be called by TuringCall() or TuringTX(). The _payload parameter is overloaded to represent either the request parameters or the off-chain response, with the rType parameter indicating which is which. When called as a request (rType == 1), it starts the offchain call, which, if all all goes well, results in the rType changing to 2. This response is then passed back to the caller. */ function GetResponse(uint32 rType, string memory _url, bytes memory _payload) public returns (bytes memory) { require (msg.sender == address(this), "Turing:GetResponse:msg.sender != address(this)"); require (_payload.length > 0, "Turing:GetResponse:no payload"); require (rType == 2, string(GetErrorCode(rType))); // l2geth can pass values here to provide debug information return _payload; } function GetRandom(uint32 rType, uint256 _random) public returns (uint256) { require (msg.sender == address(this), "Turing:GetResponse:msg.sender != address(this)"); require (rType == 2, string(GetErrorCode(rType))); return _random; } /* Called from the external contract. It takes an api endponit URL and an abi-encoded request payload. The URL and the list of allowed methods are supplied when the contract is created. In the future some of this registration might be moved into l2geth, allowing for security measures such as TLS client certificates. A configurable timeout could also be added. Logs the offchain response so that a future verifier or fraud prover can replay the transaction and ensure that it results in the same state root as during the initial execution. Note - a future version might need to include a timestamp and/or more details about the offchain interaction. */ function TuringTx(string memory _url, bytes memory _payload) public onlyPermittedCaller override returns (bytes memory) { require (_payload.length > 0, "Turing:TuringTx:no payload"); /* Initiate the request. This can't be a local function call because that would stay inside the EVM and not give l2geth a place to intercept and re-write the call. */ bytes memory response = Self.GetResponse(1, _url, _payload); emit OffchainResponse(0x01, response); return response; } function TuringRandom() public onlyPermittedCaller returns (uint256) { uint256 response = Self.GetRandom(1, 0); emit OffchainRandom(0x01, response); return response; } // ERC165 check interface function supportsInterface(bytes4 _interfaceId) public pure returns (bool) { bytes4 firstSupportedInterface = bytes4(keccak256("supportsInterface(bytes4)")); // ERC165 bytes4 secondSupportedInterface = ITuringHelper.TuringTx.selector; return _interfaceId == firstSupportedInterface || _interfaceId == secondSupportedInterface; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.9; interface ITuringHelper { /* Called from the external contract. It takes an api endponit URL and an abi-encoded request payload. The URL and the list of allowed methods are supplied when the contract is created. In the future some of this registration might be moved into l2geth, allowing for security measures such as TLS client certificates. A configurable timeout could also be added. Logs the offchain response so that a future verifier or fraud prover can replay the transaction and ensure that it results in the same state root as during the initial execution. Note - a future version might need to include a timestamp and/or more details about the offchain interaction. */ function TuringTx(string memory _url, bytes memory _payload) external returns (bytes memory); function TuringRandom() external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
{ "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "bytecodeHash": "none", "useLiteralContent": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_callerAddress","type":"address"}],"name":"AddPermittedCaller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_callerAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"permitted","type":"bool"}],"name":"CheckPermittedCaller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"random","type":"uint256"}],"name":"OffchainRandom","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"responseData","type":"bytes"}],"name":"OffchainResponse","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_callerAddress","type":"address"}],"name":"RemovePermittedCaller","type":"event"},{"inputs":[{"internalType":"uint32","name":"rType","type":"uint32"},{"internalType":"uint256","name":"_random","type":"uint256"}],"name":"GetRandom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"rType","type":"uint32"},{"internalType":"string","name":"_url","type":"string"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"GetResponse","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"TuringRandom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_url","type":"string"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"TuringTx","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_callerAddress","type":"address"}],"name":"addPermittedCaller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_callerAddress","type":"address"}],"name":"checkPermittedCaller","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"permittedCaller","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_callerAddress","type":"address"}],"name":"removePermittedCaller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061001a33610031565b600180546001600160a01b03191630179055610081565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61135c806100906000396000f3fe608060405234801561001057600080fd5b50600436106100d45760003560e01c80638da5cb5b11610081578063cbcd0c2c1161005b578063cbcd0c2c146101b5578063f2f3fa07146101c8578063f2fde38b146101eb57600080fd5b80638da5cb5b14610167578063a432ee271461018f578063aadebcb9146101a257600080fd5b8063493d57d6116100b2578063493d57d614610137578063715018a61461014a5780637d93616c1461015457600080fd5b806301ffc9a7146100d95780632f7adf431461010157806345ff812a14610121575b600080fd5b6100ec6100e7366004610ee4565b6101fe565b60405190151581526020015b60405180910390f35b61011461010f366004611047565b6102be565b6040516100f89190611125565b61012961048a565b6040519081526020016100f8565b61012961014536600461114c565b6105db565b61015261068b565b005b610114610162366004611176565b6106fe565b60005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f8565b61015261019d3660046111ea565b610800565b6101526101b03660046111ea565b6108ed565b6100ec6101c33660046111ea565b6109d0565b6100ec6101d63660046111ea565b60026020526000908152604090205460ff1681565b6101526101f93660046111ea565b610a40565b60007f01ffc9a7a5cef8baa21ed3c5c0d7e23accb804b619e9333b597f47a0d84076e27f2f7adf43000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000084167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102b657507fffffffff00000000000000000000000000000000000000000000000000000000848116908216145b949350505050565b3360009081526002602052604090205460609060ff166103255760405162461bcd60e51b815260206004820152601660248201527f496e76616c69642043616c6c657220416464726573730000000000000000000060448201526064015b60405180910390fd5b60008251116103765760405162461bcd60e51b815260206004820152601a60248201527f547572696e673a547572696e6754783a6e6f207061796c6f6164000000000000604482015260640161031c565b600180546040517f7d93616c00000000000000000000000000000000000000000000000000000000815260009273ffffffffffffffffffffffffffffffffffffffff90921691637d93616c916103d3919088908890600401611220565b600060405180830381600087803b1580156103ed57600080fd5b505af1158015610401573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610447919081019061125b565b90507ffde6d9b9b674fe8a495a825379378eb214e03439d12f342ac5e8af9768c1d85c60018260405161047b9291906112d2565b60405180910390a19392505050565b3360009081526002602052604081205460ff166104e95760405162461bcd60e51b815260206004820152601660248201527f496e76616c69642043616c6c6572204164647265737300000000000000000000604482015260640161031c565b600180546040517f493d57d600000000000000000000000000000000000000000000000000000000815260048101929092526000602483018190529173ffffffffffffffffffffffffffffffffffffffff9091169063493d57d690604401602060405180830381600087803b15801561056157600080fd5b505af1158015610575573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059991906112eb565b6040805160018152602081018390529192507f450d62889c3a6e19c9586840ce9c21040b90d81950fe31f2ba982090adaf53e8910160405180910390a1905090565b60003330146106525760405162461bcd60e51b815260206004820152602e60248201527f547572696e673a476574526573706f6e73653a6d73672e73656e64657220213d60448201527f2061646472657373287468697329000000000000000000000000000000000000606482015260840161031c565b8263ffffffff1660021461066584610b3c565b906106835760405162461bcd60e51b815260040161031c9190611125565b509092915050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146106f25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161031c565b6106fc6000610e6f565b565b60603330146107755760405162461bcd60e51b815260206004820152602e60248201527f547572696e673a476574526573706f6e73653a6d73672e73656e64657220213d60448201527f2061646472657373287468697329000000000000000000000000000000000000606482015260840161031c565b60008251116107c65760405162461bcd60e51b815260206004820152601d60248201527f547572696e673a476574526573706f6e73653a6e6f207061796c6f6164000000604482015260640161031c565b8363ffffffff166002146107d985610b3c565b906107f75760405162461bcd60e51b815260040161031c9190611125565b50909392505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146108675760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161031c565b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519182527f9ce84a7ab8065f5f6f23c19be05400b2edbabf71e4b29837f56a016c951b97d291015b60405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff1633146109545760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161031c565b73ffffffffffffffffffffffffffffffffffffffff811660008181526002602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905590519182527feacddceebef9fdf16961c5dba55871a098bd93be9160335139bdeb226537c6ed91016108e2565b73ffffffffffffffffffffffffffffffffffffffff8116600081815260026020908152604080832054815194855260ff1680151592850192909252919290917fabf082f4a354a0ea137bf1c9b0f6660d1340b3f84e293fb4a4cb01c7602c3962910160405180910390a192915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610aa75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161031c565b73ffffffffffffffffffffffffffffffffffffffff8116610b305760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161031c565b610b3981610e6f565b50565b60608163ffffffff1660011415610b8657505060408051808201909152601e81527f545552494e473a204765746820696e74657263657074206661696c7572650000602082015290565b8163ffffffff16600a1415610bce57505060408051808201909152601d81527f545552494e473a20496e636f727265637420696e707574207374617465000000602082015290565b8163ffffffff16600b1415610c1657505060408051808201909152601a81527f545552494e473a2043616c6c6461746120746f6f2073686f7274000000000000602082015290565b8163ffffffff16600c1415610c5e57505060408051808201909152601581527f545552494e473a2055524c203e36342062797465730000000000000000000000602082015290565b8163ffffffff16600d1415610ca657505060408051808201909152601481527f545552494e473a20536572766572206572726f72000000000000000000000000602082015290565b8163ffffffff16600e1415610cd4576040518060600160405280602881526020016113056028913992915050565b8163ffffffff16600f1415610d025760405180606001604052806023815260200161132d6023913992915050565b8163ffffffff1660101415610d4a57505060408051808201909152601381527f545552494e473a20524e47206661696c75726500000000000000000000000000602082015290565b8163ffffffff1660111415610d9257505060408051808201909152601f81527f545552494e473a2041504920526573706f6e7365203e33323220636861727300602082015290565b8163ffffffff1660121415610dda57505060408051808201909152601f81527f545552494e473a2041504920526573706f6e7365203e31363020627974657300602082015290565b8163ffffffff1660131415610e2257505060408051808201909152601b81527f545552494e473a20496e73756666696369656e74206372656469740000000000602082015290565b8163ffffffff1660141415610e6a57505060408051808201909152601b81527f545552494e473a204d697373696e6720636163686520656e7472790000000000602082015290565b919050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215610ef657600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610f2657600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610fa357610fa3610f2d565b604052919050565b600067ffffffffffffffff821115610fc557610fc5610f2d565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261100257600080fd5b813561101561101082610fab565b610f5c565b81815284602083860101111561102a57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806040838503121561105a57600080fd5b823567ffffffffffffffff8082111561107257600080fd5b61107e86838701610ff1565b9350602085013591508082111561109457600080fd5b506110a185828601610ff1565b9150509250929050565b60005b838110156110c65781810151838201526020016110ae565b838111156110d5576000848401525b50505050565b600081518084526110f38160208601602086016110ab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610f2660208301846110db565b803563ffffffff81168114610e6a57600080fd5b6000806040838503121561115f57600080fd5b61116883611138565b946020939093013593505050565b60008060006060848603121561118b57600080fd5b61119484611138565b9250602084013567ffffffffffffffff808211156111b157600080fd5b6111bd87838801610ff1565b935060408601359150808211156111d357600080fd5b506111e086828701610ff1565b9150509250925092565b6000602082840312156111fc57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610f2657600080fd5b63ffffffff8416815260606020820152600061123f60608301856110db565b828103604084015261125181856110db565b9695505050505050565b60006020828403121561126d57600080fd5b815167ffffffffffffffff81111561128457600080fd5b8201601f8101841361129557600080fd5b80516112a361101082610fab565b8181528560208385010111156112b857600080fd5b6112c98260208301602086016110ab565b95945050505050565b8281526040602082015260006102b660408301846110db565b6000602082840312156112fd57600080fd5b505191905056fe545552494e473a20436f756c64206e6f74206465636f64652073657276657220726573706f6e7365545552494e473a20436f756c64206e6f74206372656174652072706320636c69656e74a164736f6c6343000809000a
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.