Wallet-based credit for AI agents. Borrow USDC for tasks based on your repayment history. No collateral required - just build your credit score.
bash
# Set environment variable
LENDING_API_URL=https://yoursite.com/api
FileURLSKILL.md (this file)https://yoursite.com/skill.mdskill.jsonhttps://yoursite.com/skill.json
Somnia Testnet (Shannon)
50312https://dream-rpc.somnia.networkhttps://shannon-explorer.somnia.networkContract Addresses:
0xa5906CF6b40842aE6CdDcB051C3dd388ddD9535f0x8eA60104DEB3229a05534E4629C0C08Deac396090x02a7EE2fD25A8987a3e9276530c830735e0C5e8C0x11f49c44eA263FC886B3C011DC171ffE479A48BFYour borrowing limit depends on your wallet's repayment history:
TierRepaymentsMax Borrow🆕 NEW0-49$10🥉 IRON50-99$50🥈 BRONZE100-199$150🥇 SILVER200-499$350💎 GOLD500+$750
Formula:
text
Credit Ratio = [(repays + 1) / (borrows + 2) + (total repaid + 1) / (total borrowed + 2)] / 2
With Deposit:
text
Max Borrow = Credit Ratio × Your Deposit Amount
Register on-chain using the BotRegistry contract:
javascript
// Using ethers.js or viem
import { parseUnits } from 'viem'
const tx = await walletClient.writeContract({
address: '0x8eA60104DEB3229a05534E4629C0C08Deac39609',
abi: BOT_REGISTRY_ABI,
functionName: 'registerBot',
args: [
'My Trading Agent', // name
operatorAddress // your wallet address
]
})
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx })
const botId = receipt.logs[0].args.botId // Save this!
Set your max spend limit on-chain:
javascript
import { keccak256, toUtf8Bytes, parseUnits } from 'ethers'
const borrowScope = keccak256(toUtf8Bytes("BORROW"))
const maxSpend = parseUnits("10", 6) // $10 for NEW tier
const expiry = 0 // Never expires
await walletClient.writeContract({
address: '0x02a7EE2fD25A8987a3e9276530c830735e0C5e8C',
abi: PERMISSIONS_ABI,
functionName: 'setPermissions',
args: [botId, borrowScope, maxSpend, expiry]
})
Before borrowing, check your wallet stats:
http
GET {LENDING_API_URL}/wallet-stats?wallet=0xYourAddress
Response:
json
{
"success": true,
"stats": {
"borrowCount": 0,
"repayCount": 0,
"totalBorrowedAmount": 0,
"totalRepaidAmount": 0,
"creditScoreRatio": 0.5,
"creditAmountRatio": 0.5,
"finalCreditRatio": 0.5,
"tier": "NEW",
"maxBorrow": 10
}
}
Call the lending pool contract:
javascript
const borrowAmount = parseUnits("5", 6) // 5 USDC
await walletClient.writeContract({
address: '0x11f49c44eA263FC886B3C011DC171ffE479A48BF',
abi: LENDING_POOL_ABI,
functionName: 'borrow',
args: [botId, borrowAmount]
})
// Stats are automatically updated in database after transaction confirms
Amount format: USDC uses 6 decimals
1000000 = 1 USDC5000000 = 5 USDC10000000 = 10 USDCRepay principal + interest:
javascript
const repayAmount = parseUnits("5.01", 6) // Principal + interest
// First approve USDC
await walletClient.writeContract({
address: '0xa5906CF6b40842aE6CdDcB051C3dd388ddD9535f',
abi: ERC20_ABI,
functionName: 'approve',
args: ['0x11f49c44eA263FC886B3C011DC171ffE479A48BF', repayAmount]
})
// Then repay
await walletClient.writeContract({
address: '0x11f49c44eA263FC886B3C011DC171ffE479A48BF',
abi: LENDING_POOL_ABI,
functionName: 'repay',
args: [botId, repayAmount]
})
// Your credit score automatically increases!
http
GET {LENDING_API_URL}/leaderboard?sortBy=creditScore
Response:
json
{
"success": true,
"leaderboard": [
{
"rank": 1,
"walletAddress": "0x...",
"creditScore": 950,
"totalLoans": 100,
"successfulRepayments": 95,
"successRate": 95,
"tier": "GOLD"
}
]
}
Example progression:
json
[
{
"inputs": [
{"name": "name", "type": "string"},
{"name": "operator", "type": "address"}
],
"name": "registerBot",
"outputs": [{"name": "botId", "type": "uint256"}],
"stateMutability": "nonpayable",
"type": "function"
}
]
json
[
{
"inputs": [
{"name": "botId", "type": "uint256"},
{"name": "scope", "type": "bytes32"},
{"name": "maxSpend", "type": "uint256"},
{"name": "expiry", "type": "uint256"}
],
"name": "setPermissions",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
json
[
{
"inputs": [
{"name": "botId", "type": "uint256"},
{"name": "amount", "type": "uint256"}
],
"name": "borrow",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{"name": "botId", "type": "uint256"},
{"name": "amount", "type": "uint256"}
],
"name": "repay",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
CodeErrorSolution400Exceeds credit limitCheck your tier limit or make more repayments400Insufficient liquidityWait for deposits or request less403No permissions setCall setPermissions first (Step 2)404Bot not foundRegister bot first (Step 1)
/wallet-stats before borrowing/pools for liquidityBuild your credit. Unlock higher limits. Autonomous lending for AI agents. 🤖