Skip to content

Commit

Permalink
update to 218ece4
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Mar 19, 2024
1 parent 752ccd6 commit 21d8c01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 6 additions & 7 deletions examples/contracts/examples/deploy_from_artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use alloy_network::EthereumSigner;
use alloy_node_bindings::Anvil;
use alloy_primitives::{U256, U64};
use alloy_primitives::U256;
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
use alloy_rpc_client::RpcClient;
use alloy_signer_wallet::LocalWallet;
Expand Down Expand Up @@ -42,25 +42,24 @@ async fn main() -> Result<()> {
let contract_builder = Counter::deploy_builder(&provider);
let estimate = contract_builder.estimate_gas().await?;
let contract_address =
contract_builder.gas(estimate).gas_price(base_fee).nonce(U64::from(0)).deploy().await?;
contract_builder.gas(estimate).gas_price(base_fee).nonce(0).deploy().await?;

println!("Deployed contract at address: {:?}", contract_address);

let contract = Counter::new(contract_address, &provider);

let estimate = contract.setNumber(U256::from(42)).estimate_gas().await?;
let builder =
contract.setNumber(U256::from(42)).nonce(U64::from(1)).gas(estimate).gas_price(base_fee);
let builder = contract.setNumber(U256::from(42)).nonce(1).gas(estimate).gas_price(base_fee);
let receipt = builder.send().await?.get_receipt().await?;

println!("Set number to 42: {:?}", receipt.transaction_hash.unwrap());
println!("Set number to 42: {:?}", receipt.transaction_hash);

// Increment the number to 43.
let estimate = contract.increment().estimate_gas().await?;
let builder = contract.increment().nonce(U64::from(2)).gas(estimate).gas_price(base_fee);
let builder = contract.increment().nonce(2).gas(estimate).gas_price(base_fee);
let receipt = builder.send().await?.get_receipt().await?;

println!("Incremented number: {:?}", receipt.transaction_hash.unwrap());
println!("Incremented number: {:?}", receipt.transaction_hash);

// Retrieve the number, which should be 43.
let Counter::numberReturn { _0 } = contract.number().call().await?;
Expand Down
11 changes: 5 additions & 6 deletions examples/contracts/examples/deploy_from_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,24 @@ async fn main() -> Result<()> {
let contract_builder = Counter::deploy_builder(&provider);
let estimate = contract_builder.estimate_gas().await?;
let contract_address =
contract_builder.gas(estimate).gas_price(base_fee).nonce(U64::from(0)).deploy().await?;
contract_builder.gas(estimate).gas_price(base_fee).nonce(0).deploy().await?;

println!("Deployed contract at address: {:?}", contract_address);

let contract = Counter::new(contract_address, &provider);

let estimate = contract.setNumber(U256::from(42)).estimate_gas().await?;
let builder =
contract.setNumber(U256::from(42)).nonce(U64::from(1)).gas(estimate).gas_price(base_fee);
let builder = contract.setNumber(U256::from(42)).nonce(1).gas(estimate).gas_price(base_fee);
let receipt = builder.send().await?.get_receipt().await?;

println!("Set number to 42: {:?}", receipt.transaction_hash.unwrap());
println!("Set number to 42: {:?}", receipt.transaction_hash);

// Increment the number to 43.
let estimate = contract.increment().estimate_gas().await?;
let builder = contract.increment().nonce(U64::from(2)).gas(estimate).gas_price(base_fee);
let builder = contract.increment().nonce(2).gas(estimate).gas_price(base_fee);
let receipt = builder.send().await?.get_receipt().await?;

println!("Incremented number: {:?}", receipt.transaction_hash.unwrap());
println!("Incremented number: {:?}", receipt.transaction_hash);

// Retrieve the number, which should be 43.
let Counter::numberReturn { _0 } = contract.number().call().await?;
Expand Down

0 comments on commit 21d8c01

Please sign in to comment.