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

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.

主站蜘蛛池模板: 勐海县| 交口县| 内乡县| 禹州市| 宽甸| 泾阳县| 平利县| 大安市| 金乡县| 监利县| 都江堰市| 北票市| 枞阳县| 莱西市| 育儿| 和静县| 普兰店市| 五家渠市| 哈密市| 东方市| 民和| 南充市| 苍溪县| 五原县| 潮安县| 家居| 长泰县| 张家界市| 河津市| 涪陵区| 温州市| 廉江市| 子洲县| 平安县| 江阴市| 搜索| 休宁县| 宝山区| 定南县| 青田县| 洱源县|