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

Function eth_get_transaction_count

chain/src/method.rs:66–81  ·  view source on GitHub ↗
(module: &mut RpcModule<Context>)

Source from the content-addressed store, hash-verified

64}
65
66pub(crate) fn eth_get_transaction_count(module: &mut RpcModule<Context>) -> Result<()> {
67 module.register_async_method("eth_getTransactionCount", |params, blockchain| async move {
68 let account = params.one::<Account>()?;
69 let count = blockchain
70 .lock()
71 .await
72 .accounts
73 .get_account(&account)
74 .map_err(|e| Error::Custom(e.to_string()))?
75 .nonce;
76
77 Ok(to_hex(count))
78 })?;
79
80 Ok(())
81}
82
83pub(crate) fn eth_get_balance_by_block(module: &mut RpcModule<Context>) -> Result<()> {
84 module.register_async_method(

Callers 1

serveFunction · 0.85

Calls 2

to_hexFunction · 0.85
get_accountMethod · 0.80

Tested by

no test coverage detected