├── .gas-snapshot ├── img └── forge-template.png ├── src └── Contract.sol ├── .env.example ├── .gitignore ├── remappings.txt ├── .gitmodules ├── foundry.toml ├── test └── Contract.t.sol ├── .github └── workflows │ ├── ci.yml │ └── lint.yml ├── LICENSE └── README.md /.gas-snapshot: -------------------------------------------------------------------------------- 1 | TestContract:testBar() (gas: 401) 2 | -------------------------------------------------------------------------------- /img/forge-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pollum-io/forge-template/HEAD/img/forge-template.png -------------------------------------------------------------------------------- /src/Contract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.13; 3 | 4 | contract Contract { } 5 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | GOERLI_RPC_URL= 2 | MAINNET_RPC_URL 3 | TESTNET_PRIVATE_KEY= 4 | MAINNET_PRIVATE_KEY= 5 | ETHERSCAN_API_KEY= 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | out/ 3 | .env 4 | .idea 5 | /node_modules/ 6 | /broadcast/ 7 | broadcast/** 8 | .DS_Store 9 | **/.DS_Store 10 | -------------------------------------------------------------------------------- /remappings.txt: -------------------------------------------------------------------------------- 1 | ds-test/=lib/forge-std/lib/ds-test/src/ 2 | forge-std/=lib/forge-std/src/ 3 | openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/ 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/forge-std"] 2 | path = lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | branch = v1.2.0 5 | [submodule "lib/openzeppelin-contracts"] 6 | path = lib/openzeppelin-contracts 7 | url = https://github.com/Openzeppelin/openzeppelin-contracts 8 | branch = v4.8.2 9 | -------------------------------------------------------------------------------- /foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'src' 3 | out = 'out' 4 | libs = ['lib'] 5 | solc = "0.8.13" 6 | gas_reports = ["Contract"] 7 | 8 | [rpc_endpoints] 9 | goerli = "${GOERLI_RPC_URL}" 10 | 11 | [etherscan] 12 | goerli = { key = "${ETHERSCAN_API_KEY}" } 13 | 14 | 15 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config -------------------------------------------------------------------------------- /test/Contract.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.13; 3 | 4 | import "forge-std/Test.sol"; 5 | 6 | import "src/Contract.sol"; 7 | 8 | contract TestContract is Test { 9 | Contract c; 10 | 11 | function setUp() public { 12 | c = new Contract(); 13 | } 14 | 15 | function testBar() public { 16 | assertEq(uint256(1), uint256(1), "ok"); 17 | } 18 | 19 | function testFoo(uint256 x) public { 20 | vm.assume(x < type(uint128).max); 21 | assertEq(x + x, x * 2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Forge Tests 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | 8 | env: 9 | FOUNDRY_PROFILE: ci 10 | 11 | jobs: 12 | run-ci: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install Foundry 18 | uses: foundry-rs/foundry-toolchain@v1 19 | with: 20 | version: nightly 21 | 22 | - name: Install deps 23 | run: forge install 24 | 25 | - name: Check gas snapshots 26 | run: forge snapshot --check 27 | 28 | - name: Run tests 29 | run: forge test 30 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | 8 | jobs: 9 | run-ci: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Install Foundry 15 | uses: foundry-rs/foundry-toolchain@v1 16 | with: 17 | version: nightly 18 | 19 | - name: Install deps 20 | run: forge install 21 | 22 | - name: Run Slither 23 | uses: crytic/slither-action@main 24 | id: slither 25 | continue-on-error: true 26 | with: 27 | sarif: results.sarif 28 | 29 | - name: Upload SARIF file 30 | uses: github/codeql-action/upload-sarif@v2 31 | with: 32 | sarif_file: ${{ steps.slither.outputs.sarif }} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Pollum Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #forge-template 2 | 3 | ![Github Actions](https://github.com/foundry-rs/forge-template/workflows/CI/badge.svg) 4 | 5 | Template repository for getting started quickly with Foundry projects. 6 | 7 | Forked from [Foundry's original repo](https://github.com/foundry-rs/forge-template/) with extra code to save you time. 8 | 9 | 12 | 13 |

14 | 15 |

16 | 17 | ## Getting Started 18 | 19 | Click "Use this template" on [GitHub](https://github.com/pollum-io/forge-template) to create a new repository with this repo as the initial state. 20 | 21 | ## Writing your first test 22 | 23 | All you need is to `import forge-std/Test.sol` and then inherit it from your test contract. Forge-std's Test contract comes with a pre-instatiated [cheatcodes environment](https://book.getfoundry.sh/cheatcodes/), the `vm`. It also has support for [ds-test](https://book.getfoundry.sh/reference/ds-test.html)-style logs and assertions. Finally, it supports Hardhat's [console.log](https://github.com/brockelmore/forge-std/blob/master/src/console.sol). The logging functionalities require `-vvvv`. 24 | 25 | ```solidity 26 | pragma solidity 0.8.10; 27 | 28 | import "forge-std/Test.sol"; 29 | 30 | contract ContractTest is Test { 31 | function testExample() public { 32 | vm.roll(100); 33 | console.log(1); 34 | emit log("hi"); 35 | assertTrue(true); 36 | } 37 | } 38 | ``` 39 | 40 | ### Addresses 41 | #### Goerli 42 | - Contract1: https://goerli.etherscan.io/address/ 43 | - Contract2: https://goerli.etherscan.io/address/ 44 | - Contract3: https://goerli.etherscan.io/address/ 45 | #### Mainnet 46 | - Contract1: https://etherscan.io/address/ 47 | - Contract2: https://etherscan.io/address/ 48 | - Contract3: https://etherscan.io/address/ 49 | 50 | ## Development 51 | 52 | This project uses [Foundry](https://getfoundry.sh). See the [book](https://book.getfoundry.sh/getting-started/installation.html) for instructions on how to 53 | install and use Foundry. 54 | 55 | ## Deploying 56 | 57 | You can either deploy individual contracts or the whole system at once, depending on which script you run. 58 | 59 | For individual contracts, run: 60 | ```bash 61 | cp .env.example .env 62 | ## insert RPC, Etherscan & priv key 63 | source .env 64 | forge script script/DeployContractTestnet.s.sol:Deploy --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv 65 | ``` 66 | 67 | To deploy the whole system + setup, run: 68 | ```bash 69 | forge script script/DeploySystemTestnet.s.sol:Deploy --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv 70 | ``` 71 | 72 | It's recommended to delete your broadcast/ folder when switching back and forth from single and full deployment scripts, as there are instances where Foundry may interprit legacy hardcoded parameters from single script contracts to the complete flow. 73 | 74 | ### Docs 75 | Auto-generate docs via `forge doc`. --------------------------------------------------------------------------------