Last active
September 23, 2018 15:52
-
-
Save Arachnid/a619d31f6d32757a4328a428286da186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WHATEVER YOU DO, DON'T USE THIS. | |
// This is a bit of demo code posted to illustrate a principle. It is unaudited, | |
// probably full of bugs, and definintely not production ready. | |
// https://twitter.com/nicksdjohnson/status/1041642345467404291 | |
contract DumbWallet { | |
mapping(address=>bool) public authorised; | |
event Authorised(address indexed target, bool value); | |
event Call(address indexed target, uint value); | |
event Received(address indexed sender, uint value); | |
modifier authorisedOnly { | |
require(authorised[msg.sender]); | |
_; | |
} | |
constructor() { | |
authorised[msg.sender] = true; | |
} | |
function setAuthorised(address target, bool value) authorisedOnly { | |
require(target != msg.sender); | |
authorised[target] = value; | |
Authorised(target, value); | |
} | |
function invoke(address target, uint value, bytes data) payable authorisedOnly { | |
require(target.call.value(value)(data)); | |
} | |
function() payable { | |
require(msg.data.length == 0 && msg.value > 0); | |
Received(msg.sender, msg.value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment