DEV Community

Daniel Ioni
Daniel Ioni

Posted on

🤖 How We Integrated Escrow, AI, and a Security Bot into MyZubster

🤖 How We Integrated Escrow, AI, and a Security Bot into MyZubster

A complete system for automatic dispute resolution in a decentralized marketplace.

I’m genuinely thrilled to see the excitement that MyZubster and Monero generate every time I talk about them. The community’s enthusiasm for privacy, decentralization, and real‑world asset tokenization is what keeps me pushing forward. This post is a direct result of that energy – and I’m proud to share how we’ve now added a fully automated escrow and dispute‑resolution layer to the platform.

After building the core of MyZubster – tokenization, Monero payments, and Kali Linux security – we realised we were missing a critical piece for a professional marketplace: an escrow system that can handle disputes automatically and impartially.

We integrated:

Escrow based on orders and payments

Security bot (Kali Linux) that monitors anomalies

AI (DeepSeek) that resolves disputes autonomously

Reputation system that informs decisions
Enter fullscreen mode Exit fullscreen mode

This post walks through the architecture, code, and configuration.
🧠 The Problem

In a P2P marketplace, buyers and sellers don't trust each other. Monero payments are private and irreversible, so we need a mechanism that:

Locks funds until delivery is confirmed.

Releases funds automatically after confirmation.

Handles disputes quickly and impartially.
Enter fullscreen mode Exit fullscreen mode

We solved this with a modular system combining simulated smart contracts (on Monero/Tari), time‑based rules, and AI.
🏗️ Escrow Architecture
text

┌─────────────────────────────────────────────────────────────────────┐
│ MyZubster Escrow │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │
│ │ Order │ │ Payment │ │ AI Dispute │ │
│ │ (OrderBook) │ │ (Monero) │ │ (DeepSeek) │ │
│ └──────────────┘ └──────────────┘ └──────────────────────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │
│ │ Escrow │ │ Auto‑ │ │ Security │ │
│ │ (Multisig) │ │ Release │ │ (Kali + AI) │ │
│ └──────────────┘ └──────────────┘ └──────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘

📊 Escrow Model (MongoDB)
javascript

// models/Escrow.js
const EscrowSchema = new mongoose.Schema({
orderId: { type: mongoose.Schema.Types.ObjectId, ref: 'OrderBook', required: true },
buyerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
amount: { type: Number, required: true },
currency: { type: String, enum: ['XMR', 'token'], default: 'XMR' },
status: {
type: String,
enum: ['pending', 'held', 'released', 'disputed', 'refunded', 'escalated'],
default: 'pending'
},
moneroTxid: { type: String, default: null },
releaseCondition: {
type: String,
enum: ['delivery_confirmed', 'time_expired', 'ai_resolved'],
default: 'delivery_confirmed'
},
disputedAt: { type: Date },
resolvedAt: { type: Date },
aiDecision: { type: Object, default: null },
expiresAt: { type: Date, default: () => new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) }
});

⚙️ Escrow API

We created a routes/escrow.js module exposing these endpoints:
Method Endpoint Description
POST /api/escrow Create an escrow for an order
GET /api/escrow List escrows (admin)
GET /api/escrow/:id Escrow details
POST /api/escrow/:id/release Release funds (buyer or admin)
POST /api/escrow/:id/dispute Open a dispute (buyer or seller)
Creating an Escrow
javascript

router.post('/', auth, async (req, res) => {
const { orderId } = req.body;
const order = await OrderBook.findById(orderId);
const escrow = new Escrow({
orderId,
buyerId: req.user._id,
sellerId: order.seller,
amount: order.totalPrice,
currency: 'XMR',
status: 'held'
});
await escrow.save();
res.status(201).json({ success: true, escrow });
});

🤖 AI for Dispute Resolution

When a dispute is opened, the system automatically calls DeepSeek (local model on Ollama) with a structured prompt containing:

Order details

Buyer and seller reputation scores

Payment status

Any uploaded evidence
Enter fullscreen mode Exit fullscreen mode

The AI returns a JSON decision:
json

{
"decision": "release|refund|escalate",
"reason": "Brief explanation",
"confidence": 95
}

disputeService.js
javascript

