Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maurelian/solidity-sandbox
A forkable template repo for easily writing and testing toy contracts
https://github.com/maurelian/solidity-sandbox
forge foundry solidity
Last synced: 1 day ago
JSON representation
A forkable template repo for easily writing and testing toy contracts
- Host: GitHub
- URL: https://github.com/maurelian/solidity-sandbox
- Owner: maurelian
- License: mit
- Created: 2022-02-16T22:58:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-24T02:07:31.000Z (10 months ago)
- Last Synced: 2024-10-31T11:43:15.322Z (9 days ago)
- Topics: forge, foundry, solidity
- Language: Solidity
- Homepage:
- Size: 1.39 MB
- Stars: 145
- Watchers: 3
- Forks: 28
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-web3-tools-and-dapps - Solidity Sandbox - This repo can be easily copied and used on Forge to test smart contracts using templates. (dApps directory / Smart Contract Tools)
README
# Solidity Sandbox
![Picture of a sandbox](./sandbox.png)
Just a simple [forge](https://book.getfoundry.sh/forge/) based repo for playing around with and
understanding solidity toy code.See how other's are using it:
- [maurelian's branch](https://github.com/maurelian/solidity-sandbox/tree/maurelian)
- [devtooligan's fork](https://github.com/devtooligan/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 can be chosen for testing. Replace `` with full or partial contract name:`forge test --match-contract ` or `forge test --mc `
## 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 empty test function. Just run the following replacing `` with the name of your test (file naming conventions apply, avoid spaces). Or omit the test name to invoke _interactive mode_.
```sh
./newTest.sh
```## 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!```bash
scratch() {
cd
bash newTest.sh $1
}
```