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

Adding a utility method

Utility methods help us get data from our contract without modifying the state.

   function getBalance(address addr) public view returns(uint) {
return balances[addr];
}

This function accepts an address and returns the balance of the passed-in address. Notice how it is marked with view. The view modifier signifies that this function does not modify the storage state of the contract. You will learn more about this in Chapter 2Web3 and Solidity in Truffle, where we will refresh Solidity fundamentals.

主站蜘蛛池模板: 塔城市| 巴南区| 驻马店市| 和林格尔县| 安溪县| 电白县| 读书| 宁德市| 香格里拉县| 宜丰县| 华蓥市| 汶川县| 武清区| 神池县| 山阴县| 石城县| 连平县| 博罗县| 黑河市| 株洲市| 临武县| 开江县| 开江县| 松滋市| 禹城市| 通城县| 罗源县| 农安县| 深州市| 昌都县| 嘉黎县| 安徽省| 华阴市| 西城区| 岐山县| 广元市| 三明市| 兰州市| 长汀县| 盈江县| 马鞍山市|