This is Forest Protocols Smartcontracts. This suite of modularised immutable code is divided up into four contracts which govern the following main areas of concern:
- Registry contract: reponsible for keeping track of all actor registrations, PCs (including spinning up new ones) and collecting registration fees;
- Protocol contract: responsible for Protocol specific logic of enforcing PC rules and facilitating Providers entering Agreements with Users. Includes logic for processing Agreement balances and fees;
- Slasher contract: responsible for managing Actor's collateral, accepting votes from Validators on Provider's performance and aggregating the granular scores into aggregates which are used subsequently in emissions and slashing processes;
- Token contract: responsible for calculating and emitting new FOREST tokens based on info from Slasher as well as supporting typical ERC-20 functionality like transfers, burning and approvals.
There are three main ways to interact with the Protocol:
- CLI: link to npm
- Etherscan: check out the "Current live deployments" section below for explorer links to verified contracts
- Marketplace Web App by Forest Protocols: work-in-progress
For test tokens:
- USDC: https://faucet.circle.com/
- FOREST: contact the team on Discord
- Order of deployment is important:
- ForestToken
- ForestSlasher
- ForestRegistry
- slasher.setRegistryAndForestAddr(address(registry))
- forestToken.setRegistryAndSlasherAddr(address(registry))
- An address can register only as one type of actor both on the Protocol level and on the PC level.
- The PC smartcontracts are functional with the assumption that they were deployed by the ForestRegistry contract. Standalone deployment of PC code is not supported.
- Collateral related functions can only be called by the Owner address, not the Operator address.
- Install foundry: link
- Clone repo
- Change .env.example to .env and fill all the required fields
- Compile:
forge build
- Run tests with detailed logging:
forge test -vvvv
- Update env vars in
.env
- Load env vars from file
source .env
- Run scripts
- e.g. deployment for OP Sepolia:
forge script --chain 11155420 script/DeployForestContracts.sol:DeployScript --rpc-url $OP_SEPOLIA_RPC_URL --broadcast --verify --etherscan-api-key $OP_SEPOLIA_API_KEY -vvvv
(env vars: RUN_ON set to 1, OP_SEPOLIA_PRIV_KEY filled out) - deployment on local Anvil:
forge script script/DeployForestContracts.sol:DeployScript --rpc-url 127.0.0.1:8545 --broadcast
(env vars: RUN_ON set to 0, LOCAL_PRIV_KEY filled out)
- e.g. deployment for OP Sepolia:
- (Generate interface from ABI:
cast interface -n IForestRegistry utils/ForestRegistry.abi > IForestRegistry.sol
)
[current]
v0.43 (makes Slasher epoch & reveal window changeable for testing + optimisations)
- [dev env] ForestRegistry contract: 0xfd57c88098550f2929c1200400Cf611Be207eBC4: explorer link
- [dev env] ForestSlasher contract: 0xbC970527ac59E19DD12D4b4F69627e9eC354E848: explorer link
- [dev env] ForestToken contract: 0x3b494BcC7c9dE07610269eFE0305f2906845E2e7: explorer link
[previous]
v0.42 (unified errors + bitcoin-like emissions)
- [dev env] ForestRegistry contract: 0x67047690DeAE36373aa29fE94C165C36f3Bc449f: explorer link
- [dev env] ForestSlasher contract: 0x387dCCFB1d0F2d15832970b6580cA56B6597Dd78: explorer link
- [dev env] ForestToken contract: 0xe9402ac2a4DB99Ee6a9BbAf3B2B2aA2EB1E9090E: explorer link
v0.41 (fixes + added emissions)
- [dev env] ForestRegistry contract: 0x768328FbEf9820b3b9908577aF4A49058ADe0f22: explorer link
- [dev env] ForestSlasher contract: 0x92C3Ed245BBEA5f13cf19b4B58B0801aFe2E64d1: explorer link
- [dev env] ForestToken contract: 0xe2e1ade600433a4b932df966e5ea3cbc38f6b47d: explorer link
v0.4
- [dev env] ForestRegistry contract: 0x9c3d09b00601dc93a64cb25a9b845c33c8a4cccc: explorer link
- [dev env] ForestSlasher contract: 0x1d1897463f1af22814dd479ba8e8fddce3cfe8ad: explorer link
- [dev env] ForestToken contract: 0xd791d2b1f77d7156e9ec419e3545460a1d2e220c: explorer link