Skip to content

A forkable template repo for easily writing and testing toy contracts

License

Notifications You must be signed in to change notification settings

karmacoma-eth/halmos-sandbox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Halmos Sandbox

Picture of a sandbox

Just a simple forge-based repo for playing around with and understanding solidity toy code.

Based on maurelian's solidity-sandbox

Conventions

The whole purpose of this repo is to make it fast and easy to test stuff, and then keep the test code for future reference. Specific test contracts and functions can be selected:

halmos --contract <contract-name>
halmos --function <function-name>

Creating a new test

I don't want to have to think about avoiding contract naming collision, so each new test file is prefixed with a number, and all the contract names in that file have that same number as a suffix.

There's now a script to generate a new file with a contract and an empty test function. Just run the following replacing <test-name> with the name of your test (file naming conventions apply, avoid spaces). Or omit the test name to invoke interactive mode.

./newTest.sh <test-name>

Yul code

Occasionally it's helpful to generate the Yul intermediate representation to understand what's happening underneath the hood. In that case, I'll just use a command like the following to put the IR into the ./ir dir. Using a .sol extension gives pretty decent syntax highlighting for readability.

forge inspect Target16 ir >! ir/bytesArgLenCheck16.yul.sol

Yul code can be compiled with solc --strict-assembly.

Advanced Installation Tip

You can create a bash function that will change directories and call newTest. Add it to your .bashrc file so you can call scratch from anywhere!

scratch() {
  cd <path to solidity-sandbox>
  bash newTest.sh $1
}

About

A forkable template repo for easily writing and testing toy contracts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 99.6%
  • Shell 0.4%