Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Last active September 23, 2018 15:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arachnid/a619d31f6d32757a4328a428286da186 to your computer and use it in GitHub Desktop.
Save Arachnid/a619d31f6d32757a4328a428286da186 to your computer and use it in GitHub Desktop.
// 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