This project is meant to be a stablecoin where users can deposit WETH and WBTC in exchange for a token that will be pegged to the USD.
• git ⸰ You'll know you did it right if you can run git --version and you see a response like git version x.x.x • foundry ⸰ You'll know you did it right if you can run forge --version and you see a response like forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
git clone https://github.com/Preciousbas/foundry-stablecoin
cd foundry-stablecoin
forge buildmake anvilThis will default to your local node. You need to have it running in another terminal in order for it to deploy.
make deployforge testforge coverageand for coverage based testing:
forge coverage --report debug- Setup environment variables You'll want to set your SEPOLIA_RPC_URL and PRIVATE_KEY as environment variables.
⸰ PRIVATE_KEY: The private key of your account (like from metamask). ⸰ SEPOLIA_RPC_URL: This is url of the sepolia testnet node you're working with. You can get setup with one for free from Alchemy
Optionally, add your ETHERSCAN_API_KEY if you want to verify your contract on Etherscan.
-
Get testnet ETH Head over to any faucet of your choice and get some Sepolia testnet ETH. You should see the ETH show up in your metamask.
-
Deploy
make deploy ARGS="--network sepolia"Instead of scripts, we can directly use the cast command to interact with the contract.
For example, on Sepolia:
- Get some WETH
cast send 0x3b3901ea5DF1fDF6c7f3B22b8A03d935b42D1E85 "deposit()" --value 0.1ether --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY- Approve the WETH
cast send 0x3b3901ea5DF1fDF6c7f3B22b8A03d935b42D1E85 "approve(address,uint256)" 0x091EA0838eBD5b7ddA2F2A641B068d6D59639b98 1000000000000000000 --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY- Deposit and Mint ZEN
cast send 0x091EA0838eBD5b7ddA2F2A641B068d6D59639b98 "depositCollateralandMintZen(address,uint256,uint256)" 0xdd13E55209Fd76AfE204dBda4007C227904f0a81 100000000000000000 10000000000000000 --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEYforge fmtYou can estimate how much gas things cost by running:
forge snapshotforge --help
anvil --help
cast --help