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

Method send

web3/src/transaction.rs:44–51  ·  view source on GitHub ↗

Create a new message call transaction or deploy a contract. See https://eth.wiki/json-rpc/API#eth_sendTransaction # 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 =

(&self, transaction_request: TransactionRequest)

Source from the content-addressed store, hash-verified

42 /// let tx_hash = web3.send(transaction_request).await;
43 /// ```
44 pub async fn send(&self, transaction_request: TransactionRequest) -> Result<H256> {
45 let transaction_request = to_value(&transaction_request)?;
46 let params = rpc_params![transaction_request];
47 let response = self.send_rpc("eth_sendTransaction", params).await?;
48 let tx_hash: H256 = serde_json::from_value(response)?;
49
50 Ok(tx_hash)
51 }
52
53 /// Send a raw transaction
54 ///

Callers 2

send_transactionFunction · 0.80
deployMethod · 0.80

Calls 1

send_rpcMethod · 0.80

Tested by

no test coverage detected