Thank you for considering contributing to Hats Protocol. We welcome any contributions that can help improve the project, including bug reports, feature requests, and code changes.
- Fork the Project
- Install Foundry
- Compile the contracts, run
forge build
, and to test, runforge test
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request — see the checklist below for what your PR should include
Existing deployments of Hats Protocol can be found in Releases. To deploy Hats Protocol yourself (e.g., for testing):
- Install Foundry
- Compile the contracts, run
forge build
, and to test, runforge test
- Deploy using the Hats.s.sol script and follow the Foundry scripting instructions
Hats Protocol follows certain conventions, including:
- Use custom errors (rather than in-line require statement strings), added to HatsErrors.sol
- New events should be added to HatsEvents.sol
- All new public or external functions should be added to the appropriate interface file, such as IHats.sol or IHatsIdUtilities.sol
- We format all markdown according to the settings in .markdownlintrc
- All Solidity is formatted using Foundry's native formatter forge fmt, currently using the following settings (also viewable in foundry.toml):
forge fmt setting |
our value |
---|---|
line_length | 120 |
tab_width | 4 |
bracket_spacing | true |
int_types | long |
multiline_func_header | attributes_first |
quote_style | double |
number_underscore | thousands |
override_spacing | true |
wrap_comments | true |
All code changes should be accompanied by updates to documentation:
- Document all new functions (external and internal), data models, and state variables with Solidity NatSpec
- The above will be produced in an mdBook via Foundry's forge doc module
- Update the README and/or developer docs as needed
We also welcome contributions to the project's documentation itself!
We require that all new code changes are thoroughly tested to ensure that the project remains stable and reliable. When submitting a pull request, please make sure to:
- Write thorough unit tests for all new code
- Ensure that all tests (existing and new) are passing
- Track test coverage with Foundry's
forge coverage
module - Verify that contract sizes are under the EIP-170 limit when compiled with the optimizer set to at least
10_000
runs
In summary, before submitting a PR, please complete each of the following items. Items that are explicitly checked in our CI workflow are flagged with "(ci)".
- Thorough unit tests are written for all new code
- Update the test coverage tracker — run
forge coverage --report lcov
- Update the gas snapshot tracker — run
forge snapshot
- Ensure contract sizes are small enough to deploy — run
forge build --sizes
(ci) - Ensure all existing and new tests are passing — run
forge test
(ci) - Document all new Solidity code with NatSpec, and generate updated docs — run
forge doc
- Update the README with any new or changed functionality
- Ensure all markdown is formatted correctly — run
forge fmt
(ci)
If you have any questions or need assistance with contributing to the Hats Protocol, please feel free to reach out to the project maintainers. Contact information can be found in the README file.
Thank you for your contributions!