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

Method send_raw

web3/src/transaction.rs:78–85  ·  view source on GitHub ↗

Send a raw transaction See https://eth.wiki/json-rpc/API#eth_sendrawtransaction # Examples ```ignore use types::transaction::TransactionRequest; let web3 = web3::Web3::new("http://127.0.0.1:8545").unwrap(); let from = web3.get_all_accounts().await.unwrap()[0]; let to = web3.get_all_accounts().await.unwrap()[1]; let gas = U256::from(1_000_000); let gas_price = U256::from(1); let data = include_

(&self, transaction_request: Bytes)

Source from the content-addressed store, hash-verified

76 /// let tx_hash = web3.send(transaction_request).await;
77 /// ```
78 pub async fn send_raw(&self, transaction_request: Bytes) -> Result<H256> {
79 let transaction_request = to_value(&transaction_request)?;
80 let params = rpc_params![transaction_request];
81 let response = self.send_rpc("eth_sendRawTransaction", params).await?;
82 let tx_hash: H256 = serde_json::from_value(response)?;
83
84 Ok(tx_hash)
85 }
86
87 /// Retrieve a transaction receipt by transaction hash.
88 ///

Calls 1

send_rpcMethod · 0.80

Tested by

no test coverage detected