20 min read
The code in this guide is strictly for educational and demonstration purposes. It is not production-ready and should not be used in live environments.
Overviewβ
While centralized stablecoins like USDC and USDT dominate the market (data: Ethereum, Solana) and make up for significant part of blockchain volume today, the need for decentralized alternatives continues to grow. This guide will walk you through creating, testing, deploying, and interacting with your own ETH-backed stablecoin using Foundry v1.0 as our smart contract development toolkit, OpenZeppelin for standardized token contracts, and Chainlink for our price oracle.
Let's get started!
What You Will Doβ
- Learn about Foundry
- Recap the changes in Foundry v1.0 and migration tips
- Create a QuickNode endpoint + fund your wallet (get some test funds here!)
- Write, test, deploy, and interact with stablecoin smart contract (Foundry v1.0 compatible)
What You Will Needβ
- Basic understanding of Solidity and smart contracts
- Foundry v1.0 installed (latest version)
- A code editor (VSCode recommended)
- Terminal/Command Line Interface
- Git installed
- Node.js (latest LTS version)
Foundryβ
Foundry is a smart contract development framework for building and deploying smart contracts on EVM blockchains. It is designed to make it easier for developers of all levels to create and deploy secure and efficient smart contracts.
More recently, Foundry released v1.0 which represents a major milestone in Ethereum development tooling, bringing more efficiency and stability to how we build and test smart contracts.
Foundry v1.0 Migration Tipsβ
If you're new to Foundry, feel free to skip over this section, as it won't relate to future smart contract development work you do.
Foundry v1.0 brings changes to how we develop smart contracts. Key changes include:
-
Solc Optimizer Changes: The optimizer is now disabled by default to prevent potential optimization bugs. This means you'll need to explicitly enable it in your
foundry.toml
. -
Testing Framework Updates:
- Removed support for
testFail
prefix (usevm.expectRevert()
instead) - Changed behavior of
expectRevert
on internal calls - New assertion methods and testing utilities
- Removed support for
-
Remapping and Dependencies:
- Stricter handling of conflicting remappings
- New approach to managing project dependencies
- More explicit source file handling
You won't have to worry about migrating code in this guide as it will all be v1.0 compliant. To learn more, check out this migration post from Foundry.
Project Prerequisite: Create a QuickNode Endpointβ
To communicate with the blockchain, you need access to a node. While we could run our own node, here at QuickNode, we make it quick and easy to fire up blockchain nodes. You can register for an account here.
Once logged in, create an endpoint for the Ethereum Sepolia testnet blockchain. Keep the HTTP URL handy, it should look like this:
This guide is EVM-compatible. If you want to deploy your agent on another chain, pick another EVM-compatible chain (e.g., Optimism, Arbitrum, etc.) and update the wallet and RPC URL's accordingly. You can also add the Chain Prism add-on to your endpoint so you can access multiple blockchain RPC URLs within the same endpoint.
Project Prerequisite: Get ETH from QuickNode Multi-Chain Faucetβ
In order to conduct activity on-chain, you'll need ETH to pay for gas fees. Since we're using the Sepolia testnet, we can get some test ETH from the Multi-Chain QuickNode Faucet.
Navigate to the Multi-Chain QuickNode Faucet and connect your wallet (e.g., MetaMask, Coinbase Wallet) or paste in your wallet address to retrieve test ETH. Note that there is a mainnet balance requirement of 0.001 ETH on Ethereum Mainnet to use the EVM faucets. You can also tweet or log in with your QuickNode account to get a bonus!