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

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.

主站蜘蛛池模板: 确山县| 团风县| 鄂尔多斯市| 兴国县| 阜南县| 临泉县| 河津市| 重庆市| 华蓥市| 铜陵市| 达尔| 开平市| 哈尔滨市| 广平县| 北川| 平邑县| 桃江县| 延吉市| 隆尧县| 柘城县| 包头市| 云南省| 滨州市| 时尚| 洪湖市| 渭源县| 浮梁县| 琼海市| 方山县| 金寨县| 平舆县| 讷河市| 民权县| 潍坊市| 眉山市| 中西区| 秦皇岛市| 龙海市| 梁山县| 连云港市| 长丰县|