Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6219e3b
Expand ReadMe with PiRC-AI project details
Clawue884 Mar 30, 2026
3e6c177
Add architecture overview to ReadMe.md
Clawue884 Mar 30, 2026
e3693c9
Expand ReadMe with Token Model and challenges
Clawue884 Mar 30, 2026
1375d12
Add Attention Triad framework overview and details
Clawue884 Mar 30, 2026
bd76227
Implement attention economy simulation model
Clawue884 Mar 30, 2026
a884fc3
Initialize Cargo.toml for reward_engine package
Clawue884 Mar 30, 2026
e3f5a94
Add RewardEngine contract with reward calculations
Clawue884 Mar 30, 2026
8b4060d
Implement RewardEngine contract with reward functions
Clawue884 Mar 30, 2026
517553c
Implement AI verification and user generation functions
Clawue884 Mar 30, 2026
99149d8
Implement real-time data updates in App component
Clawue884 Mar 30, 2026
6b48d6c
Implement full simulation for user rewards calculation
Clawue884 Mar 30, 2026
9bd9fb8
Add feature extraction function for user data
Clawue884 Mar 30, 2026
2d3e583
Add training script for AI verification model
Clawue884 Mar 30, 2026
53f1fad
Add inference script for AI model verification
Clawue884 Mar 30, 2026
1c1b38f
Add user simulation with reward calculation
Clawue884 Mar 30, 2026
a113c7e
Implement AI verification endpoint with FastAPI
Clawue884 Mar 30, 2026
f0d432f
Implement user verification function in client.py
Clawue884 Mar 30, 2026
ffabd55
Implement user processing and reward minting
Clawue884 Mar 30, 2026
37f42b7
Implement FastAPI endpoint for user processing
Clawue884 Mar 30, 2026
180fa79
Refactor App component to send user data and display result
Clawue884 Mar 30, 2026
e09e36d
Add connectWallet function to handle wallet connection
Clawue884 Mar 30, 2026
683e870
Add wallet connection and data submission functionality
Clawue884 Mar 30, 2026
b955c99
Add signature verification function
Clawue884 Mar 30, 2026
9b1d3d0
Add RPC call implementation in test.js
Clawue884 Apr 1, 2026
971e16e
Rename test.js to backend/test.js
Clawue884 Apr 1, 2026
9b08087
Implement RPC client for Pi network
Clawue884 Apr 1, 2026
46823c1
Initialize Express server with API endpoints
Clawue884 Apr 1, 2026
60b0dfe
Create server.js
Clawue884 Apr 1, 2026
3c2ac96
Add endpoint for AIOracle anomaly analysis
Clawue884 Apr 1, 2026
8092bf9
Implement AIOracle class for network analysis
Clawue884 Apr 1, 2026
f88ae30
Implement AnomalyDetector class for risk assessment
Clawue884 Apr 1, 2026
1ac92b8
Initialize package.json with project details
Clawue884 Apr 1, 2026
ab300f2
Implement PiRPC class for JSON-RPC calls
Clawue884 Apr 1, 2026
e9b8540
Refactor server.js to use ES modules and update endpoints
Clawue884 Apr 1, 2026
a81ae87
Update package.json
Clawue884 Apr 1, 2026
052b025
Update package.json
Clawue884 Apr 1, 2026
8448926
Update piRpc.js
Clawue884 Apr 1, 2026
977ad59
Update server.js
Clawue884 Apr 1, 2026
3cd0f8e
Update package.json
Clawue884 Apr 1, 2026
84cacb0
Create piHealth.js
Clawue884 Apr 1, 2026
bcc74e1
Create actionEngine.js
Clawue884 Apr 1, 2026
c42467c
Create healthRoute.js
Clawue884 Apr 1, 2026
5618310
Create app.js
Clawue884 Apr 1, 2026
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
73 changes: 73 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useState } from "react";
import { connectWallet, signMessage } from "./wallet";

function App() {
const [wallet, setWallet] = useState(null);
const [result, setResult] = useState(null);

const handleConnect = async () => {
const addr = await connectWallet();
setWallet(addr);
};

const sendData = async () => {
if (!wallet) {
alert("Connect wallet first");
return;
}

const user = {
attention: Math.random() * 10,
quality: Math.random(),
behavior: Math.random(),
session_time: Math.random() * 10,
interaction_rate: Math.random() * 5,
};

const message = JSON.stringify(user);
const signature = await signMessage(message);

const res = await fetch("http://localhost:8000/process", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
user,
address: wallet,
signature
}),
});

const data = await res.json();
setResult(data);
};

return (
<div style={{ padding: 20 }}>
<h1>PiRC-AI Wallet Dashboard</h1>

{!wallet ? (
<button onClick={handleConnect}>
Connect Wallet
</button>
) : (
<p>Wallet: {wallet}</p>
)}

<button onClick={sendData}>
Generate Attention
</button>

{result && (
<div>
<p>Verification: {result.verification.toFixed(3)}</p>
<p>Reward: {result.reward.toFixed(3)}</p>
<p>Balance: {result.balance.toFixed(3)}</p>
</div>
)}
</div>
);
}

