Skip to content

Commit 337a2cc

Browse files
authored
chore: improve documentation of individual binaries (#1371)
* start adding new docs * update refs * clean up * note * add anvil overview * fix list * fix spacing
1 parent 0fa273d commit 337a2cc

File tree

6 files changed

+224
-47
lines changed

6 files changed

+224
-47
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ As a small change in the Foundry CLIs can have a large impact on the book, most
7272

7373
Each output file has three anchors you can use:
7474

75-
**Display the command *and* the output**
75+
**Display the command _and_ the output**
7676

7777
```handlebars
7878
{{#include ../output/abc/xyz:all}}

src/SUMMARY.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# Forge Overview
2020

21-
- [Overview of Forge](forge/README.md)
21+
- [Forge](forge/README.md)
2222
- [Tests](./forge/tests.md)
2323
- [Writing Tests](./forge/writing-tests.md)
2424
- [Cheatcodes](./forge/cheatcodes.md)
@@ -45,15 +45,15 @@
4545

4646
# Cast Overview
4747

48-
- [Overview of Cast](./cast/README.md)
48+
- [Cast](./cast/README.md)
4949

5050
# Anvil Overview
5151

52-
- [Overview of Anvil](./anvil/README.md)
52+
- [Anvil](./anvil/README.md)
5353

5454
# Chisel Overview
5555

56-
- [Overview of Chisel](./chisel/README.md)
56+
- [Chisel](./chisel/README.md)
5757

5858
# Configuration
5959

src/anvil/README.md

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,91 @@
1-
## Overview of Anvil
1+
## Anvil
22

3-
Anvil is a local testnet node shipped with Foundry. You can use it for testing your contracts from frontends or for interacting over RPC.
3+
Anvil is a fast local Ethereum development node.
44

5-
Anvil is part of the Foundry suite and is installed alongside `forge`, `cast`, and `chisel`. If you haven't installed Foundry yet, see [Foundry installation](../getting-started/installation.md).
5+
Anvil is part of the Foundry suite and is installed alongside `forge`, `cast` and `chisel`. If you haven't installed Foundry
6+
yet, see [Foundry installation](../getting-started/installation.md).
67

7-
> Note: If you have an older version of Foundry installed, you'll need to re-install `foundryup` in order for Anvil to be downloaded.
8+
### Getting started
89

9-
### How to use Anvil
10+
To use Anvil, simply type `anvil`. To fork against a live Ethereum network run `anvil --fork-url <RPC_URL>`.
1011

11-
To use Anvil, simply type `anvil`. You should see a list of accounts and private keys available for use, as well as the address and port that the node is listening on.
12+
Let's fork Ethereum mainnet at the latest block:
1213

13-
Anvil is highly configurable. You can run `anvil -h` to see all the configuration options.
14+
```console
15+
$ anvil --fork-url https://eth.merkle.io
1416

15-
Some basic options are:
1617

17-
```bash
18-
# Number of dev accounts to generate and configure. [default: 10]
19-
anvil -a, --accounts <ACCOUNTS>
18+
_ _
19+
(_) | |
20+
__ _ _ __ __ __ _ | |
21+
/ _` | | '_ \ \ \ / / | | | |
22+
| (_| | | | | | \ V / | | | |
23+
\__,_| |_| |_| \_/ |_| |_|
2024

21-
# The EVM hardfork to use. [default: latest]
22-
anvil --hardfork <HARDFORK>
25+
0.2.0 (c4fcf12 2024-12-12T00:23:45.094165202Z)
26+
https://github.com/foundry-rs/foundry
2327

24-
# Port number to listen on. [default: 8545]
25-
anvil -p, --port <PORT>
28+
Available Accounts
29+
==================
30+
31+
(0) 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000.000000000000000000 ETH)
32+
(1) 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 (10000.000000000000000000 ETH)
33+
(2) 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC (10000.000000000000000000 ETH)
34+
(3) 0x90F79bf6EB2c4f870365E785982E1f101E93b906 (10000.000000000000000000 ETH)
35+
(4) 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 (10000.000000000000000000 ETH)
36+
(5) 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc (10000.000000000000000000 ETH)
37+
(6) 0x976EA74026E726554dB657fA54763abd0C3a0aa9 (10000.000000000000000000 ETH)
38+
(7) 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 (10000.000000000000000000 ETH)
39+
(8) 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f (10000.000000000000000000 ETH)
40+
(9) 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 (10000.000000000000000000 ETH)
41+
42+
Private Keys
43+
==================
44+
45+
(0) 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
46+
(1) 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
47+
(2) 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
48+
(3) 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6
49+
(4) 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
50+
(5) 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
51+
(6) 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e
52+
(7) 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356
53+
(8) 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
54+
(9) 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
55+
56+
Wallet
57+
==================
58+
Mnemonic: test test test test test test test test test test test junk
59+
Derivation path: m/44'/60'/0'/0/
60+
61+
62+
Fork
63+
==================
64+
Endpoint: https://eth.merkle.io
65+
Block number: 21387064
66+
Block hash: 0x904aee789b82ac0412448bc2ea9bb3774d10c2dae4a0e5b7f6451ac2ecd0787a
67+
Chain ID: 1
68+
69+
Base Fee
70+
==================
71+
72+
26049293674
73+
74+
Gas Limit
75+
==================
76+
77+
30000000
78+
79+
Genesis Timestamp
80+
==================
81+
82+
1734014216
83+
84+
Listening on 127.0.0.1:8545
2685
```
2786

87+
<br>
88+
2889
> 📚 **Reference**
2990
>
3091
> See the [`anvil` Reference](../reference/anvil/) for in depth information on Anvil and its capabilities.
31-

src/cast/README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,56 @@
1-
## Overview of Cast
1+
## Cast
22

3-
Cast is Foundry's command-line tool for performing Ethereum RPC calls. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line!
3+
Cast is a Swiss Army knife for interacting with Ethereum applications from the command line. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line!
44

5-
### How to use Cast
5+
The `cast` binary can be used both within and outside of a Foundry project.
66

7-
To use Cast, run the [`cast`](../reference/cast/cast.md) command followed by a subcommand:
7+
Cast is part of the Foundry suite and is installed alongside `forge`, `chisel`, and `anvil`. If you haven't installed Foundry
8+
yet, see [Foundry installation](../getting-started/installation.md).
89

9-
```bash
10-
$ cast <subcommand>
10+
### Getting started
11+
12+
Here are a few examples of what you can do:
13+
14+
**Check the latest block on Ethereum Mainnet**:
15+
16+
```sh
17+
cast block-number --rpc-url https://eth.merkle.io
18+
```
19+
20+
**Check the Ether balance of `vitalik.eth`**
21+
22+
```sh
23+
cast balance vitalik.eth --ether --rpc-url https://eth.merkle.io
24+
```
25+
26+
**Replay and trace a transaction**
27+
28+
```sh
29+
cast run 0x9c32042f5e997e27e67f82583839548eb19dc78c4769ad6218657c17f2a5ed31 --rpc-url https://eth.merkle.io
1130
```
1231

13-
#### Examples
32+
Optionally, pass `--etherscan-api-key <API_KEY>` to decode transaction traces using verified source maps, providing more detailed and human-readable information.
1433

15-
Let's use `cast` to retrieve the total supply of the DAI token:
34+
**Retrieve the total supply of the DAI token**
1635

17-
```bash
36+
```sh
1837
{{#include ../output/cast/cast-call:all}}
1938
```
2039

21-
`cast` also provides many convenient subcommands, such as for decoding calldata:
40+
**Decode calldata**
2241

23-
```bash
42+
```sh
2443
{{#include ../output/cast/cast-4byte-decode:all}}
2544
```
2645

27-
You can also use `cast` to send arbitrary messages. Here's an example of sending a message between two Anvil accounts.
46+
**Send messages between two Anvil accounts**
2847

29-
```bash
30-
$ cast send --private-key <Your Private Key> 0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc $(cast from-utf8 "hello world") --rpc-url http://127.0.0.1:8545/
48+
```sh
49+
cast send --private-key <PRIVATE_KEY> 0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc $(cast from-utf8 "hello world") --rpc-url http://127.0.0.1:8545/
3150
```
3251

3352
<br>
3453

3554
> 📚 **Reference**
36-
>
55+
>
3756
> See the [`cast` Reference](../reference/cast/) for a complete overview of all the available subcommands.

src/chisel/README.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,56 @@
1-
## Overview of Chisel
1+
## Chisel
22

3-
Chisel is an advanced Solidity REPL shipped with Foundry. It can be used to quickly test the behavior of Solidity snippets
4-
on a local or forked network.
3+
Chisel is a fast, utilitarian, and verbose Solidity REPL.
4+
5+
The `chisel` binary can be used both within and outside of a Foundry project.
6+
If the binary is executed in a Foundry project root, Chisel will inherit the project's configuration options.
57

68
Chisel is part of the Foundry suite and is installed alongside `forge`, `cast`, and `anvil`. If you haven't installed Foundry
7-
yet, see [Foundry installation](../getting-started/installation.md).
9+
yet, see [Foundry installation](../getting-started/installation.md).
10+
11+
### Getting started
12+
13+
To use Chisel, simply type `chisel`.
14+
15+
```sh
16+
chisel
17+
```
18+
19+
From here, start writing Solidity code! Chisel will offer verbose feedback on each input.
820

9-
> Note: If you have an older version of Foundry installed, you'll need to re-install `foundryup` in order for Chisel to be downloaded.
21+
Create a variable `a` and query it:
1022

11-
### How to use Chisel
23+
```console
24+
uint256 a = 123;
25+
a
26+
Type: uint256
27+
├ Hex: 0x7b
28+
├ Hex (full word): 0x000000000000000000000000000000000000000000000000000000000000007b
29+
└ Decimal: 123
30+
```
1231

13-
To use Chisel, simply type `chisel`. From there, start writing Solidity code! Chisel will offer verbose feedback on each input.
32+
Finally, run `!source` to see `a` was applied:
1433

15-
Chisel can be used both within and outside of a foundry project. If the binary is executed in a Foundry project root, Chisel will
16-
inherit the project's configuration options.
34+
```solidity
35+
// SPDX-License-Identifier: UNLICENSED
36+
pragma solidity ^0.8.28;
37+
38+
import {Vm} from "forge-std/Vm.sol";
39+
40+
contract REPL {
41+
Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
42+
43+
/// @notice REPL contract entry point
44+
function run() public {
45+
uint256 a = 123;
46+
}
47+
}
48+
```
1749

1850
To see available commands, type `!help` within the REPL.
1951

52+
<br>
53+
2054
> 📚 **Reference**
2155
>
2256
> See the [`chisel` Reference](../reference/chisel/) for in depth information on Chisel and its capabilities.
23-

src/forge/README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1-
## Overview of Forge
1+
## Forge
22

33
Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts.
4+
5+
Forge is part of the Foundry suite and is installed alongside `cast`, `chisel`, and `anvil`. If you haven't installed Foundry
6+
yet, see [Foundry installation](../getting-started/installation.md).
7+
8+
### Getting started
9+
10+
The best way to understand Forge is to simply try it (in less than 30 seconds!).
11+
12+
First, let's initialize a new `counter` example repository:
13+
14+
```sh
15+
$ forge init counter
16+
```
17+
18+
Next `cd` into `counter` and build :
19+
20+
```sh
21+
$ forge build
22+
```
23+
24+
```console
25+
[⠊] Compiling...
26+
[⠔] Compiling 27 files with Solc 0.8.28
27+
[⠒] Solc 0.8.28 finished in 452.13ms
28+
Compiler run successful!
29+
```
30+
31+
Let's [test](https://book.getfoundry.sh/forge/tests#tests) our contracts:
32+
33+
```sh
34+
$ forge test
35+
```
36+
37+
```console
38+
[⠊] Compiling...
39+
No files changed, compilation skipped
40+
41+
Ran 2 tests for test/Counter.t.sol:CounterTest
42+
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 31121, ~: 31277)
43+
[PASS] test_Increment() (gas: 31293)
44+
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 5.35ms (4.86ms CPU time)
45+
46+
Ran 1 test suite in 5.91ms (5.35ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)
47+
```
48+
49+
Finally, let's run our deployment script:
50+
51+
```sh
52+
$ forge script script/Counter.s.sol
53+
```
54+
55+
```console
56+
[⠊] Compiling...
57+
No files changed, compilation skipped
58+
Script ran successfully.
59+
Gas used: 109037
60+
61+
If you wish to simulate on-chain transactions pass a RPC URL.
62+
```
63+
64+
<br>
65+
66+
> 📚 **Reference**
67+
>
68+
> See the [`forge` Reference](../reference/forge/) for a complete overview of all the available subcommands.

0 commit comments

Comments
 (0)