Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] only replay-protected (EIP-155) transactions allowed over RPC #527

Closed
NicolasWent opened this issue Apr 13, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@NicolasWent
Copy link
Contributor

NicolasWent commented Apr 13, 2024

Component

network, json-rpc, provider, pubsub

What version of Alloy are you on?

rev = "8cb0307"

Operating System

Linux

Describe the bug

Hello,

I have tried to run the deploy_from_contract.rs example, but instead of using Anvil, I have tried to deploy it on ethereum sepolia testnet

Code to reproduce
use std::env;

use alloy_primitives::U256;
use alloy_provider::{network::EthereumSigner, Provider, ProviderBuilder};
use alloy_signer_wallet::LocalWallet;
use alloy_sol_types::sol;
use dotenv::dotenv;
use eyre::Result;

sol! {
    #[allow(missing_docs)]
    // solc v0.8.24; solc a.sol --via-ir --optimize --bin
    #[sol(rpc, bytecode="608080604052346100155760d2908161001a8239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c9081633fb5c1cb1460865781638381f58a14606f575063d09de08a146039575f80fd5b34606b575f366003190112606b575f545f1981146057576001015f55005b634e487b7160e01b5f52601160045260245ffd5b5f80fd5b34606b575f366003190112606b576020905f548152f35b34606b576020366003190112606b576004355f5500fea2646970667358221220bdecd3c1dd631eb40587cafcd6e8297479db76db6a328e18ad1ea5b340852e3864736f6c63430008180033")]
    contract Counter {
        uint256 public number;

        function setNumber(uint256 newNumber) public {
            number = newNumber;
        }

        function increment() public {
            number++;
        }
    }
}

#[tokio::main]
async fn main() -> Result<()> {
    dotenv().ok();
    let signer: LocalWallet = env::var("WALLET")
        .expect("Missing 'WALLET' environment variable")
        .parse()?;
    let rpc_url = env::var("HTTP_RPC")
        .expect("Missing HTTP_RPC environment variable")
        .parse()?;
    let provider = ProviderBuilder::new()
        .signer(EthereumSigner::from(signer.clone()))
        .on_http(rpc_url)?;

    let base_fee = provider.get_gas_price().await?;

    let contract_builder = Counter::deploy_builder(&provider);
    let estimate = contract_builder.estimate_gas().await?;
    // Crashes here with error: Error: server returned an error response: error code -32000: only replay-protected (EIP-155) transactions allowed over RPC
    let contract_address = contract_builder
        .gas(estimate)
        .gas_price(base_fee)
        .nonce(
            provider
                .get_transaction_count(signer.address(), None)
                .await?,
        )
        .deploy()
        .await?;

       // other interactions from the example but the code crashes above
Cargo.toml
[package]
name = "send-trx-minimal"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dotenv = "0.6"
eyre = "0.6"
tokio = { version = "1.37", features = ["full"] }

alloy-primitives = "0.7.0"
alloy-sol-types = { version = "0.7.0", features = ["json"] }

alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "8cb0307" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy.git", rev = "8cb0307" }
alloy-contract = { git = "https://github.com/alloy-rs/alloy.git", rev = "8cb0307" }
alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy.git", rev = "8cb0307" }

According to this post we need to specify the chain-id field, but I can't specify the chain-id in the CallBuilder

@mattsse
Copy link
Member

mattsse commented Apr 14, 2024

Thanks for flagging, we're missing important setters on CallBuilder: #534

According to this post we need to specify the chain-id field, but I can't specify the chain-id in the CallBuilder

this will be handled automatically with the new filler API, see docs and alloy-rs/examples#50

@prestwich
Copy link
Member

believe this is closed by #726 and by the fillers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants