Skip to content

[FEAT] Add examples of using era-test-node with alloy #300

Closed
@mm-zk

Description

@mm-zk

🌟 Feature Request

📝 Description

Alloy is the replacement for ethers.rs - and we should make sure that it is nicely integrated with era-test-node.

Make sure that we expose the rich wallets, and that transactions confirmations work correctly.

Rationale

We had reports that code below doesn't work well:

sol!(
    #[sol(rpc)]
    Counter,
    "out/Counter.sol/Counter.json"
);

async fn call_contract(rpc_url: &str, wallet_pk: &str, contract_addr: &str) -> Result<()> {
    // We assume that anvil/era-test-node are running externally and we've deployed the contract there.
    let wallet = EthereumWallet::new(PrivateKeySigner::from_str(wallet_pk)?);
    let provider = ProviderBuilder::new()
        .with_recommended_fillers()
        .wallet(wallet)
        .on_http(rpc_url.parse()?);

    let counter = Counter::new(contract_addr.parse()?, provider);
    let tx_hash = counter
        .setNumber(U256::from(42))
        .send()
        .await?
        .watch()
        .await?;
    println!("Tx hash is {tx_hash}");

    let number = counter.number().call().await?._0.to_string();
    println!("Number is {number}");

    Ok(())
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature ➕Feature itemmedium 🚩Indicates moderately difficult itemp2 🟡Indicates moderately high priority item

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions