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

Method get_transaction_count

web3/src/account.rs:87–93  ·  view source on GitHub ↗

Retrieve the eth balance for an accout at a given block. See https://eth.wiki/json-rpc/API#eth_getBalance # Examples ```ignore let account = web3.get_all_accounts().await.unwrap()[0]; let nonce = web3.get_transaction_count(account).await; assert!(nonce.is_ok()); ```

(&self, address: Account)

Source from the content-addressed store, hash-verified

85 /// assert!(nonce.is_ok());
86 /// ```
87 pub async fn get_transaction_count(&self, address: Account) -> Result<U256> {
88 let params = rpc_params![to_hex(address)];
89 let response = self.send_rpc("eth_getTransactionCount", params).await?;
90 let balance: U256 = serde_json::from_value(response)?;
91
92 Ok(balance)
93 }
94}
95
96#[cfg(test)]

Callers 1

Calls 1

send_rpcMethod · 0.80

Tested by

no test coverage detected