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

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.

主站蜘蛛池模板: 新津县| 金寨县| 格尔木市| 宁乡县| 阜城县| 万州区| 康保县| 金沙县| 长治县| 修武县| 隆昌县| 鄯善县| 合肥市| 修文县| 河北省| 舒兰市| 垦利县| 惠来县| 久治县| 怀柔区| 五常市| 侯马市| 吉安县| 蒙城县| 临武县| 廉江市| 大足县| 临颍县| 闽侯县| 阿巴嘎旗| 无棣县| 罗江县| 安庆市| 梁河县| 固始县| 买车| 贵阳市| 珲春市| 东阳市| 深州市| 来凤县|