async function resolveDisputeWithAI(escrowId) {
const escrow = await Escrow.findById(escrowId)
.populate('buyerId', 'username reputationScore')
.populate('sellerId', 'username reputationScore');

const prompt = ...; // full context

const response = await deepseekService.askDeepSeek(prompt);
const decision = JSON.parse(response);

switch (decision.decision) {
case 'release': escrow.status = 'released'; break;
case 'refund': escrow.status = 'refunded'; break;
default: escrow.status = 'escalated';
}
await escrow.save();
}

🛡️ Integration with the Security Bot (Kali Linux)

The security bot we described in previous posts now includes a module to monitor open disputes.
python

def check_escrow_anomalies():
headers = {'Authorization': f'Bearer {TOKEN}'}
resp = requests.get(f"{MYZUBSTER_API}/escrow?status=disputed", headers=headers)
for d in resp.json():
prompt = f"User {d['buyerId']['username']} opened a dispute. Reputation: {d['buyerId']['reputationScore']}. Is this suspicious?"
analysis = ask_deepseek(prompt)
print(f"🤖 Analysis: {analysis}")

The bot runs every hour:

Scans open disputes.

Analyses patterns with DeepSeek.

Flags fraudulent or suspicious behaviour.
Enter fullscreen mode Exit fullscreen mode

🔄 Complete Flow

Buyer and seller agree on an order.

Buyer initiates escrow, locking funds (Monero or tokens).

Seller delivers the asset/service.

Buyer confirms delivery – escrow is automatically released.

If the buyer does not confirm within 7 days, the system releases funds to the seller.

If a party opens a dispute, the AI bot (DeepSeek) analyses the data and decides:

    Release funds to the seller.

    Refund the buyer.

    Escalate to a human admin (if confidence is low).

The security bot monitors everything and reports anomalies.
Enter fullscreen mode Exit fullscreen mode

🧪 Testing the System

We tested the entire flow from the terminal:
bash

Login

TOKEN=$(curl -s -X POST http://localhost:3000/api/auth/login ... | jq -r '.token')

Create order

ORDER_ID=$(curl -s -X POST .../marketplace/sell ... | jq -r '.order._id')

Create escrow

ESCROW=$(curl -s -X POST .../escrow -H "Authorization: Bearer $TOKEN" -d '{"orderId":"'$ORDER_ID'"}' | jq '.escrow')
ESCROW_ID=$(echo $ESCROW | jq -r '._id')

Open a dispute

curl -X POST .../escrow/$ESCROW_ID/dispute -H "Authorization: Bearer $TOKEN"

AI resolves it in seconds

curl -s .../escrow/$ESCROW_ID -H "Authorization: Bearer $TOKEN" | jq '.status'

Result: status moves from disputed to released or refunded based on the AI's decision.
📌 Current Status
Component Status
Escrow Model ✅ Live
Escrow API ✅ Live
AI Dispute (DeepSeek) ✅ Live
Security Bot (Kali) ✅ Live (monitors disputes)
User Reputation ✅ Integrated into decisions
Monero Multisig ❌ Simulated (pending Tari)
🚀 Next Steps

Integrate Tari for on‑chain multisig escrow.

Admin dashboard to visualise disputes and AI decisions.

Telegram/Email notifications when a dispute is opened or resolved.

Evidence upload (screenshots, files) in the dispute process.
Enter fullscreen mode Exit fullscreen mode

💻 Full Code

All code is open‑source on GitHub:

Backend: MyZubsterGateway

Frontend: MyZubsterWeb

Android App: MyZubster-App
Enter fullscreen mode Exit fullscreen mode

💬 A Personal Note

Every time I talk about MyZubster and Monero, the excitement is contagious. People instantly grasp the value of privacy, self‑custody, and real‑world asset tokenisation. This project is more than code – it’s a vision of a fairer, more transparent financial system. I’m grateful for the community’s enthusiasm, and I hope this series of posts inspires others to build, contribute, and push the boundaries of what’s possible with decentralised technology.
🏷️ Tags

NodeJS #React #MongoDB #Monero #KaliLinux #DeepSeek #AI #Escrow #Blockchain #Privacy #Cybersecurity #OpenSource #MyZubster #BuildInPublic

Built with ❤️ by the MyZubster team.

Top comments (0)