File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 1+ pragma solidity ^ 0.4.11 ;
2+
3+ /**
4+ * @title Ownable
5+ * @dev The Ownable contract has an owner address, and provides basic authorization control
6+ * functions, this simplifies the implementation of "user permissions".
7+ */
8+ contract Ownable {
9+ address public owner;
10+
11+
12+ /**
13+ * @dev The Ownable constructor sets the original `owner` of the contract to the sender
14+ * account.
15+ */
16+ function Ownable () {
17+ owner = msg .sender ;
18+ }
19+
20+
21+ /**
22+ * @dev Throws if called by any account other than the owner.
23+ */
24+ modifier onlyOwner () {
25+ if (msg .sender != owner) {
26+ throw ;
27+ }
28+ _;
29+ }
30+
31+
32+ /**
33+ * @dev Allows the current owner to transfer control of the contract to a newOwner.
34+ * @param newOwner The address to transfer ownership to.
35+ */
36+ function transferOwnership (address newOwner ) onlyOwner {
37+ if (newOwner != address (0 )) {
38+ owner = newOwner;
39+ }
40+ }
41+
42+ }
Original file line number Diff line number Diff line change 11pragma solidity ^ 0.4.7 ;
2- contract SimpleStorage {
2+
3+ import "ownable.sol " ;
4+
5+ contract SimpleStorage is Ownable {
36 uint public storedData;
47
58 function () payable { }
@@ -12,7 +15,7 @@ contract SimpleStorage {
1215 storedData = x;
1316 }
1417
15- function set2 (uint x , uint unusedGiveWarning ) {
18+ function set2 (uint x , uint unusedGiveWarning ) onlyOwner {
1619 storedData = x;
1720 }
1821
Original file line number Diff line number Diff line change 1717 ],
1818 "gas" : " auto" ,
1919 "contracts" : {
20+ "Ownable" : {
21+ "deploy" : false
22+ },
2023 "SimpleStorage" : {
2124 "args" : [
2225 100
You can’t perform that action at this time.
0 commit comments