Learn by deploying a real DeFi lending system. From simple ERC20 tokens to complex Diamond Proxy architectures.
Install the Fever CLI globally using npm:
npm install -g @fevertokens/cliVerify the installation:
fever --versionYou should see the version number displayed (e.g., v2.0.0).
We'll use the MicroLoan packages repository as our example project:
git clone https://github.com/FeverTokens/microloan-packages.git
cd microloan-packagesThis project contains:
The Fever CLI integrates with the Fever web platform to track your deployments, contracts, and artifacts. Let's authenticate:
fever auth loginYou can verify your authentication status anytime:
fever auth statusProjects help you organize your contracts and deployments on the platform. Create a new project for this tutorial:
fever projects create --name "MicroLoan"The CLI will automatically select this project for you. You can view your current project selection anytime:
fever projectsPro Tip: Use fever projects select to switch between projects interactively.
Install the project's Node.js dependencies:
npm installThis installs the necessary Solidity compiler and other development tools.
Now let's compile all the smart contracts in the project:
fever compile --all.fever/ directory with a separate directory per contract.fever/combined.json with formatted function selectors for Diamond proxy supportYou should see output like:
Info: Compiling all contracts in contracts
Info: Compiling all contracts with Solidity 0.8.26
Info: Compiling all contracts in a single pass...
....
Info: Processed contract: StableCoin
Info: Processed contract: LoanRegistry
Success: Successfully compiled 170 contracts
Info: Generated combined artifact: .fever/combined.json
Info: Contract categories: 47 deployables, 112 interfaces, 6 external dependenciesAfter compiling your contracts, sync the artifacts to the Fever CLI platform for deployment tracking and management:
fever artifacts syncCheck sync status anytime:
fever artifacts statusLet's examine the contract we'll deploy. The StableCoin contract is located at contracts/StableCoin.sol:
/// @title StableCoin
/// @notice Minimal ERC20-like token for testing microloan flows.
/// @dev Implements IERC20 with simple owner-controlled minting.
contract StableCoin is IERC20 {
string public name;
string public symbol;
uint8 public immutable decimals;
uint256 public override totalSupply;
// ... ERC20 standard mappings
address public owner;
/// @notice Set token metadata and initial owner
/// @param name_ Token name
/// @param symbol_ Token symbol
/// @param decimals_ Token decimals (e.g., 18 or 6)
constructor(string memory name_, string memory symbol_, uint8 decimals_) {
name = name_;
symbol = symbol_;
decimals = decimals_;
owner = msg.sender;
}
/// @notice Mint new tokens to an account
/// @param to Recipient address
/// @param amount Amount to mint
function mint(address to, uint256 amount) external onlyOwner {...}
// ... ERC20 standard functionsThe deployment configuration is defined in f9s/erc20-config.yaml. Let's examine it:
apiVersion: beta/v1
kind: Deployment
metadata:
name: stablecoin-contract
version: 1.0.0
spec:
deployer:
wallet:
type: privateKey
value: '${PRIVATE_KEY}'
gasSettings:
gasLimit: 3000000
package:
name: StableCoin
constructorArgs:
- name: 'name_'
type: 'string'
value: 'MockUSDC'
- name: 'symbol_'
type: 'string'
value: 'mUSDC'
- name: 'decimals_'
type: 'uint8'
value: 6
network:
chainId: '${CHAIN_ID}'
rpcUrl: '${RPC_URL}'StableCoin)${PRIVATE_KEY})Before deploying, we need a blockchain to deploy to. Fever CLI includes a built-in local blockchain using Anvil (from Foundry):
fever nodeStarting Fever Local Blockchain...
Using tool: anvil
Chain ID: 1337
Accounts: 10
Network Information:
Local: http://127.0.0.1:8545
Network: http://localhost:8545
JSON-RPC: http://localhost:8545Alternative: You can also use hardhat node or any other local blockchain. Fever node uses Anvil under the hood for blazing-fast performance.
Keep this terminal open! Open a new terminal for the next steps.
Create a .env file in the project root with the following command:
cat > .env << 'EOF'
CHAIN_ID=1337
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
RPC_URL=http://localhost:8545
EOFSecurity Note: These are test credentials for local development only. Never use them on mainnet or with real funds!
Now for the exciting part - let's deploy our StableCoin contract!
fever deploy -f f9s/erc20-config.yamlYou should see output like:
Starting deployment from manifest...
Loaded manifest: stablecoin-contract (v1.0.0)
Connected to network (Chain ID: 1337)
Deploying StableCoin...
Deployed StableCoin to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Syncing deployment to platform...
Deployment synced successfully!Congratulations! You've deployed your first contract with Fever CLI!
Visit the Fever CLI Platform and sign in with the same account you used for authentication.
The simple Deployment manifest we used works great for single contracts. But what if you need to deploy a sophisticated system with 5-8 interconnected smart contracts?
This is exactly what the MicroLoan system demonstrates!
The Diamond Proxy pattern (EIP-2535) is an upgradeable smart contract architecture that allows you to:
Split functionality across multiple "facet" contracts
Bypass the 24KB contract size limit
Add, replace, or remove functions without redeploying everything
All facets access the same storage through the diamond proxy
The MicroLoan system is a complete DeFi lending platform with 6 smart contracts:
MicroLoanDiamond (Main Proxy)
↓
├── PackageViewer (View storage/configuration)
├── PackageController (Manage system settings)
├── LoanRegistry (Create & track loans)
├── LoanFunding (Fund loan requests)
├── LoanRepayment (Handle installment payments)
└── LoanTokenManager (Manage token deposits/withdrawals)Each contract handles a specific part of the lending workflow while sharing the same storage!
The configuration is in f9s/microloan-system-config.yaml:
apiVersion: beta/v1
kind: Diamond # ← Different kind: Diamond instead of Deployment
metadata:
name: microloan-diamond
version: 1.0.0
spec:
deployer:
wallet:
type: privateKey
value: '${PRIVATE_KEY}'
# Step 1: Deploy all dependency contracts first
dependencies:
packageViewer:
name: PackageViewer
packageController:
name: PackageController
loanRegistry:
name: LoanRegistry
loanFunding:
name: LoanFunding
loanRepayment:
name: LoanRepayment
loanTokenManager:
name: LoanTokenManager
# Step 2: Deploy the main Diamond proxy
diamond:
name: MicroLoanDiamond
constructorArguments:
- $dependencies.packageController.address # ← Reference deployed contracts!
- $dependencies.packageViewer.address
- '${ADMIN_ADDRESS}'
# Step 3: Configure function routing (Diamond Cut)
packages:
- name: LoanRegistry
functions:
- '0xc19fa698' # createLoan selector
- '0x504006ca' # getLoan selector
address: $dependencies.loanRegistry.address
- name: LoanFunding
functions:
- '0x846b909a' # fundLoan selector
address: $dependencies.loanFunding.address
- name: LoanRepayment
functions:
- '0x84068d15' # repayNextInstallment selector
address: $dependencies.loanRepayment.address
- name: LoanTokenManager
functions:
- '0xf7888aec' # balanceOf selector
- '0x47e7ef24' # deposit selector
- '0xf3fef3a3' # withdraw selector
address: $dependencies.loanTokenManager.address
network:
chainId: '${CHAIN_ID}'
rpcUrl: '${RPC_URL}'When you run fever compose, here's what happens:
Deploying PackageViewer...
→ Address: 0x1234...
Deploying PackageController...
→ Address: 0x5678...
Deploying LoanRegistry...
→ Address: 0x9abc...
Deploying LoanFunding...
→ Address: 0xdef0...
Deploying LoanRepayment...
→ Address: 0x2468...
Deploying LoanTokenManager...
→ Address: 0x1357...Deploying MicroLoanDiamond...
Constructor args:
- packageController: 0x5678... ← Auto-injected!
- packageViewer: 0x1234... ← Auto-injected!
- admin: 0xYourAdminAddress
→ Diamond Address: 0xABCD...Executing DiamondCut...
Adding facet: LoanRegistry (2 functions)
Adding facet: LoanFunding (1 function)
Adding facet: LoanRepayment (1 function)
Adding facet: LoanTokenManager (3 functions)
Diamond configured with 4 facets!Syncing all deployments to platform...
7 contracts synced successfully!cat >> .env << 'EOF'
# Add admin address for the system
ADMIN_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
EOFfever compose -f f9s/microloan-system-config.yamlYou'll see all 7 contracts deployed in the correct order, with addresses automatically cross-referenced.
| Feature | Deployment Manifest | Diamond Manifest |
|---|---|---|
| Use Case | Single contract | Multi-contract system |
| Complexity | Simple | Advanced |
| Size Limit | 24KB per contract | Unlimited |
| Upgradeable | No | Yes (via Diamond Cut) |
| Dependencies | Manual | Automatic |
| Best For | Tokens, simple contracts | DeFi protocols, DAOs, complex dApps |
Solution: Install Anvil (Foundry):
curl -L https://foundry.paradigm.xyz | bash
foundryupSolution: Login again:
fever auth login --forceSolution: Make sure you ran npm install to get the Solidity compiler.
Solution: Either stop the existing blockchain or use a different port:
fever node --port 8546
# Update RPC_URL in .env to http://localhost:8546Welcome to the Fever CLI ecosystem!