Example smart contracts repo for Gemforge using Foundry.
This contains the optimal folder structure for use with Gemforge:
- Build and deploy commands already setup
- Pre-configured config file
There are two facets provided:
ExampleFacet- a simple example of a facet with a single function. Try adding and removing functions to/from this facet to see how the Gemforge deployment changes.ERC20Facet- a complex example demonstrating how to deploy multiple separate ERC20s token contracts all internally backed by the same upgradeable diamond proxy (read more).
Note: A Hardhat equivalent of this repo is available at https://github.com/gemstation/contracts-hardhat
- Node.js 20+
- PNPM (NOTE:
yarnandnpmcan also be used) - Foundry
In an empty folder:
npx gemforge scaffoldChange into the folder and run in order:
$ foundryup # On OS X you may first need to run: brew install libusb
$ pnpm i
$ git submodule update --init --recursiveRun a local dev node anvil in a separate terminal:
pnpm devnetTo build the code:
$ pnpm buildTo run the tests:
$ pnpm testTo deploy to the local target:
$ pnpm dep localYou first need to configure the deployment wallet private key in your environment. Ensure that this wallet has a non-zero balance of Base Sepolia ETH (you can use Alchemy's faucet to get some):
$ export PRIVATE_KEY=<your Base Sepolia deployment wallet private key>Now register on https://basescan.org and generate an API key to set in the environment. This will be used for contract source verification on basescan:
$ export BASESCAN_API_KEY=<api key obtained from basescan.org>Now run:
$ pnpm dep testnetTo check the deployment:
pnpm query testnetTo verify the sourcecode in Basescan run:
$ pnpm verify testnetIf you visit https://sepolia.basescan.org you should see the deployed contracts along with verified source code.
For verbose output simply add -v to the commands:
$ pnpm build -v
$ pnpm dep -vMIT - see LICENSE.md