> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.getfoundry.sh/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

## Chisel

Chisel is an interactive Solidity REPL (Read-Eval-Print Loop) for rapid prototyping and debugging. Write and execute Solidity code instantly without compiling full contracts.

When run inside a Foundry project, Chisel uses that project's configuration and dependencies.

### Key capabilities

| Feature | Description |
|---------|-------------|
| **Interactive execution** | Execute Solidity expressions and statements in real-time |
| **Variable inspection** | Inspect values, types, and raw stack/memory data |
| **Forking** | Fork any chain to interact with live contracts |
| **Session management** | Save, load, and export REPL sessions |
| **Project integration** | Access your project's contracts and dependencies |

### Common workflows

```bash [Start the REPL]
$ chisel
```

```bash [Fork mainnet]
$ chisel --fork-url https://ethereum.reth.rs/rpc
```

```bash [Evaluate without entering REPL]
$ chisel eval "uint256 x = 1 + 2; x"
```

```bash [Load a saved session]
$ chisel load my-session
```

```bash [List cached sessions]
$ chisel list
```

### Quick example

```solidity
➜ uint256 x = 10
➜ uint256 y = 20
➜ x + y
Type: uint256
├ Hex: 0x1e
├ Hex (full word): 0x1e
└ Decimal: 30
```

### Integer literal typing

Chisel follows Solidity's literal typing. A bare subtraction such as `1 - 2` is the rational constant -1, which Chisel displays as the smallest fitting type, `int8`. Encoding that value with `abi.encode` yields a 32-byte two's-complement word of `0xff…ff` — the same bit pattern as `type(uint256).max` if you read it as unsigned:

```solidity
➜ 1 - 2
Type: int8
├ Hex: 0xff
├ Hex (full word): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
└ Decimal: -1

➜ abi.encode(1 - 2)
Type: dynamic bytes
└ Data: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
```

That bit pattern is correct for signed `-1`. It is easy to mistake for unsigned wrap-around. Prefer an explicit cast when signedness matters:

```solidity
➜ int256(1) - int256(2)
Type: int256
├ Hex: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
├ Hex (full word): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
└ Decimal: -1
```

Checked `uint256` arithmetic reverts on underflow instead of wrapping, so `uint256(1) - uint256(2)` panics under the default Solidity `^0.8` checked math. Use `unchecked` (or an explicit wrap helper) only when wrap-around is intentional.

### Learn more

* [Session management](/chisel/session-management) — Save, load, and export sessions
* [Forking](/chisel/forking) — Interact with live chain state
* [Commands](/chisel/commands) — All available REPL commands
* [Reference](/reference/chisel/chisel) — Full CLI reference
