Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion vocs/docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ import { HomePage } from "vocs";
# Common Actions

Networked snippets read `RPC_URL` (or `WS_URL` for WebSocket examples) from the environment. This
keeps credentials out of source control and lets you choose the node provider.
keeps credentials out of source control and lets you choose the node provider. Snippets that start
Anvil from Rust, such as the mainnet fork in `write_contract.rs`, need the `node-bindings` feature
in addition to the defaults:

```bash
cargo add alloy --features node-bindings
```

:::code-group

Expand Down
17 changes: 14 additions & 3 deletions vocs/docs/pages/introduction/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ cargo add alloy

## Quick Start

The default features cover the first example, which connects to an Anvil node you start yourself.
The second example starts and controls Anvil from Rust, which requires the `node-bindings` feature
and the [`anvil`](https://getfoundry.sh) binary on your `PATH`. The third example subscribes over
WebSocket, which requires `provider-ws`. Enable both to run every example on this page:

```bash [cargo]
cargo add alloy --features node-bindings,provider-ws
```

### 1. Sending Transactions

This example shows how to send 100 ETH using the [`TransactionBuilder`](/transactions/using-the-transaction-builder) on a local anvil node
This example shows how to send 100 ETH using the [`TransactionBuilder`](/transactions/using-the-transaction-builder) on a local anvil node. Start the node with `anvil` in a separate terminal before running it:

```rust
use alloy::{
Expand Down Expand Up @@ -80,7 +89,8 @@ async fn main() -> Result<(), Box<dyn Error>> {

### 2. Interacting with Smart Contracts

Alloy's `sol!` macro makes working with smart contracts intuitive by letting you write Solidity directly in Rust:
Alloy's `sol!` macro makes working with smart contracts intuitive by letting you write Solidity directly in Rust.
This example forks mainnet into a local Anvil instance with `connect_anvil_with_config` and funds the signer through the `AnvilApi` extension trait, both of which need the `node-bindings` feature. Set `RPC_URL` to a mainnet RPC endpoint before running it:

```rust
use alloy::{
Expand Down Expand Up @@ -165,7 +175,8 @@ async fn main() -> Result<(), Box<dyn Error>> {

### 3. Monitoring Blockchain Activity

This example shows how to monitor blocks and track the [WETH](https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) balance of a [Uniswap V3 WETH-USDC](https://etherscan.io/address/0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8) contract in real-time:
This example shows how to monitor blocks and track the [WETH](https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) balance of a [Uniswap V3 WETH-USDC](https://etherscan.io/address/0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8) contract in real-time.
It needs the `provider-ws` feature, the `futures-util` crate for `StreamExt`, and `WS_URL` set to a WebSocket endpoint:

:::code-group

Expand Down
9 changes: 9 additions & 0 deletions vocs/docs/pages/introduction/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ use alloy::{
};
```

The `node_bindings` module, together with the `ProviderBuilder::connect_anvil*` helpers, is only
available with the `node-bindings` feature, which the default feature set does not enable. Add it
when you want to start Anvil, Geth, or Reth from Rust, for example to run the
[getting started](/introduction/getting-started) examples:

```sh
cargo add alloy --features node-bindings
```

### Next steps

- [Choose a task-oriented path](/introduction/choose-a-path).
Expand Down
4 changes: 2 additions & 2 deletions vocs/docs/pages/reference/feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ requirements are additive, so compile every intended target after changing them.
| Mnemonics or keystores | `signer-mnemonic`, `signer-keystore` | Add to `signer-local` behavior |
| AWS KMS, GCP KMS, or Turnkey | `signer-aws`, `signer-gcp`, `signer-turnkey` | Each integration is independent |
| Ledger or Trezor | `signer-ledger`, `signer-trezor` | Ledger also has browser and Node variants |
| Anvil process helpers | `provider-anvil-node` | Includes provider Anvil RPC and node bindings; not in `full` |
| Standalone node bindings | `node-bindings` | Re-exports process bindings without provider helpers |
| Start Anvil, Geth, or Reth from Rust | `node-bindings` | Enables the process bindings, `ProviderBuilder::connect_anvil*`, and the `AnvilApi` trait; not in `full` |
| Anvil helpers plus Anvil RPC types | `provider-anvil-node` | `node-bindings` plus `provider-anvil-api`, which adds the `anvil` RPC types |
| `debug_*` RPC methods | `provider-debug-api` | Also enables debug and trace RPC types |
| `trace_*` RPC methods | `provider-trace-api` | Enables trace RPC types |
| `txpool_*` RPC methods | `provider-txpool-api` | Enables txpool RPC types |
Expand Down
Loading