alloy-rs / alloy-rs/alloy

[Feature] Easier way to sign transactions with an external wallet + existing provider

Abierto
#2,829 2 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Rust
Estrellas
1.3k
Forks
668
Merge medio
2 d 2 h
PR fusionados (30 d)
29

Descripción

### Component

provider, pubsub

### Describe the feature you would like

## Problem

I’m trying to interact with a contract bound via Alloy, where the provider is configured with the recommended fillers (so I can omit nonce, gas, fee fields etc.).

However, when I want to sign a transaction with a different wallet (not the one bound to the provider), I run into problems:

```
let tx = my_smart_contract
.call_function(/* args */)
.into_transaction_request()
.nonce(
my_smart_contract
.provider()
.get_transaction_count(from_account.address().to_alloy())
.await? + 1,
)
.with_gas_limit(21_000)
.with_max_priority_fee_per_gas(1_000_000_000)
.with_max_fee_per_gas(20_000_000_000)
.build(&wallet);

my_smart_contract
.provider()
.send_raw_transaction(&tx.encoded_2718())
.await?;
```

This works, but only if I manually set nonce/fees each time.
I’d like to avoid hardcoding values and refetching the nonce manually.
If those fields are not set, I get a `missing ["nonce", "gas_limit", "max_fee_per_gas", "max_priority_fee_per_gas"] fields` error.

I tried wrapping the provider with a wallet filler:
```
let provider_with_wallet =
FillProvider::new(my_smart_contract.provider().clone(), WalletFiller::new(wallet.clone())).erased();

let my_smart_contract = MyContract::Instance::new(*zeroex.address(), provider_with_wallet);

let response = my_smart_contract
.call_function(/* args */)
.send()
.await?;
```
But this fails with:
```
local usage error: missing properties: [("Wallet", ["nonce", "gas_limit", "max_fee_per_gas", "max_priority_fee_per_gas"])]
```
It seems like the recommended fillers from the original provider are not being applied once I switch to `FillProvider`.

## Expected

There should be a straightforward way to:
- Reuse the provider’s fillers (nonce, gas, fees, etc.)
- Swap in a different signing wallet
- Call `.send()` directly on contract bindings without manually specifying tx fields

### Additional context

_No response_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.