Là một dạng shell dùng để chạy code Solidity. Use case của nó là để thay thế Remix nhằm chạy một contract nào đó line-by-line.
Chisel có thể được dùng ở bên ngoài một project Foundry.
Ví dụ sử dụng chisel:
❯ chisel
Welcome to Chisel! Type `!help` to show available commands.
➜ uint256 cat = 1;
➜ cat
Type: uint256
├ Hex: 0x1
├ Hex (full word): 0x0000000000000000000000000000000000000000000000000000000000000001
└ Decimal: 1
➜ uint256 dog = 2;
➜ cat + dog
Type: uint256
├ Hex: 0x3
├ Hex (full word): 0x0000000000000000000000000000000000000000000000000000000000000003
└ Decimal: 3
➜ uint256 frog = 10;
➜ require(frog > cat)
➜ ;
Error: Compiler errors:
Error (9182): Function, variable, struct or modifier declaration expected.
--> ReplContract.sol:10:5:
|
10 | ;
| ^
➜ require(frog > cat);
➜ require(cat > frog);
Traces:
[191] 0xBd770416a3345F91E4B34576cb804a576fa48EB1::run()
└─ ← [Revert] EvmError: Revert
Error: Failed to execute REPL contract!
➜
(To exit, press Ctrl+C again)
➜Một ví dụ khác dùng để compare hash của 2 string:
❯ chisel
Welcome to Chisel! Type `!help` to show available commands.
➜ string memory cat = "cat";
➜ string memory dog = "dog";
➜ cat
Type: string
├ UTF-8: cat
├ Hex (Memory):
├─ Length ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000003
├─ Contents ([0x20:..]): 0x6361740000000000000000000000000000000000000000000000000000000000
├ Hex (Tuple Encoded):
├─ Pointer ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000020
├─ Length ([0x20:0x40]): 0x0000000000000000000000000000000000000000000000000000000000000003
└─ Contents ([0x40:..]): 0x6361740000000000000000000000000000000000000000000000000000000000
➜ dog
Type: string
├ UTF-8: dog
├ Hex (Memory):
├─ Length ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000003
├─ Contents ([0x20:..]): 0x646f670000000000000000000000000000000000000000000000000000000000
├ Hex (Tuple Encoded):
├─ Pointer ([0x00:0x20]): 0x0000000000000000000000000000000000000000000000000000000000000020
├─ Length ([0x20:0x40]): 0x0000000000000000000000000000000000000000000000000000000000000003
└─ Contents ([0x40:..]): 0x646f670000000000000000000000000000000000000000000000000000000000