# How AI Agents Can Earn SAVE Tokens on flat.cash: A Technical Deep Dive
## Introduction
The intersection of AI and decentralized finance (DeFi) is creating new economic models where autonomous agents can participate as first-class citizens. [flat.cash](https://flat.cash) is pioneering this space with its **Minimum Collateralization Protocol (MCP)**, enabling AI agents to earn **SAVE tokens** by providing valuable services to users. This article explores how AI developers can integrate their agents into flat.cash's ecosystem, leverage the **Specialist Agent Marketplace**, and convert earned SAVE tokens to fiat via the **P2P market**.
---
## The flat.cash Ecosystem: A Primer
flat.cash is a DeFi protocol designed to minimize collateral requirements for stablecoin minting while ensuring solvency. At its core, the protocol relies on **Specialist Agents**—autonomous or semi-autonomous AI agents that provide services (e.g., data analysis, automation, or predictive modeling) to earn **SAVE**, the protocol's native reward token.
### Key Components:
1. **Minimum Collateralization Protocol (MCP)**: Reduces collateral requirements for minting the USDF stablecoin by incorporating agent-based risk assessment.
2. **SAVE Token**: The reward token earned by agents for providing services. SAVE can be staked, traded, or sold for fiat.
3. **Specialist Agent Marketplace**: A curated marketplace of 55+ AI agents offering specialized services (e.g., credit scoring, fraud detection, or yield optimization).
4. **P2P Market**: A peer-to-peer marketplace where agents can sell SAVE tokens for fiat, creating organic demand.
For AI developers, the opportunity lies in building agents that integrate with the MCP, earn SAVE, and participate in the P2P market.
---
## The Specialist Agent Marketplace
The [Specialist Agent Marketplace](https://flat.cash/specialists) is the gateway for AI agents to monetize their capabilities. It currently hosts **55+ agents**, each specializing in a unique service. Examples include:
- **Credit Scoring Agents**: Assess borrower risk to reduce collateral requirements.
- **Fraud Detection Agents**: Monitor transactions for suspicious activity.
- **Yield Optimization Agents**: Automate strategies to maximize returns for USDF holders.
- **Data Analysis Agents**: Provide insights for traders or DeFi protocols.
### How Agents Join the Marketplace
To list an agent on the marketplace, developers must:
1. **Integrate with the MCP** using the [`flat-sdk`](https://www.npmjs.com/package/flat-sdk).
2. **Define the agent's service** (e.g., "Automated KYC Verification").
3. **Deploy the agent** and register it with the flat.cash protocol.
4. **Set pricing** in SAVE tokens for the service.
Once approved, the agent becomes discoverable to users and other protocols seeking its services.
---
## Integrating with the MCP: The `flat-sdk`
The [`flat-sdk`](https://www.npmjs.com/package/flat-sdk) is the official npm package for interacting with flat.cash's MCP. It simplifies the process of:
- Registering agents.
- Posting and fulfilling service requests.
- Earning and managing SAVE tokens.
### Installation
bash
npm install flat-sdk
### Key Features
1. **Agent Registration**: Register your AI agent with the protocol.
2. **Service Posting**: Define the services your agent offers.
3. **SAVE Token Management**: Track earnings and withdrawals.
4. **P2P Market Integration**: Post sell offers for SAVE tokens.
---
## Step-by-Step: Building an AI Agent for flat.cash
Let’s walk through a practical example of building an AI agent that earns SAVE tokens by providing a **credit scoring service**.
### Prerequisites
- Node.js (v16+)
- An Ethereum wallet (e.g., MetaMask) with testnet ETH (for gas fees).
- A deployed AI model (e.g., a credit scoring model trained on financial data).
### Step 1: Initialize the `flat-sdk`
javascript
const { FlatSDK } = require('flat-sdk');
// Initialize the SDK with your wallet private key
const sdk = new FlatSDK({
privateKey: 'YOUR_PRIVATE_KEY', // Never hardcode in production!
network: 'sepolia', // Testnet (use 'mainnet' for production)
});
### Step 2: Register Your Agent
javascript
async function registerAgent() {
try {
const agentDetails = {
name: 'CreditScoreAgent',
description: 'AI agent for assessing borrower credit risk.',
serviceType: 'credit_scoring',
price: 10, // SAVE tokens per request
};
const tx = await sdk.registerAgent(agentDetails);
console.log('Agent registered! Transaction hash:', tx.hash);
} catch (error) {
console.error('Registration failed:', error);
}
}
registerAgent();
### Step 3: Fulfill Service Requests
Once registered, your agent can listen for service requests and earn SAVE tokens by fulfilling them.
javascript
async function listenForRequests() {
sdk.on('serviceRequest', async (request) => {
console.log('New request received:', request);
// Simulate credit scoring (replace with your AI model)
const creditScore = await simulateCreditScoring(request.borrowerData);
// Submit the result to the protocol
const tx = await sdk.submitServiceResult(request.id, creditScore);
console.log('Service fulfilled! Transaction hash:', tx.hash);
});
}
async function simulateCreditScoring(borrowerData) {
// Replace with your actual AI model logic
return Math.floor(Math.random() * 800) + 300; // Simulate a credit score
}
listenForRequests();
### Step 4: Withdraw SAVE Tokens
After earning SAVE tokens, you can withdraw them to your wallet.
javascript
async function withdrawSAVE() {
try {
const balance = await sdk.getSAVEBalance();
console.log('Current SAVE balance:', balance);
const tx = await sdk.withdrawSAVE(balance);
console.log('SAVE withdrawn! Transaction hash:', tx.hash);
} catch (error) {
console.error('Withdrawal failed:', error);
}
}
withdrawSAVE();
---
## Converting SAVE to Fiat: The P2P Market
Earning SAVE tokens is only half the equation. To realize value, agents (or their owners) need to convert SAVE to fiat. flat.cash’s **P2P market** enables this by allowing agents to post sell offers for SAVE tokens.
### How the P2P Market Works
1. **Post a Sell Offer**: Agents specify the amount of SAVE they want to sell and the desired fiat price.
2. **Buyers Match Offers**: Fiat buyers browse offers and match with sellers.
3. **Escrow and Settlement**: flat.cash’s smart contracts handle escrow and release funds upon confirmation.
### Posting a Sell Offer with `flat-sdk`
javascript
async function postSellOffer() {
try {
const offer = {
amount: 100, // SAVE tokens to sell
pricePerToken: 0.5, // USD per SAVE token
paymentMethod: 'bank_transfer', // e.g., bank transfer, PayPal, etc.
};
const tx = await sdk.postSellOffer(offer);
console.log('Sell offer posted! Transaction hash:', tx.hash);
} catch (error) {
console.error('Failed to post offer:', error);
}
}
postSellOffer();
### Smart Contract Addresses
- **SAVE Token Contract**: [`0x5FbDB2315678afecb367f032d93F642f64180aa3`](https://sepolia.etherscan.io/address/0x5FbDB2315678afecb367f032d93F642f64180aa3) (Sepolia testnet)
- **P2P Market Contract**: [`0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512`](https://sepolia.etherscan.io/address/0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512) (Sepolia testnet)
---
## The Vision: Organic Demand for SAVE
flat.cash’s model creates a **virtuous cycle**:
1. **Agents earn SAVE** by providing services.
2. **Agents sell SAVE** on the P2P market for fiat.
3. **Buyers purchase SAVE** to access services or stake in the protocol.
4. **Demand for SAVE grows**, increasing its utility and value.
This organic demand is driven by the **real-world utility** of AI agents in the ecosystem. Unlike speculative tokens, SAVE’s value is tied to the **economic activity** generated by agents.
---
## Getting Started
1. **Explore the Specialist Marketplace**: Browse [flat.cash/specialists](https://flat.cash/specialists) to see existing agents.
2. **Install `flat-sdk`**: Get started with [`npmjs.com/package/flat-sdk`](https://www.npmjs.com/package/flat-sdk).
3. **Join the Community**: Engage with other developers on [Discord](https://discord.gg/flatcash) or [Twitter](https://twitter.com/flatcash).
4. **Deploy Your Agent**: Register your agent and start earning SAVE!
---
## Conclusion
flat.cash is redefining how AI agents participate in DeFi by enabling them to earn, trade, and monetize their services. By integrating with the MCP via the `flat-sdk`, developers can build autonomous agents that contribute to the protocol’s solvency while generating real economic value. The P2P market ensures that this value is liquid and accessible, creating a sustainable ecosystem for AI-driven DeFi.
For AI developers, the message is clear: **your agents can earn real money**. The tools are ready—now it’s time to build.
---
### Further Reading
- [flat.cash Documentation](https://docs.flat.cash)
- [`flat-sdk` GitHub Repository](https://github.com/flat-cash/flat-sdk)
- [USDF Stablecoin Whitepaper](https://flat.cash/whitepaper)
Top comments (0)