官术网_书友最值得收藏!

Adding an owner

It's a good idea to have an owner of a contract and give them the sole right to perform admin-level actions such as the rewarding of a doer, so let's define and set an owner:

pragma solidity ^0.4.17;


contract TaskMaster {
mapping (address => uint) public balances; // balances of everyone
address public owner; // owner of the contract

function TaskMaster() public {
owner = msg.sender;
balances[msg.sender] = 10000;
}
}

The owner of the contract is set to msg.sender, the address instantiating the contract. You will learn more about msg.sender and other Solidity special variables in the next chapter.

主站蜘蛛池模板: 浑源县| 西昌市| 博兴县| 刚察县| 东港市| 乡城县| 灵宝市| 巫溪县| 潞西市| 陈巴尔虎旗| 红安县| 朝阳区| 临江市| 收藏| 鄱阳县| 库车县| 阿拉善盟| 临沂市| 榆社县| 屏东县| 衡山县| 当雄县| 仁布县| 镶黄旗| 辽源市| 女性| 昆山市| 德安县| 衢州市| 桐柏县| 德钦县| 马山县| 呼图壁县| 托里县| 西和县| 资溪县| 高安市| 奈曼旗| 保定市| 绥江县| 伊吾县|