alloy-rs / alloy

Transports, Middleware, and Networks for the Alloy project
https://alloy.rs
Apache License 2.0
667 stars 241 forks source link

[Bug] Transferring 1 ether using anvil but received 1 ether and 21000 wei #1570

Closed Confucian-e closed 1 month ago

Confucian-e commented 1 month ago

Component

node-bindings

What version of Alloy are you on?

v0.5.4

Operating System

macOS (Apple Silicon)

Describe the bug

I'm transferring 1 ether using anvil but received 1 ether and 21000 wei.

    // setup anvil node
    let provider = ProviderBuilder::new()
        .with_recommended_fillers()
        .on_anvil_with_wallet();

    let receiver = Address::ZERO;
    let balance_before = provider.get_balance(receiver).await.unwrap();

    // send tx
    let value = parse_ether("1").unwrap();
    let tx = TransactionRequest::default()
        .with_to(receiver)
        .with_value(value);

    let tx_hash = provider
        .send_transaction(tx)
        .await
        .unwrap()
        .watch()
        .await
        .unwrap();

    println!("tx_hash: {:?}", tx_hash);

    let balancer_after = provider.get_balance(receiver).await.unwrap();

    let balance_change = balancer_after - balance_before;
    println!("balance_change: {:?}", balance_change);

The value of balance_change is 1000000000000021000.

mattsse commented 1 month ago

you sent to zero address, by default the zero address is the fee recipient for that block hence the additional balance.

miner 0x0000000000000000000000000000000000000000