Skip to content

Commit

Permalink
fix: set tx nonce and sender
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Jul 18, 2024
1 parent 30d8e98 commit 9fc9bb0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bolt-spammer-helder/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::str::FromStr;

use alloy::{
eips::eip2718::Encodable2718,
hex,
network::{EthereumWallet, TransactionBuilder},
primitives::{keccak256, Address},
providers::{Provider, ProviderBuilder},
signers::{local::PrivateKeySigner, Signer},
};
use beacon_api_client::mainnet::Client as BeaconApiClient;
Expand All @@ -27,7 +26,7 @@ use crate::{
struct Opts {
/// EL node URL to send transactions to
#[clap(short = 'p', long, default_value = "https://rpc.helder-devnets.xyz", env)]
el_provider_url: String,
el_provider_url: Url,
/// CL node URL to fetch the beacon chain info from
#[clap(short = 'c', long, default_value = "http://localhost:4000", env)]
beacon_client_url: Url,
Expand All @@ -47,15 +46,17 @@ async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
tracing::info!("starting bolt-spammer-helder");

let _ = dotenvy::dotenv()?;
let _ = dotenvy::dotenv();
let opts = Opts::parse();

let wallet: PrivateKeySigner = opts.private_key.parse().expect("should parse private key");
let transaction_signer: EthereumWallet = wallet.clone().into();
let provider = ProviderBuilder::new().on_http(opts.el_provider_url.clone());
let sender = wallet.address();

let beacon_api_client = BeaconApiClient::new(opts.beacon_client_url);

let registry = BoltRegistry::new(Url::from_str(&opts.el_provider_url)?, opts.registry_address);
let registry = BoltRegistry::new(opts.el_provider_url, opts.registry_address);

let current_slot = current_slot(&beacon_api_client).await?;

Expand Down Expand Up @@ -87,7 +88,9 @@ async fn main() -> Result<()> {
}
};

let tx = if opts.blob { generate_random_blob_tx() } else { generate_random_tx() };
let mut tx = if opts.blob { generate_random_blob_tx() } else { generate_random_tx() };
tx.set_from(sender);
tx.set_nonce(provider.get_transaction_count(sender).await?);

let tx_signed = tx.build(&transaction_signer).await?;
let tx_hash = tx_signed.tx_hash().to_string();
Expand Down

0 comments on commit 9fc9bb0

Please sign in to comment.