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

Method send_rpc

web3/src/lib.rs:50–65  ·  view source on GitHub ↗

Send a RPC call with the given method and parameters. # Examples ```ignore let web3 = web3::Web3::new("http://127.0.0.1:8545").unwrap(); let response = web3.send_rpc("eth_blockNumber", rpc_params![]).await; assert!(response.is_ok()); ```

(&self, method: &str, params: Params)

Source from the content-addressed store, hash-verified

48 /// assert!(response.is_ok());
49 /// ```
50 pub async fn send_rpc<Params>(&self, method: &str, params: Params) -> Result<Value>
51 where
52 Params: ToRpcParams + Send + std::fmt::Debug,
53 {
54 trace!("Sending RPC {} with params {:?}", method, params);
55
56 let response = self
57 .client
58 .request(method, params)
59 .await
60 .map_err(|e| Web3Error::RpcRequestError(e.to_string()));
61
62 trace!("RPC Response {:?}", response);
63
64 response
65 }
66}

Callers 8

get_balance_by_blockMethod · 0.80
get_transaction_countMethod · 0.80
sendMethod · 0.80
send_rawMethod · 0.80
transaction_receiptMethod · 0.80
get_block_numberMethod · 0.80
get_blockMethod · 0.80
codeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected