Skip to content

Commit

Permalink
avoid using RootProvider directly, use on_client and new_http
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Mar 19, 2024
1 parent 489a9df commit 3515d82
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion examples/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ alloy-provider.workspace = true
alloy-rpc-client.workspace = true
alloy-signer-wallet.workspace = true
alloy-sol-types.workspace = true
alloy-transport-http.workspace = true

eyre.workspace = true
reqwest.workspace = true
Expand Down
8 changes: 3 additions & 5 deletions examples/anvil/examples/deploy_contract_anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
use alloy_network::EthereumSigner;
use alloy_node_bindings::Anvil;
use alloy_primitives::U256;
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_signer_wallet::LocalWallet;
use alloy_sol_types::sol;
use alloy_transport_http::Http;
use eyre::Result;
use reqwest::Client;

// Codegen from embedded Solidity code and precompiled bytecode.
sol! {
Expand Down Expand Up @@ -38,10 +36,10 @@ async fn main() -> Result<()> {
let wallet: LocalWallet = anvil.keys()[0].clone().into();

// Create a provider with a signer and the network.
let http = Http::<Client>::new(anvil.endpoint().parse()?);
let http = anvil.endpoint().parse()?;
let provider = ProviderBuilder::new()
.signer(EthereumSigner::from(wallet))
.provider(RootProvider::new(RpcClient::new(http, true)));
.on_client(RpcClient::new_http(http));

println!("Anvil running at `{}`", anvil.endpoint());

Expand Down

0 comments on commit 3515d82

Please sign in to comment.