@moneytools-dev/plugin-moneytools 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +40 -2
- package/dist/client.d.ts +68 -0
- package/dist/client.js +112 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +87 -0
- package/dist/x402.d.ts +6 -0
- package/dist/x402.js +14 -0
- package/images/banner.jpg +0 -0
- package/images/logo.jpg +0 -0
- package/package.json +85 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MoneyTools
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @moneytools-dev/plugin-moneytools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Onchain safety checks for agents that are about to pay or buy. Ships as an **elizaOS plugin** and as a **tiny TypeScript client** usable from any framework.
|
|
4
|
+
|
|
5
|
+
| Action | Route | Price |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `MONEYTOOLS_WALLET_RISK` | `GET https://tools.moneytools.dev/v1/wallet-risk?address=&chain=` | $0.02 USDC (x402, no free tier) |
|
|
8
|
+
| `MONEYTOOLS_TOKEN_SAFETY` | `GET /v1/token-safety?token=&chain=&usd=` | $0.005 (10 free calls/day) |
|
|
9
|
+
| `MONEYTOOLS_TOKEN_INFO` | `GET /v1/token?token=&chain=` | $0.005 (10 free calls/day) |
|
|
10
|
+
|
|
11
|
+
Chains: base, ethereum, arbitrum, optimism, polygon, bsc, avalanche. Payment: x402 v2, `exact` scheme, USDC on Base. All endpoints are read-only; MoneyTools never signs, moves or holds funds.
|
|
12
|
+
|
|
13
|
+
## elizaOS
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { moneytoolsPlugin } from "@moneytools-dev/plugin-moneytools";
|
|
17
|
+
// character.plugins = [..., moneytoolsPlugin]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Settings (all optional):
|
|
21
|
+
|
|
22
|
+
- `MONEYTOOLS_X402_PRIVATE_KEY` — key of a dedicated low-balance Base USDC wallet that signs x402 payments. Without it, token checks run on the free tier and paid calls return the 402 terms instead of paying.
|
|
23
|
+
- `MONEYTOOLS_MAX_USD` — the plugin refuses any quote above this (default `0.02`). It also refuses any network other than Base.
|
|
24
|
+
- `MONEYTOOLS_BASE_URL` — default `https://tools.moneytools.dev`.
|
|
25
|
+
|
|
26
|
+
## Any framework
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { MoneyToolsClient, createPaidFetch } from "@moneytools-dev/plugin-moneytools";
|
|
30
|
+
const mt = new MoneyToolsClient({ paidFetch: createPaidFetch(process.env.AGENT_KEY as `0x${string}`), maxUsd: 0.02 });
|
|
31
|
+
const card = await mt.walletRisk("0x...", "base"); // { ok, data: { riskScore, grade, sanctioned, flags, ... }, resultUrl }
|
|
32
|
+
const safe = await mt.tokenSafety("0x...", "base"); // honeypot / sell-tax round trip
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Never charged twice
|
|
36
|
+
|
|
37
|
+
Every paid result includes `operation_id` and a free `result_url` (7 days). Resending the same signed payment or `Idempotency-Key` returns the stored result with `payment.charged=false`. Failed calls are never charged.
|
|
38
|
+
|
|
39
|
+
Docs: https://tools.moneytools.dev/agents.md · https://tools.moneytools.dev/llms.txt · Contact: moneytools@mail.grokbot.com
|
|
40
|
+
|
|
41
|
+
MIT License.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal MoneyTools client for three read-only onchain checks:
|
|
3
|
+
* - Wallet Risk Card GET /v1/wallet-risk $0.02 (x402, no free tier)
|
|
4
|
+
* - Token safety GET /v1/token-safety $0.005 (free tier 10/day)
|
|
5
|
+
* - Token facts GET /v1/token $0.005 (free tier 10/day)
|
|
6
|
+
* Unpaid calls return a structured "payment required" result instead of throwing.
|
|
7
|
+
* Pass `paidFetch` (an @x402/fetch wrapped fetch) to pay automatically, capped by `maxUsd`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_BASE_URL = "https://tools.moneytools.dev";
|
|
10
|
+
export declare const CHAINS: readonly ["base", "ethereum", "arbitrum", "optimism", "polygon", "bsc", "avalanche"];
|
|
11
|
+
export type Chain = (typeof CHAINS)[number];
|
|
12
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
13
|
+
export interface ClientOptions {
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
fetch?: FetchLike;
|
|
16
|
+
/** fetch that settles x402 challenges (e.g. wrapFetchWithPayment(fetch, client)). Optional. */
|
|
17
|
+
paidFetch?: FetchLike;
|
|
18
|
+
/** Never pay more than this per call in USD (default 0.02). */
|
|
19
|
+
maxUsd?: number;
|
|
20
|
+
/** Use the free daily tier on $0.005 routes (default true). */
|
|
21
|
+
freeTier?: boolean;
|
|
22
|
+
userAgent?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PaymentTerms {
|
|
25
|
+
amountUsd: string;
|
|
26
|
+
network: string;
|
|
27
|
+
asset: string;
|
|
28
|
+
payTo: string;
|
|
29
|
+
resource: string;
|
|
30
|
+
}
|
|
31
|
+
export type CallResult = {
|
|
32
|
+
ok: true;
|
|
33
|
+
status: number;
|
|
34
|
+
data: Record<string, unknown>;
|
|
35
|
+
charged: boolean;
|
|
36
|
+
resultUrl?: string;
|
|
37
|
+
operationId?: string;
|
|
38
|
+
} | {
|
|
39
|
+
ok: false;
|
|
40
|
+
status: 402;
|
|
41
|
+
paymentRequired: true;
|
|
42
|
+
terms?: PaymentTerms;
|
|
43
|
+
reason: string;
|
|
44
|
+
} | {
|
|
45
|
+
ok: false;
|
|
46
|
+
status: number;
|
|
47
|
+
error: string;
|
|
48
|
+
message?: string;
|
|
49
|
+
};
|
|
50
|
+
export declare function isAddress(x: string): boolean;
|
|
51
|
+
export declare function normalizeChain(c?: string): Chain;
|
|
52
|
+
export declare class MoneyToolsClient {
|
|
53
|
+
readonly baseUrl: string;
|
|
54
|
+
private f;
|
|
55
|
+
private paid?;
|
|
56
|
+
private maxUsd;
|
|
57
|
+
private free;
|
|
58
|
+
private ua;
|
|
59
|
+
constructor(o?: ClientOptions);
|
|
60
|
+
walletRisk(address: string, chain?: string): Promise<CallResult>;
|
|
61
|
+
tokenSafety(token: string, chain?: string, usd?: number): Promise<CallResult>;
|
|
62
|
+
token(token: string, chain?: string, holder?: string): Promise<CallResult>;
|
|
63
|
+
private get;
|
|
64
|
+
private parse;
|
|
65
|
+
}
|
|
66
|
+
/** One-line human summary for an agent reply. */
|
|
67
|
+
export declare function summarize(kind: "wallet-risk" | "token-safety" | "token", r: CallResult): string;
|
|
68
|
+
export {};
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal MoneyTools client for three read-only onchain checks:
|
|
3
|
+
* - Wallet Risk Card GET /v1/wallet-risk $0.02 (x402, no free tier)
|
|
4
|
+
* - Token safety GET /v1/token-safety $0.005 (free tier 10/day)
|
|
5
|
+
* - Token facts GET /v1/token $0.005 (free tier 10/day)
|
|
6
|
+
* Unpaid calls return a structured "payment required" result instead of throwing.
|
|
7
|
+
* Pass `paidFetch` (an @x402/fetch wrapped fetch) to pay automatically, capped by `maxUsd`.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_BASE_URL = "https://tools.moneytools.dev";
|
|
10
|
+
export const CHAINS = ["base", "ethereum", "arbitrum", "optimism", "polygon", "bsc", "avalanche"];
|
|
11
|
+
const ADDR = /^0x[0-9a-fA-F]{40}$/;
|
|
12
|
+
const ENS = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.eth$/i;
|
|
13
|
+
export function isAddress(x) { return ADDR.test(x); }
|
|
14
|
+
export function normalizeChain(c) {
|
|
15
|
+
const v = String(c || "base").toLowerCase().trim();
|
|
16
|
+
const alias = { eth: "ethereum", mainnet: "ethereum", arb: "arbitrum", op: "optimism", matic: "polygon", bnb: "bsc", avax: "avalanche" };
|
|
17
|
+
const out = (alias[v] || v);
|
|
18
|
+
if (!CHAINS.includes(out))
|
|
19
|
+
throw new Error(`unsupported chain "${c}"; use one of ${CHAINS.join(", ")}`);
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
function decodeTerms(res, body) {
|
|
23
|
+
let req = body;
|
|
24
|
+
const h = res.headers.get("payment-required");
|
|
25
|
+
if (h) {
|
|
26
|
+
try {
|
|
27
|
+
req = JSON.parse(typeof atob === "function" ? atob(h) : Buffer.from(h, "base64").toString("utf8"));
|
|
28
|
+
}
|
|
29
|
+
catch { /* keep body */ }
|
|
30
|
+
}
|
|
31
|
+
const a = req?.accepts?.[0];
|
|
32
|
+
if (!a)
|
|
33
|
+
return undefined;
|
|
34
|
+
return { amountUsd: (Number(a.amount ?? a.maxAmountRequired) / 1e6).toString(), network: a.network, asset: a.asset, payTo: a.payTo, resource: a.resource || req?.resource?.url };
|
|
35
|
+
}
|
|
36
|
+
export class MoneyToolsClient {
|
|
37
|
+
baseUrl;
|
|
38
|
+
f;
|
|
39
|
+
paid;
|
|
40
|
+
maxUsd;
|
|
41
|
+
free;
|
|
42
|
+
ua;
|
|
43
|
+
constructor(o = {}) {
|
|
44
|
+
this.baseUrl = (o.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
45
|
+
this.f = o.fetch || ((i, init) => fetch(i, init));
|
|
46
|
+
this.paid = o.paidFetch;
|
|
47
|
+
this.maxUsd = o.maxUsd ?? 0.02;
|
|
48
|
+
this.free = o.freeTier ?? true;
|
|
49
|
+
this.ua = o.userAgent || "moneytools-agent-plugin/0.1";
|
|
50
|
+
}
|
|
51
|
+
walletRisk(address, chain) {
|
|
52
|
+
if (!ADDR.test(address) && !ENS.test(address))
|
|
53
|
+
return Promise.resolve(bad("invalid_address", "address must be a 0x EVM address or an ENS name"));
|
|
54
|
+
return this.get("/v1/wallet-risk", { address, chain: normalizeChain(chain) }, false);
|
|
55
|
+
}
|
|
56
|
+
tokenSafety(token, chain, usd = 10) {
|
|
57
|
+
if (!ADDR.test(token))
|
|
58
|
+
return Promise.resolve(bad("invalid_address", "token must be a 0x EVM address"));
|
|
59
|
+
return this.get("/v1/token-safety", { token, chain: normalizeChain(chain), usd: String(usd) }, true);
|
|
60
|
+
}
|
|
61
|
+
token(token, chain, holder) {
|
|
62
|
+
if (!ADDR.test(token))
|
|
63
|
+
return Promise.resolve(bad("invalid_address", "token must be a 0x EVM address"));
|
|
64
|
+
const q = { token, chain: normalizeChain(chain) };
|
|
65
|
+
if (holder)
|
|
66
|
+
q.holder = holder;
|
|
67
|
+
return this.get("/v1/token", q, true);
|
|
68
|
+
}
|
|
69
|
+
async get(path, q, hasFree) {
|
|
70
|
+
const url = `${this.baseUrl}${path}?${new URLSearchParams(q)}`;
|
|
71
|
+
const headers = { accept: "application/json", "user-agent": this.ua };
|
|
72
|
+
if (hasFree && this.free)
|
|
73
|
+
headers["x-moneytools-free"] = "1";
|
|
74
|
+
const first = await this.f(url, { headers });
|
|
75
|
+
if (first.status !== 402)
|
|
76
|
+
return this.parse(first);
|
|
77
|
+
const body = await first.json().catch(() => ({}));
|
|
78
|
+
const terms = decodeTerms(first, body);
|
|
79
|
+
if (!this.paid)
|
|
80
|
+
return { ok: false, status: 402, paymentRequired: true, terms, reason: "x402 payment required; configure a paying fetch (x402) to buy this result" };
|
|
81
|
+
if (!terms || Number(terms.amountUsd) > this.maxUsd)
|
|
82
|
+
return { ok: false, status: 402, paymentRequired: true, terms, reason: `quoted price ${terms?.amountUsd ?? "unknown"} USD exceeds maxUsd ${this.maxUsd}; not paying` };
|
|
83
|
+
if (terms.network !== "eip155:8453")
|
|
84
|
+
return { ok: false, status: 402, paymentRequired: true, terms, reason: `unexpected network ${terms.network}; not paying` };
|
|
85
|
+
const second = await this.paid(url, { headers: { accept: "application/json", "user-agent": this.ua } });
|
|
86
|
+
return this.parse(second);
|
|
87
|
+
}
|
|
88
|
+
async parse(res) {
|
|
89
|
+
const data = await res.json().catch(() => ({}));
|
|
90
|
+
if (data && typeof data === "object")
|
|
91
|
+
delete data._sponsored;
|
|
92
|
+
if (res.ok)
|
|
93
|
+
return { ok: true, status: res.status, data, charged: !!data?.payment?.charged, resultUrl: data?.result_url, operationId: data?.operation_id };
|
|
94
|
+
if (res.status === 402)
|
|
95
|
+
return { ok: false, status: 402, paymentRequired: true, terms: decodeTerms(res, data), reason: data?.paymentError?.message || data?.error || "payment required" };
|
|
96
|
+
return { ok: false, status: res.status, error: String(data?.error || "http_error"), message: data?.message };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function bad(error, message) { return { ok: false, status: 400, error, message }; }
|
|
100
|
+
/** One-line human summary for an agent reply. */
|
|
101
|
+
export function summarize(kind, r) {
|
|
102
|
+
if (!r.ok)
|
|
103
|
+
return "paymentRequired" in r ? `MoneyTools ${kind}: payment required (${r.terms?.amountUsd ?? "?"} USDC on Base). ${r.reason}` : `MoneyTools ${kind} failed: ${r.error}${r.message ? ` — ${r.message}` : ""}`;
|
|
104
|
+
const d = r.data;
|
|
105
|
+
if (kind === "wallet-risk")
|
|
106
|
+
return `${d.headline ?? `Risk ${d.riskScore}/100`} Grade ${d.grade}, sanctioned: ${d.sanctioned ? "YES" : "no"}.${r.resultUrl ? ` Result: ${r.resultUrl}` : ""} ${d.limits ?? ""}`.trim();
|
|
107
|
+
if (kind === "token-safety") {
|
|
108
|
+
const fl = Array.isArray(d.flags) ? d.flags.map((x) => (typeof x === "string" ? x : x?.detail || x?.code)).filter(Boolean) : [];
|
|
109
|
+
return `Token safety ${d.symbol ?? d.token ?? ""} on ${d.chain}: risk ${d.risk ?? "unknown"}${fl.length ? ` — ${fl.slice(0, 3).join("; ")}` : ""}`;
|
|
110
|
+
}
|
|
111
|
+
return `${d.name ?? "token"} (${d.symbol ?? "?"}) on ${d.chain}: decimals ${d.decimals}, owner ${d.owner ?? "none"}, paused ${d.paused}, ${d.proxy ? "upgradeable proxy" : "not a proxy"}${Array.isArray(d.flags) && d.flags.length ? `. Flags: ${d.flags.join("; ")}` : ""}`;
|
|
112
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Action, IAgentRuntime, Plugin } from "@elizaos/core";
|
|
2
|
+
import { MoneyToolsClient } from "./client.js";
|
|
3
|
+
export * from "./client.js";
|
|
4
|
+
export { createPaidFetch } from "./x402.js";
|
|
5
|
+
export declare function clientFor(rt: IAgentRuntime): MoneyToolsClient;
|
|
6
|
+
export declare const walletRiskAction: Action;
|
|
7
|
+
export declare const tokenSafetyAction: Action;
|
|
8
|
+
export declare const tokenInfoAction: Action;
|
|
9
|
+
export declare const moneytoolsPlugin: Plugin;
|
|
10
|
+
export default moneytoolsPlugin;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { MoneyToolsClient, summarize, CHAINS } from "./client.js";
|
|
2
|
+
import { createPaidFetch } from "./x402.js";
|
|
3
|
+
export * from "./client.js";
|
|
4
|
+
export { createPaidFetch } from "./x402.js";
|
|
5
|
+
const ADDR_RE = /0x[0-9a-fA-F]{40}/g;
|
|
6
|
+
const ENS_RE = /\b[a-z0-9-]+\.eth\b/i;
|
|
7
|
+
function setting(rt, k) { const v = rt.getSetting(k); return v === null || v === undefined || v === "" ? undefined : String(v); }
|
|
8
|
+
const cache = new WeakMap();
|
|
9
|
+
export function clientFor(rt) {
|
|
10
|
+
const hit = cache.get(rt);
|
|
11
|
+
if (hit)
|
|
12
|
+
return hit;
|
|
13
|
+
const pk = setting(rt, "MONEYTOOLS_X402_PRIVATE_KEY");
|
|
14
|
+
const c = new MoneyToolsClient({
|
|
15
|
+
baseUrl: setting(rt, "MONEYTOOLS_BASE_URL"),
|
|
16
|
+
maxUsd: Number(setting(rt, "MONEYTOOLS_MAX_USD") ?? "0.02"),
|
|
17
|
+
paidFetch: pk && /^0x[0-9a-fA-F]{64}$/.test(pk) ? createPaidFetch(pk) : undefined,
|
|
18
|
+
});
|
|
19
|
+
cache.set(rt, c);
|
|
20
|
+
return c;
|
|
21
|
+
}
|
|
22
|
+
function pick(message, options, key) {
|
|
23
|
+
const p = options?.parameters?.[key];
|
|
24
|
+
if (typeof p === "string" && p)
|
|
25
|
+
return p;
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
function textOf(m) { return String(m.content?.text ?? ""); }
|
|
29
|
+
function chainFrom(text) { const t = text.toLowerCase(); return CHAINS.find((c) => new RegExp(`\\b${c}\\b`).test(t)); }
|
|
30
|
+
async function respond(kind, r, cb) {
|
|
31
|
+
const text = summarize(kind, r);
|
|
32
|
+
if (cb)
|
|
33
|
+
await cb({ text, actions: [] });
|
|
34
|
+
return { success: r.ok, text, data: { moneytools: r }, ...(r.ok ? {} : { error: "paymentRequired" in r ? "payment_required" : r.error }) };
|
|
35
|
+
}
|
|
36
|
+
const chainParam = { name: "chain", description: `EVM chain: ${CHAINS.join(", ")} (default base)`, required: false, schema: { type: "string", enum: [...CHAINS] } };
|
|
37
|
+
export const walletRiskAction = {
|
|
38
|
+
name: "MONEYTOOLS_WALLET_RISK",
|
|
39
|
+
similes: ["CHECK_WALLET_RISK", "WALLET_RISK_CARD", "SCREEN_ADDRESS", "IS_WALLET_SANCTIONED"],
|
|
40
|
+
description: "Score an EVM wallet before paying or trusting it: 0-100 risk score, A-F grade, OFAC sanctions match, EIP-7702/contract checks and open ERC-20 approvals. MoneyTools Wallet Risk Card, $0.02 USDC on Base via x402. Read-only.",
|
|
41
|
+
parameters: [{ name: "address", description: "0x address or ENS name to score", required: true, schema: { type: "string" } }, chainParam],
|
|
42
|
+
validate: async (_rt, m) => true,
|
|
43
|
+
handler: async (rt, m, _s, o, cb) => {
|
|
44
|
+
const t = textOf(m);
|
|
45
|
+
const address = pick(m, o, "address") || t.match(ADDR_RE)?.[0] || t.match(ENS_RE)?.[0];
|
|
46
|
+
if (!address)
|
|
47
|
+
return respond("wallet-risk", { ok: false, status: 400, error: "missing_address", message: "give a 0x address or ENS name" }, cb);
|
|
48
|
+
return respond("wallet-risk", await clientFor(rt).walletRisk(address, pick(m, o, "chain") || chainFrom(t)), cb);
|
|
49
|
+
},
|
|
50
|
+
examples: [[{ name: "{{user}}", content: { text: "Is 0x8589427373D6D84E98730D7795D8f6f8731FDA16 safe to pay on ethereum?" } }, { name: "{{agent}}", content: { text: "Checking its wallet risk card.", actions: ["MONEYTOOLS_WALLET_RISK"] } }]],
|
|
51
|
+
};
|
|
52
|
+
export const tokenSafetyAction = {
|
|
53
|
+
name: "MONEYTOOLS_TOKEN_SAFETY",
|
|
54
|
+
similes: ["CHECK_HONEYPOT", "TOKEN_SAFETY", "CAN_I_SELL_TOKEN", "TOKEN_SELL_TAX"],
|
|
55
|
+
description: "Before buying an ERC-20: simulate a USDC→token→USDC round trip with live DEX quotes and read owner/proxy/paused flags to detect honeypots and sell taxes. $0.005 via x402 after a free tier of 10 calls/day. Read-only.",
|
|
56
|
+
parameters: [{ name: "token", description: "ERC-20 contract address", required: true, schema: { type: "string" } }, chainParam],
|
|
57
|
+
validate: async () => true,
|
|
58
|
+
handler: async (rt, m, _s, o, cb) => {
|
|
59
|
+
const t = textOf(m);
|
|
60
|
+
const token = pick(m, o, "token") || t.match(ADDR_RE)?.[0];
|
|
61
|
+
if (!token)
|
|
62
|
+
return respond("token-safety", { ok: false, status: 400, error: "missing_token", message: "give an ERC-20 contract address" }, cb);
|
|
63
|
+
return respond("token-safety", await clientFor(rt).tokenSafety(token, pick(m, o, "chain") || chainFrom(t)), cb);
|
|
64
|
+
},
|
|
65
|
+
examples: [[{ name: "{{user}}", content: { text: "Is 0x4200000000000000000000000000000000000006 on base a honeypot?" } }, { name: "{{agent}}", content: { text: "Running a round-trip safety check.", actions: ["MONEYTOOLS_TOKEN_SAFETY"] } }]],
|
|
66
|
+
};
|
|
67
|
+
export const tokenInfoAction = {
|
|
68
|
+
name: "MONEYTOOLS_TOKEN_INFO",
|
|
69
|
+
similes: ["TOKEN_FACTS", "ERC20_INFO", "TOKEN_OWNER", "IS_TOKEN_UPGRADEABLE"],
|
|
70
|
+
description: "ERC-20 facts: name, symbol, decimals, total supply, owner, paused, upgradeable-proxy detection, optional holder balance. $0.005 via x402 after a free tier of 10 calls/day. Read-only.",
|
|
71
|
+
parameters: [{ name: "token", description: "ERC-20 contract address", required: true, schema: { type: "string" } }, chainParam],
|
|
72
|
+
validate: async () => true,
|
|
73
|
+
handler: async (rt, m, _s, o, cb) => {
|
|
74
|
+
const t = textOf(m);
|
|
75
|
+
const token = pick(m, o, "token") || t.match(ADDR_RE)?.[0];
|
|
76
|
+
if (!token)
|
|
77
|
+
return respond("token", { ok: false, status: 400, error: "missing_token", message: "give an ERC-20 contract address" }, cb);
|
|
78
|
+
return respond("token", await clientFor(rt).token(token, pick(m, o, "chain") || chainFrom(t)), cb);
|
|
79
|
+
},
|
|
80
|
+
examples: [[{ name: "{{user}}", content: { text: "Who owns token 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 on base?" } }, { name: "{{agent}}", content: { text: "Reading the token facts.", actions: ["MONEYTOOLS_TOKEN_INFO"] } }]],
|
|
81
|
+
};
|
|
82
|
+
export const moneytoolsPlugin = {
|
|
83
|
+
name: "moneytools",
|
|
84
|
+
description: "Onchain safety checks for agents that pay: MoneyTools Wallet Risk Card ($0.02), token-safety honeypot simulation and token facts ($0.005, free tier) over x402 on Base. Read-only.",
|
|
85
|
+
actions: [walletRiskAction, tokenSafetyAction, tokenInfoAction],
|
|
86
|
+
};
|
|
87
|
+
export default moneytoolsPlugin;
|
package/dist/x402.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a fetch that pays x402 challenges from a Base USDC wallet.
|
|
3
|
+
* The key stays in this process; it is only used to sign the EIP-3009 transfer quoted in the 402.
|
|
4
|
+
* Use a dedicated low-balance wallet for agent spending.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createPaidFetch(privateKey: `0x${string}`): (input: string, init?: RequestInit) => Promise<Response>;
|
package/dist/x402.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
|
|
2
|
+
import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
3
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
4
|
+
/**
|
|
5
|
+
* Build a fetch that pays x402 challenges from a Base USDC wallet.
|
|
6
|
+
* The key stays in this process; it is only used to sign the EIP-3009 transfer quoted in the 402.
|
|
7
|
+
* Use a dedicated low-balance wallet for agent spending.
|
|
8
|
+
*/
|
|
9
|
+
export function createPaidFetch(privateKey) {
|
|
10
|
+
const account = privateKeyToAccount(privateKey);
|
|
11
|
+
const client = new x402Client();
|
|
12
|
+
registerExactEvmScheme(client, { signer: account });
|
|
13
|
+
return wrapFetchWithPayment(fetch, client);
|
|
14
|
+
}
|
|
Binary file
|
package/images/logo.jpg
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneytools-dev/plugin-moneytools",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "elizaOS plugin + tiny TS client: score an EVM wallet (risk 0-100, A-F grade, OFAC, approvals) or an ERC-20 (honeypot / sell-tax round trip, owner/proxy facts) before your agent pays or buys. MoneyTools x402 endpoints on Base: $0.02 wallet risk card, $0.005 token checks with a free tier. Read-only.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./dist/client.d.ts",
|
|
15
|
+
"import": "./dist/client.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"images",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p .",
|
|
26
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
27
|
+
"prepublishOnly": "npm test"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "MoneyTools <moneytools@mail.grokbot.com>",
|
|
31
|
+
"homepage": "https://tools.moneytools.dev/agents.md",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"elizaos",
|
|
34
|
+
"elizaos-plugins",
|
|
35
|
+
"plugin",
|
|
36
|
+
"x402",
|
|
37
|
+
"base",
|
|
38
|
+
"usdc",
|
|
39
|
+
"wallet-risk",
|
|
40
|
+
"ofac",
|
|
41
|
+
"token-safety",
|
|
42
|
+
"honeypot",
|
|
43
|
+
"ai-agents",
|
|
44
|
+
"moneytools"
|
|
45
|
+
],
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@elizaos/core": ">=1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@elizaos/core": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@x402/evm": "^2.31.0",
|
|
56
|
+
"@x402/fetch": "^2.31.0",
|
|
57
|
+
"viem": "^2.57.20"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@elizaos/core": "^2.0.5",
|
|
61
|
+
"@types/node": "^26.6.6",
|
|
62
|
+
"typescript": "^5.9.3"
|
|
63
|
+
},
|
|
64
|
+
"agentConfig": {
|
|
65
|
+
"pluginType": "elizaos:plugin:1.0.0",
|
|
66
|
+
"pluginParameters": {
|
|
67
|
+
"MONEYTOOLS_X402_PRIVATE_KEY": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "Optional. 0x private key of a dedicated low-balance Base USDC wallet used only to sign x402 payments. Without it, token checks use the free tier and paid calls return the 402 terms.",
|
|
70
|
+
"required": false,
|
|
71
|
+
"sensitive": true
|
|
72
|
+
},
|
|
73
|
+
"MONEYTOOLS_MAX_USD": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "Max USD per call the plugin will pay (default 0.02).",
|
|
76
|
+
"required": false
|
|
77
|
+
},
|
|
78
|
+
"MONEYTOOLS_BASE_URL": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"description": "Default https://tools.moneytools.dev",
|
|
81
|
+
"required": false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=18"
|
|
87
|
+
}
|
|
6
88
|
}
|