Logo

dev-resources.site

for different kinds of informations.

Foundry - chisel

Published at
12/26/2023
Categories
100daystooffload
foundry
chisel
solidity
Author
stefanalfbo
Author
11 person written this
stefanalfbo
open
Foundry - chisel

The Chisel component in the Foundry toolkit is a very sophisticated REPL tool designed for Solidity. This tool is incredibly useful for rapidly evaluating Solidity code snippets in a local or forked network environment.

As an integral component of the Foundry suite, Chisel is installed along with other tools like forge, cast, and anvil. So make sure you got foundry installed.



# Install it
curl -L https://foundry.paradigm.xyz | bash
# or update
foundryup


Enter fullscreen mode Exit fullscreen mode

When foundry is installed locally we can just fire up a terminal and type chisel to get started.

chisel start

As you can see, type !help to show available commands. To quit the REPL you will have use the command !quit. The common theme is the use of ! as prefix for all commands.

Lets start the test drive with chisel by playing with some expressions.

Simple expression

We can see that if we do the expression 1337 + 42 in Solidity we will get the result 1379 of the type uint and in hex it will be 0x0000000000000000000000000000000000000000000000000000000000000563 (as a 32 byte word or 256 bit).

In the REPL we can tinker with any Solidity code that we might think of. Here is an example of some testing with the Solidity function require.

require

This make it very easy to try something out or if you just want to explore something in Solidity.

It is also possible to save your session so you can go back to it at a later time. The command for that is !s or !save.

Save session

Now you can quit the session, !q, and in the terminal type chisel list to list all your saved sessions in chisel.

Chisel list

By using the load command when starting a chisel session you can load any of the earlier saved sessions. When loaded you can use the session command !source to display the source code of the loaded/current session.

chisel load

Other notable features of chisel is the possibility to fork a network, !fork <rpc-url> and toggling traces, !traces.

traces

We have only scratched the surface of the tool yet, but I hope you will explore it more either via Foundry book or its GitHub page.

Happy REPLing

foundry Article's
24 articles in total
Favicon
Mainnet Forking in Foundry
Favicon
Foundry tutorial para inciantes
Favicon
How to deploy smart contracts using Foundry
Favicon
The best way to import your private key in Foundry
Favicon
Streamline Your Smart Contract Development with Foundry
Favicon
Developer’s Guide to ERC-4337 #1 | Developing Simple Account
Favicon
How to write and compile smart contracts in Foundry
Favicon
How to Install Foundry on Windows/macOS/Linux
Favicon
Build a Multi-Payment DApp on Morph with Foundry
Favicon
How I Built a Decentralized Crowdfunding App with Foundry(incl. unit tests)
Favicon
Cómo desplegar y verificar un contrato inteligente en la blockchain de Mode usando Foundry
Favicon
How to Deploy and Verify a Smart Contract on Mode's Blockchain using Foundry
Favicon
Ethereum Development: Foundry or Hardhat
Favicon
Deploy Upgradeable Smart Contracts with Foundry and OpenZeppelin
Favicon
Foundry - chisel
Favicon
Introduction to smart contract development using Foundry
Favicon
Foundry Test : ERC721 SOL (Postmortem)
Favicon
Deploy a smart contract to an arbitrary address
Favicon
Installing foundry toolchain on windows.
Favicon
Setup Smart Contract Development with Foundry and Thirdweb
Favicon
Compiling and testing Vyper contract using Foundry
Favicon
Foundry – Solidity Tests, Fuzzing and so much more!
Favicon
Foundry Vs Hardhat
Favicon
使用Foundry,感受快,rust对写合约的支持

Featured ones: