MCPcopy Create free account
hub / github.com/ddimaria/rust-blockchain-tutorial / get_balance

Method get_balance

web3/src/account.rs:33–37  ·  view source on GitHub ↗

Retrieve the eth balance for an accout at the current block. See https://eth.wiki/json-rpc/API#eth_getBalance # Examples ```ignore let web3 = web3::Web3::new("http://127.0.0.1:8545").unwrap(); let account = web3.get_all_accounts().await.unwrap()[0].clone(); let balance = web3.get_balance(account).await; assert!(balance.is_ok()); ```

(&self, address: Account)

Source from the content-addressed store, hash-verified

31 /// assert!(balance.is_ok());
32 /// ```
33 pub async fn get_balance(&self, address: Account) -> Result<U256> {
34 let balance: U256 = self.get_balance_by_block(address, None).await?;
35
36 Ok(balance)
37 }
38
39 /// Retrieve the eth balance for an accout at a given block.
40 ///

Callers 1

it_gets_a_balanceFunction · 0.80

Calls 1

get_balance_by_blockMethod · 0.80

Tested by

no test coverage detected