-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c52f4a
commit eeca2a5
Showing
6 changed files
with
197 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,56 @@ | ||
## Overview of Chisel | ||
|
||
Chisel is an advanced Solidity REPL shipped with Foundry. It can be used to quickly test the behavior of Solidity snippets | ||
on a local or forked network. | ||
Chisel is a fast, utilitarian, and verbose Solidity REPL. | ||
|
||
The `chisel` binary can be used both within and outside of a Foundry project. | ||
If the binary is executed in a Foundry project root, Chisel will inherit the project's configuration options. | ||
|
||
Chisel is part of the Foundry suite and is installed alongside `forge`, `cast`, and `anvil`. If you haven't installed Foundry | ||
yet, see [Foundry installation](../getting-started/installation.md). | ||
yet, see [Foundry installation](../getting-started/installation.md). | ||
|
||
### Getting Started | ||
|
||
To use Chisel, simply type `chisel`. | ||
|
||
```sh | ||
chisel | ||
``` | ||
|
||
From here, start writing Solidity code! Chisel will offer verbose feedback on each input. | ||
|
||
> Note: If you have an older version of Foundry installed, you'll need to re-install `foundryup` in order for Chisel to be downloaded. | ||
Create a variable `a` and query it: | ||
|
||
### How to use Chisel | ||
```console | ||
➜ uint256 a = 123; | ||
➜ a | ||
Type: uint256 | ||
├ Hex: 0x7b | ||
├ Hex (full word): 0x000000000000000000000000000000000000000000000000000000000000007b | ||
└ Decimal: 123 | ||
``` | ||
|
||
To use Chisel, simply type `chisel`. From there, start writing Solidity code! Chisel will offer verbose feedback on each input. | ||
Finally, run `!source` to see `a` was applied: | ||
|
||
Chisel can be used both within and outside of a foundry project. If the binary is executed in a Foundry project root, Chisel will | ||
inherit the project's configuration options. | ||
```solidity | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.28; | ||
import {Vm} from "forge-std/Vm.sol"; | ||
contract REPL { | ||
Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); | ||
/// @notice REPL contract entry point | ||
function run() public { | ||
uint256 a = 123; | ||
} | ||
} | ||
``` | ||
|
||
To see available commands, type `!help` within the REPL. | ||
|
||
### Reference | ||
|
||
> 📚 **Reference** | ||
> | ||
> See the [`chisel` Reference](../reference/chisel/) for in depth information on Chisel and its capabilities. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,64 @@ | ||
## Overview of Forge | ||
## Forge | ||
|
||
Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts. | ||
|
||
Forge is part of the Foundry suite and is installed alongside `cast`, `chisel`, and `anvil`. If you haven't installed Foundry | ||
yet, see [Foundry installation](../getting-started/installation.md). | ||
|
||
### Getting Started | ||
|
||
The best way to understand Forge is to simply try it (in less than 30 seconds!). | ||
|
||
First, let's initialize a new `counter` example repository: | ||
|
||
```sh | ||
$ forge init counter | ||
``` | ||
|
||
Next `cd` into `counter` and build : | ||
|
||
```sh | ||
$ forge build | ||
``` | ||
|
||
```console | ||
[⠊] Compiling... | ||
[⠔] Compiling 27 files with Solc 0.8.28 | ||
[⠒] Solc 0.8.28 finished in 452.13ms | ||
Compiler run successful! | ||
``` | ||
|
||
Let's [test](https://book.getfoundry.sh/forge/tests#tests) our contracts: | ||
|
||
```sh | ||
$ forge test | ||
``` | ||
|
||
```console | ||
[⠊] Compiling... | ||
No files changed, compilation skipped | ||
|
||
Ran 2 tests for test/Counter.t.sol:CounterTest | ||
[PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 31121, ~: 31277) | ||
[PASS] test_Increment() (gas: 31293) | ||
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 5.35ms (4.86ms CPU time) | ||
|
||
Ran 1 test suite in 5.91ms (5.35ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests) | ||
``` | ||
|
||
Finally, let's run our deployment script: | ||
|
||
```sh | ||
$ forge script script/Counter.s.sol | ||
``` | ||
|
||
```console | ||
[⠊] Compiling... | ||
No files changed, compilation skipped | ||
Script ran successfully. | ||
Gas used: 109037 | ||
|
||
If you wish to simulate on-chain transactions pass a RPC URL. | ||
``` | ||
|
||
### Features |