Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose solidity REPL.
$ forge build$ forge test$ forge fmt$ forge snapshot$ anvil$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>$ cast <subcommand>$ forge --help
$ anvil --help
$ cast --helpA staking contract for BBT tokens with compound interest rewards.
- Foundry installed
- An Ethereum node URL (Infura, Alchemy, etc.)
- A wallet private key with sufficient ETH for deployment gas
Create a .env file with the following variables:
PRIVATE_KEY=your_private_key_here_without_0x_prefix
RPC_URL=your_ethereum_node_url
TOKEN_ADDRESS=address_of_bbt_token_contract
Load environment variables:
source .envDeploy using an existing token:
forge script script/DeployCompoundStakingBBT.s.sol --rpc-url $TESTNET --broadcast --verifyOr deploy with a mock token (for testing):
forge script script/DeployWithMockToken.s.sol --rpc-url $TESTNET --broadcast --verify- Verify the contract on Etherscan (if the
--verifyflag didn't work automatically):
forge verify-contract <DEPLOYED_CONTRACT_ADDRESS> src/CompoundStakingBBT.sol:CompoundStakingBBT --chain-id <CHAIN_ID> --watch- Grant the SELLON_ADMIN_ROLE to any additional addresses that need it:
cast send <STAKING_CONTRACT_ADDRESS> "grantRole(bytes32,address)" \
$(cast keccak "SELLON_ADMIN_ROLE") <NEW_ADMIN_ADDRESS> \
--rpc-url $RPC_URL --private-key $PRIVATE_KEY- Annual Reward Rate: Default is 30%, can be changed by admin
- Wait Time: Default is 1 day (86400 seconds), can be changed by admin