- 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.
推薦閱讀
- 數(shù)據(jù)通信網(wǎng)絡(luò)實(shí)踐:基礎(chǔ)知識(shí)與交換機(jī)技術(shù)
- 物聯(lián)網(wǎng)安全與深度學(xué)習(xí)技術(shù)
- Getting Started with WebRTC
- 網(wǎng)絡(luò)安全技術(shù)與解決方案(修訂版)
- 中小型局域網(wǎng)組建、管理與維護(hù)實(shí)戰(zhàn)
- Getting Started with Grunt:The JavaScript Task Runner
- 基于性能的保障理論與方法
- 網(wǎng)管工具使用與技巧大全
- 網(wǎng)絡(luò)利他行為研究:積極心理學(xué)的視角
- INSTANT LinkedIn Customization How-to
- 智慧城市中的物聯(lián)網(wǎng)技術(shù)
- Migrating to Drupal7
- Hands-On Cloud:Native Microservices with Jakarta EE
- 學(xué)術(shù)虛擬社區(qū)用戶社會(huì)化交互行為研究
- 世界網(wǎng)力:2018年中國(guó)網(wǎng)信產(chǎn)業(yè)桔皮書