Skip to content

Commit

Permalink
add tx builder
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed May 7, 2024
1 parent e882b7d commit 47eeca0
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
- [Creating a WS provider](./building-with-alloy/connecting-to-a-blockchain/ws-provider.md)
- [Creating an IPC provider](./building-with-alloy/connecting-to-a-blockchain/ipc-provider.md)
- [Understanding Fillers](./building-with-alloy/understanding-fillers.md)
- [The Network abstraction](./building-with-alloy/the-network-abstraction.md)
- [Queries](./building-with-alloy/queries.md)
- [Transactions](./building-with-alloy/transactions/using-the-transaction-builder.md)
- [Sending a legacy transaction](./building-with-alloy/transactions/sending-a-legacy-transaction.md)
- [Using the Transaction Builder](./building-with-alloy/transactions/using-the-transaction-builder.md)
- [Sending an EIP-1559 transaction](./building-with-alloy/transactions/sending-an-EIP-1559-transaction.md)
- [Using access lists](./building-with-alloy/transactions/using-access-lists.md)
- [Sending a legacy transaction](./building-with-alloy/transactions/sending-a-legacy-transaction.md)
- [Sending an EIP-4844 transaction](./building-with-alloy/transactions/sending-an-EIP-4844-transaction.md)
- [Awaiting for receipts](./building-with-alloy/transactions/awaiting-for-receipts.md)
- [Using access lists](./building-with-alloy/transactions/using-access-lists.md)

# Examples

Expand Down
2 changes: 0 additions & 2 deletions src/building-with-alloy/queries.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Queries

TODO: text

{{#include ../examples/queries/query_contract_storage.md}}

{{#include ../examples/queries/query_deployed_bytecode.md}}
Expand Down
4 changes: 0 additions & 4 deletions src/building-with-alloy/the-network-abstraction.md

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Sending a legacy transaction

<!-- {{#include ../../examples/transactions/.md}} -->
{{#include ../../examples/transactions/send_legacy_tx.md}}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
## Sending an EIP-1559 transaction
## Sending an EIP-1559 transaction

{{#include ../../examples/transactions/send_eip1559_tx.md}}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
## Sending an EIP-4844 transaction
## Sending an EIP-4844 transaction

{{#include ../../examples/transactions/send_eip4844_tx.md}}
4 changes: 3 additions & 1 deletion src/building-with-alloy/transactions/using-access-lists.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
## Using access lists
## Using access lists

{{#include ../../examples/transactions/with_access_list.md}}
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
## Using the `TransactionBuilder`
## Using the `TransactionBuilder`

The [`TransactionBuilder`](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html) is a network specific transaction builder configurable with `.with_*` methods.

Common fields one can configure are:

- [with_from](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_from)
- [with_to](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_to)
- [with_nonce](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_nonce)
- [with_chain_id](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_chain_id)
- [with_value](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_value)
- [with_gas_limit](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_gas_limit)
- [with_max_priority_fee_per_gas](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_max_priority_fee_per_gas)
- [with_max_fee_per_gas](https://alloy-rs.github.io/alloy/alloy_network/transaction/builder/trait.TransactionBuilder.html#method.with_max_fee_per_gas)

It is generally recommended to use the builder pattern, as shown, rather than directly setting values (`with_to` versus `set_to`).

```rust,ignore
//! Example showing how to build a transaction using the `TransactionBuilder`
{{#include ../../../lib/examples/examples/transactions/examples/send_eip1559_tx.rs:2:}}
```

It is recommended to use the `.with_recommended_fillers()` method on the [ProviderBuilder](../connecting-to-a-blockchain/setting-up-a-provider.md) to automatically [fill fields](../understanding-fillers.md) for you.

{{#include ../../examples/fillers/recommended_fillers.md}}

0 comments on commit 47eeca0

Please sign in to comment.