LeoYeAI/agent-master-skills / skills/aawp
aawp
FlaggedAAWP (AI Agent Wallet Protocol) — the only crypto wallet protocol built exclusively for AI Agents on EVM-compatible blockchains. Not for humans. The signer is the AI Agent itself, cryptographically bound at wallet creation. Supports wallet lifecycle management, token transfers, DEX swaps, cross-chain bridging, arbitrary contract interactions, DCA automation, and price alerts.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 10.9 KB |
| SKILL.md | skill md | 20.1 KB |
| WALLET_SETUP.md | markdown | 4.6 KB |
| _meta.json | config | 436 B |
| bin/install.js | script | 7.0 KB |
| config/chains.json | config | 4.2 KB |
| core/index.d.ts | script | 2.8 KB |
| core/loader.js | script | 1.0 KB |
| daemon/client.js | script | 1.1 KB |
| daemon/daemon.js | script | 606 B |
| lib/address-book.js | script | 1.6 KB |
| lib/gas-estimator.js | script | 1.7 KB |
| lib/multicall.js | script | 2.6 KB |
| lib/nonce-manager.js | script | 1.9 KB |
| lib/tx-history.js | script | 1.3 KB |
| scripts/bootstrap.sh | script | 1.7 KB |
| scripts/dca.js | script | 9.4 KB |
| scripts/deploy-clanker.js | script | 13.6 KB |
| scripts/doctor.sh | script | 1.6 KB |
| scripts/ensure-daemon.sh | script | 2.2 KB |
| scripts/limit-order.js | script | 28.3 KB |
| scripts/nft.js | script | 25.2 KB |
| scripts/portfolio.js | script | 18.0 KB |
| scripts/price-alert.js | script | 12.1 KB |
| scripts/provision.sh | script | 9.4 KB |
| scripts/restart-daemon.sh | script | 1.5 KB |
| scripts/restore-impl.js | script | 3.9 KB |
| scripts/sign-worker.js | script | 2.9 KB |
| scripts/start-daemon.js | script | 3.9 KB |
| scripts/swap.js | script | 31.8 KB |
| scripts/wallet-manager.js | script | 70.6 KB |
| scripts/yield.js | script | 34.1 KB |
scripts/start-daemon.js
View on GitHub'use strict';
/**
* start-daemon.js — AAWP persistent daemon launcher
* Must be called by OpenClaw ONLY. Generates AI gate token, arms daemon,
* writes socket path to lock file. wallet-manager.js connects to this daemon.
*
* Usage: node start-daemon.js
* Exits 0 on success, prints socket path to stdout.
*/
const crypto = require('crypto');
const fs = require('fs');
const net = require('net');
const addon = require('../core/aawp-core.node');
const C = process.env.AAWP_CONFIG || require('path').join(__dirname, '..', '.agent-config');
const S = process.env.AAWP_SKILL || require('path').resolve(__dirname, '..');
const LOCK = '/tmp/.aawp-daemon.lock';
// Generate random 32-byte AI gate token
const token = crypto.randomBytes(32).toString('hex');
process.env.AAWP_AI_TOKEN = token;
// Clean up stale lock/socket/token files from crashed daemon
try {
const stale = JSON.parse(fs.readFileSync(LOCK, 'utf8'));
if (stale.sock) try { fs.unlinkSync(stale.sock); } catch (_) {}
fs.unlinkSync(LOCK);
} catch (_) {}
try { fs.unlinkSync('/tmp/.aawp-ai-token'); } catch (_) {}
function socketQuery(sock, payload, timeoutMs = 5000) {
return new Promise((resolve, reject) => {
const ts = Math.floor(Date.now() / 1000);
const hmac = addon._h0(ts);
const req = JSON.stringify({ ...payload, ts, hmac });
const c = net.createConnection(sock, () => c.end(req));
let data = '';
const timer = setTimeout(() => {
c.destroy();
reject(new Error('healthcheck timeout'));
}, timeoutMs);
c.on('data', chunk => { data += chunk; });
c.on('end', () => {
clearTimeout(timer);
try { resolve(JSON.parse(data)); }
catch (_) { reject(new Error('invalid healthcheck response')); }
});
c.on('error', err => {
clearTimeout(timer);
reject(err);
});
});
}
async function waitForHealthy(sock, timeoutMs = 10000) {
const started = Date.now();
while (Date.now() - started < timeoutMs) {
if (fs.existsSync(sock)) {
try {
const res = await socketQuery(sock, { cmd: 'address' }, 2000);
if (res && res.address) return res;
} catch (_) {}
}
await new Promise(r => setTimeout(r, 250));
}
throw new Error(`daemon healthcheck failed for socket ${sock}`);
}
async function main() {
// Start daemon (reads env var, arms gate, clears env var internally)
addon._l0(C, S, '/tmp/aawp.log');
const sock = addon._x0();
let health;
try {
health = await waitForHealthy(sock, 12000);
} catch (err) {
try { fs.unlinkSync(LOCK); } catch (_) {}
console.error('[AAWP] startup failed:', err.message || err);
process.exit(1);
}
// Write lock file only after successful healthcheck.
fs.writeFileSync(LOCK, JSON.stringify({ sock }), { mode: 0o600 });
console.log(sock);
console.log('[AAWP] healthy address=' + health.address);
let _tokenDelivered = false;
try {
fs.writeSync(3, 'TOKEN:' + token + '\n');
_tokenDelivered = true;
} catch (_) {}
if (!_tokenDelivered) {
console.log('TOKEN:' + token);
}
try { fs.writeFileSync('/tmp/.aawp-ai-token', token, { mode: 0o600 }); } catch (_) {}
// Keep the token file synchronized with daemon-side one-time rotation.
let lastToken = token;
setInterval(() => {
try {
const next = addon._a0();
if (next && next !== lastToken) {
fs.writeFileSync('/tmp/.aawp-ai-token', next, { mode: 0o600 });
lastToken = next;
}
} catch (_) {}
}, 500);
// Keep process alive — daemon runs in Rust background thread, needs host process.
setInterval(() => {}, 60000);
}
main().catch(err => {
console.error('[AAWP] fatal startup error:', err && err.message ? err.message : String(err));
process.exit(1);
});
process.on('SIGTERM', () => {
try { fs.unlinkSync(LOCK); } catch (_) {}
process.exit(0);
});
process.on('SIGINT', () => {
try { fs.unlinkSync(LOCK); } catch (_) {}
process.exit(0);
});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |