Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions plugins/maiatTrustPlugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# @virtuals-protocol/game-maiat-plugin

> Trust score verification for GAME agents — powered by [Maiat Protocol](https://maiat-protocol.vercel.app)

Give your Virtuals agent the ability to **check trust before it acts**. Maiat Protocol provides on-chain verified trust scores for tokens, DeFi protocols, and AI agents on Base.

## Why

AI agents executing swaps autonomously can be exploited by:
- Rug-pull tokens with no history
- Honeypot contracts
- Low-liquidity traps
- Unverified counterparties

Maiat trust scores are computed from verified reviews, on-chain activity, and AI analysis — stored in a `TrustScoreOracle` contract on Base.

## Install

```bash
npm install @virtuals-protocol/game-maiat-plugin
```

## Quick Start

```typescript
import { GameAgent, GameWorkerService } from "@virtuals-protocol/game";
import MaiatTrustPlugin from "@virtuals-protocol/game-maiat-plugin";

const maiatPlugin = new MaiatTrustPlugin({
minScore: 3.0, // reject tokens with score < 3.0/10
chain: "base",
});

const agent = new GameAgent(process.env.GAME_API_KEY!, {
name: "Trust-Gated Agent",
goal: "Execute swaps only for tokens with Maiat trust score ≥ 3.0",
workers: [new GameWorkerService(maiatPlugin.getWorker())],
});

await agent.init();
await agent.step({ verbose: true });
```

## Functions

### `check_trust_score`

Query the trust score for any address or project name.

| Arg | Type | Description |
|-----|------|-------------|
| `identifier` | `string` | `0x...` address or project name (e.g. `"Uniswap"`, `"AIXBT"`) |
| `chain` | `string` | Blockchain (default: `"base"`) |

**Returns:**
```json
{
"address": "0x...",
"score": 8.7,
"risk": "low",
"type": "DeFi",
"flags": [],
"safe": true,
"summary": "Trust score for Uniswap: 8.7/10 | Risk: LOW | Safe: YES"
}
```

---

### `gate_swap`

Check whether a swap is safe before executing. Checks both sides.

| Arg | Type | Description |
|-----|------|-------------|
| `token_in` | `string` | Token being sold |
| `token_out` | `string` | Token being bought |
| `min_score` | `number` | Minimum score to pass (default: `3.0`) |

**Returns:** `APPROVED` or `REJECTED` with reasons.

---

### `batch_check_trust`

Score multiple addresses at once, sorted by trust.

| Arg | Type | Description |
|-----|------|-------------|
| `identifiers` | `string` | Comma-separated addresses or names (max 10) |

## Configuration

```typescript
new MaiatTrustPlugin({
apiUrl: "https://maiat-protocol.vercel.app", // default
apiKey: "your-api-key", // optional
minScore: 3.0, // 0–10 scale
chain: "base", // base | bnb | solana
})
```

## Score Scale

| Score | Risk | Meaning |
|-------|------|---------|
| 7–10 | 🟢 Low | Trusted, well-reviewed |
| 4–6.9 | 🟡 Medium | Use with caution |
| 0–3.9 | 🔴 High | Risky, avoid |

## Links

- 🌐 [maiat-protocol.vercel.app](https://maiat-protocol.vercel.app)
- 📦 [GitHub](https://github.com/JhiNResH/maiat-protocol)
- 🔗 Oracle contract (Base Sepolia): `0xF662902ca227BabA3a4d11A1Bc58073e0B0d1139`
- 📖 [API docs](https://maiat-protocol.vercel.app/docs)

## License

MIT
45 changes: 45 additions & 0 deletions plugins/maiatTrustPlugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@virtuals-protocol/game-maiat-plugin",
"version": "0.1.0",
"description": "Maiat Trust Score plugin for the GAME SDK — lets your Virtuals agent verify trust before swapping or transacting",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsup src/index.ts --dts --format cjs,esm --out-dir dist",
"example": "ts-node src/example.ts",
"test": "echo 'No tests yet' && exit 0"
},
"files": [
"dist",
"README.md"
],
"keywords": [
"virtuals",
"game",
"maiat",
"trust-score",
"ai-agent",
"defi",
"web3",
"uniswap",
"base"
],
"author": "JhiNResH <https://github.com/JhiNResH>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/game-by-virtuals/game-node"
},
"homepage": "https://maiat-protocol.vercel.app",
"dependencies": {
"@virtuals-protocol/game": "^0.1.4"
},
"devDependencies": {
"@types/node": "^22.0.0",
"dotenv": "^16.4.7",
"ts-node": "^10.9.2",
"tsup": "^8.3.5",
"typescript": "^5.7.3"
}
}
45 changes: 45 additions & 0 deletions plugins/maiatTrustPlugin/src/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @maiat/game-maiat-plugin — Example usage
*
* Before running:
* 1. npm install
* 2. Get a GAME API key from https://console.game.virtuals.io
* 3. Set GAME_API_KEY in your environment (optional: MAIAT_API_KEY)
*/
import { GameAgent } from "@virtuals-protocol/game";
import MaiatTrustPlugin from "./maiatTrustPlugin";
import * as dotenv from "dotenv";

dotenv.config();

async function main() {
// 1. Init plugin
const maiatPlugin = new MaiatTrustPlugin({
minScore: 3.0, // reject anything below 3.0/10
chain: "base",
// apiKey: process.env.MAIAT_API_KEY, // optional — for higher rate limits
});

// 2. Create worker
const worker = maiatPlugin.getWorker();

// 3. Attach to a GAME agent
const agent = new GameAgent(process.env.GAME_API_KEY!, {
name: "TrustGated Trading Agent",
goal: "Execute token swaps only after verifying trust scores via Maiat Protocol. Reject any swap involving tokens with trust score below 3.0/10.",
description: "A DeFi trading agent that uses Maiat trust scoring to avoid rugs and scams.",
workers: [worker],
});

await agent.init();

// 4. Run examples
console.log("\n=== Example 1: Check trust score ===");
await agent.step({ verbose: true });

console.log("\n=== Example 2: Gate a swap ===");
// The agent will call gate_swap before executing
await agent.step({ verbose: true });
}

main().catch(console.error);
2 changes: 2 additions & 0 deletions plugins/maiatTrustPlugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as MaiatTrustPlugin } from "./maiatTrustPlugin";
export type { IMaiatTrustPluginOptions, TrustResponse } from "./maiatTrustPlugin";
Loading