- Truffle Quick Start Guide
- Nikhil Bhaskar
- 84字
- 2021-06-25 20:47:34
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 2, Web3 and Solidity in Truffle, where we will refresh Solidity fundamentals.
推薦閱讀
- 物聯網標準化指南
- 智慧城市:大數據、互聯網時代的城市治理(第4版)
- FreeSWITCH 1.2
- INSTANT PhpStorm Starter
- Hands-On Industrial Internet of Things
- WordPress 5 Complete
- 信息通信網絡建設安全管理概要2
- 互聯網安全的40個智慧洞見:2014年中國互聯網安全大會文集
- 城域網與廣域網(第2版)
- The Kubernetes Workshop
- 物聯網工程概論
- INSTANT LinkedIn Customization How-to
- 移動物聯網:商業模式+案例分析+應用實戰
- bash網絡安全運維
- Selenium WebDriver 3 Practical Guide