This is a set of payment streaming contracts for open source contributors working on public goods.
It combines Paul Razvan Berg's work on both Sablier and Foundry templates. We are enormously grateful to him for both of these meaningful exmaples of the kinds of public goods we love working with, and are interested in creating ourselves.
Note: while Paul's foundry template is licensed under MIT, we have followed the GPL-3.0 licensing for Sablier, as this holds the functionality we intend to use.
You can clone the repo and set it up manually:
git clone --recurse-submodules https://github.com/kernel-community/streams.git
cd streams
yarn
If you prefer to install using foundry directly:
forge init kernel-streams --template https://github.com/kernel-community/streams
cd kernel-streams
yarn # install Solhint, Prettier, and other Node.js deps
If this is your first time with Foundry, check out the installation instructions.
- Tests
- Deploy scripts
If you're interested in exploring Foundry in more detail, you should look at the Foundry Book. In particular, you may be interested in reading the Writing Tests tutorial.
This template comes with a set of sensible default configurations for you to use. These defaults can be found in the following files:
├── .editorconfig
├── .gitignore
├── .prettierignore
├── .prettierrc.yml
├── .solhint.json
├── .yarnrc.yml
├── foundry.toml
└── remappings.txt
This template is IDE agnostic, but for the best user experience, you may want to use it in VSCode alongside Juan Blanco's Solidity extension.
For guidance on how to integrate a Foundry project in VSCode, please refer to this guide.
To write a new test contract, you start by importing PRBTest and inherit from
it in your test contract. PRBTest comes with a pre-instantiated cheatcodes
environment accessible via the vm
property. If you would like to view the logs in the terminal output you can add the
-vvv
flag and use console.log.
This template comes with an example test contract Foo.t.sol.
This is a list of the most frequently needed commands.
Build the contracts:
$ forge build
Delete the build artifacts and cache directories:
$ forge clean
Compile the contracts:
$ forge build
Get a test coverage report:
$ forge coverage
Deploy to Anvil:
$ forge script script/DeployStreams.s.sol --broadcast --fork-url http://localhost:8545
For this script to work, you need to have a MNEMONIC
environment variable set to a valid
BIP39 mnemonic.
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
Format the contracts:
$ forge fmt
Get a gas report:
$ forge test --gas-report
Lint the contracts:
$ yarn lint
Run the tests:
$ forge test
- Forge: compile, test, fuzz, format, and deploy smart contracts
- PRBTest: modern collection of testing assertions and logging utilities
- Forge Std: collection of helpful contracts and cheatcodes for testing
- Solhint: linter for Solidity code
- Prettier Plugin Solidity: code formatter for non-Solidity files