Retrieve the eth balance for an accout at a given block. See https://eth.wiki/json-rpc/API#eth_getBalance # Examples ```ignore use types::block::BlockNumber; let block = BlockNumber(0.into()); let account = web3.get_all_accounts().await.unwrap()[0]; let balance = web3.get_balance_by_block(account, Some(block)).await; assert!(balance.is_ok()); ```
(
&self,
address: Account,
block_number: Option<BlockNumber>,
)
| 50 | /// assert!(balance.is_ok()); |
| 51 | /// ``` |
| 52 | pub async fn get_balance_by_block( |
| 53 | &self, |
| 54 | address: Account, |
| 55 | block_number: Option<BlockNumber>, |
| 56 | ) -> Result<U256> { |
| 57 | let block_number = Web3::get_hex_blocknumber(block_number); |
| 58 | let params = rpc_params![to_hex(address), block_number]; |
| 59 | let response = self.send_rpc("eth_getBalanceByBlock", params).await?; |
| 60 | let balance: U256 = serde_json::from_value(response)?; |
| 61 | |
| 62 | Ok(balance) |
| 63 | } |
| 64 | |
| 65 | pub fn sign_transaction( |
| 66 | &self, |
no test coverage detected