- 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.
推薦閱讀
- 光網(wǎng)絡評估及案例分析
- 物聯(lián)網(wǎng)安全與深度學習技術
- 物聯(lián)網(wǎng)信息安全
- 智慧城市中的移動互聯(lián)網(wǎng)技術
- 信息通信網(wǎng)絡建設安全管理概要2
- 計算機網(wǎng)絡與通信(第2版)
- 區(qū)塊鏈輕松上手:原理、源碼、搭建與應用
- 6G新技術 新網(wǎng)絡 新通信
- Unity Artificial Intelligence Programming
- INSTANT KineticJS Starter
- jQuery Mobile Web Development Essentials
- TD-LTE無線網(wǎng)絡規(guī)劃與設計
- Hands-On Reactive Programming in Spring 5
- 物聯(lián)網(wǎng)導論
- 現(xiàn)場總線與工業(yè)以太網(wǎng)及其應用技術(第2版)