export default App;
60 changes: 59 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
See [PiRC1: Pi Ecosystem Token Design](./PiRC1/ReadMe.md)
See [PiRC1: Pi Ecosystem Token Design](./PiRC1/ReadMe.md)

# PiRC-AI: Attention-Based Token Economy for Pi Network

PiRC-AI is an extended implementation of the Pi Request for Comment (PiRC), introducing an attention-centered token economic model designed for the AI era.

As automation reduces the role of traditional labor, this project explores a new paradigm where verified human attention becomes a core economic resource.

## Core Innovations
- Attention-based reward system (Attention Mining)
- AI-powered human verification (anti-bot & Sybil resistance)
- Token economy with revenue-backed sinks
- Simulation-driven tokenomics validation

## Vision
Transitioning from a labor-centered economy to an attention-centered economy within the Pi ecosystem.

## Status
Experimental design + implementation layer (not official Pi Network code)
## Architecture Overview

PiRC-AI introduces a three-layer attention economy model:

1. Attention Contribution
Users generate verifiable attention through interaction.

2. Attention Verification
AI-based systems validate human authenticity and filter bots.

3. Attention Monetization
Attention is converted into tokenized value backed by real economic sinks (ads, data, AI training).
## Token Model

The reward mechanism follows a simple but robust formula:

R = A × Q × V

Where:
- A = Attention (time/engagement)
- Q = Quality score (interaction depth)
- V = Verification score (human authenticity)

This ensures fair distribution and resistance to manipulation.
## Simulation

The project includes simulation tools to evaluate:
- Token emission dynamics
- Network effects
- Inflation control

Future work includes AI-driven optimization of token distribution.
## Risks & Challenges

- Sybil attacks (multi-account abuse)
- Fake attention generation
- Centralization of verification AI
- Token inflation without sufficient sinks

These risks are actively considered in the design.
13 changes: 13 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import express from "express";
import healthRoute from "./routes/healthRoute.js";

const app = express();
app.use(express.json());

app.use("/api", healthRoute);

const PORT = process.env.PORT || 3000;

app.listen(PORT, () => {
console.log(`🚀 PiRC AI Oracle running on port ${PORT}`);
});
43 changes: 43 additions & 0 deletions backend/piClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const axios = require("axios");

const RPC_URL = "https://rpc.testnet.minepi.com";

async function callRPC(method, params = {}) {
try {
const response = await axios.post(
RPC_URL,
{
jsonrpc: "2.0",
id: 1,
method,
params
},
{
headers: {
"Content-Type": "application/json"
}
}
);

return response.data;
} catch (error) {
console.error("RPC Error:", error.message);
throw error;
}
}

// ===== FUNCTIONS =====

async function getHealth() {
return callRPC("getHealth");
}

async function getLatestLedger() {
const health = await getHealth();
return health.result.latestLedger;
}

module.exports = {
getHealth,
getLatestLedger
};
63 changes: 63 additions & 0 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import express from "express";
import PiRPC from "../sdk/piRpc.js";
import AIOracle from "../oracle/aiOracle.js";

const app = express();
const rpc = new PiRPC();

app.use(express.json());

// HEALTH
app.get("/health", async (req, res) => {
const data = await rpc.getHealth();
res.json(data);
});

// LEDGER
app.get("/ledger", async (req, res) => {
const data = await rpc.getLedger();
res.json(data);
});

// AI INSIGHT
app.get("/oracle/analysis", async (req, res) => {
const data = await AIOracle.analyzeNetwork();
res.json(data);
});

// SIMULASI TX
app.post("/simulate", async (req, res) => {
const { from, to, amount } = req.body;
const result = await AIOracle.simulateTransaction(from, to, amount);
res.json(result);
});

app.listen(3000, () => {
console.log("🔥 PiRC API running on http://localhost:3000");
});
app.get("/rpc/health", async (req, res) => {
try {
const data = await rpc.getHealth();
res.json(data);
} catch (err) {
res.status(500).json({ error: err.message });
}
});

app.get("/rpc/network", async (req, res) => {
try {
const data = await rpc.getNetwork();
res.json(data);
} catch (err) {
res.status(500).json({ error: err.message });
}
});

app.get("/rpc/version", async (req, res) => {
try {
const data = await rpc.getVersionInfo();
res.json(data);
} catch (err) {
res.status(500).json({ error: err.message });
}
});
42 changes: 42 additions & 0 deletions backend/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fetch from "node-fetch";

const RPC_URL = "https://rpc.testnet.minepi.com";

async function callRPC(method, params = []) {
try {
const res = await fetch(RPC_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: Date.now(),
method,
params,
}),
});

const data = await res.json();
return data.result;
} catch (err) {
console.error("Error:", err.message);
}
}

const methods = [
"getHealth",
"getLatestLedger",
"getVersion"
];

async function main() {
for (const m of methods) {
const res = await callRPC(m);
console.log("Method:", m);
console.log("Result:", res);
console.log("------------");
}
}

main();
10 changes: 10 additions & 0 deletions contracts/reward_engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "reward_engine"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = "20.3.0"
Loading