solana-agent-kit-plugin-madeonsol 0.2.1 → 0.3.1

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/README.md CHANGED
@@ -1,13 +1,25 @@
1
1
  # solana-agent-kit-plugin-madeonsol
2
2
 
3
- [Solana Agent Kit](https://github.com/sendaifun/solana-agent-kit) plugin for [MadeOnSol](https://madeonsol.com) — Solana KOL intelligence and deployer analytics via x402 micropayments.
3
+ [Solana Agent Kit](https://github.com/sendaifun/solana-agent-kit) plugin for [MadeOnSol](https://madeonsol.com) — Solana KOL intelligence and deployer analytics.
4
+
5
+ ## Authentication
6
+
7
+ Three options (in priority order):
8
+
9
+ | Method | Config key | Best for |
10
+ |---|---|---|
11
+ | **MadeOnSol API key** (recommended) | `MADEONSOL_API_KEY` | Developers — [get a free key](https://madeonsol.com/developer) |
12
+ | RapidAPI key | `RAPIDAPI_KEY` | RapidAPI subscribers |
13
+ | x402 micropayments | `SVM_PRIVATE_KEY` | AI agents with Solana wallets |
4
14
 
5
15
  ## Install
6
16
 
7
17
  ```bash
8
- npm install solana-agent-kit-plugin-madeonsol @x402/fetch @x402/svm @x402/core @solana/kit @scure/base
18
+ npm install solana-agent-kit-plugin-madeonsol
9
19
  ```
10
20
 
21
+ > x402 peer deps (`@x402/fetch @x402/svm @x402/core @solana/kit @scure/base`) are only needed when using `SVM_PRIVATE_KEY`.
22
+
11
23
  ## Usage
12
24
 
13
25
  ```typescript
@@ -15,7 +27,14 @@ import { SolanaAgentKit } from "solana-agent-kit";
15
27
  import MadeOnSolPlugin from "solana-agent-kit-plugin-madeonsol";
16
28
 
17
29
  const agent = new SolanaAgentKit(privateKey, rpcUrl, {
18
- SVM_PRIVATE_KEY: "your_solana_private_key_base58",
30
+ // Option 1: API key (simplest)
31
+ MADEONSOL_API_KEY: "msk_your_api_key_here",
32
+
33
+ // Option 2: RapidAPI key
34
+ // RAPIDAPI_KEY: "your_rapidapi_key",
35
+
36
+ // Option 3: x402 micropayments
37
+ // SVM_PRIVATE_KEY: "your_solana_private_key_base58",
19
38
  });
20
39
 
21
40
  agent.use(MadeOnSolPlugin);
@@ -29,18 +48,12 @@ const trades = await agent.methods.kolFeed(agent, { limit: 10, action: "buy" });
29
48
 
30
49
  ## Actions
31
50
 
32
- | Action | Price | Triggers on |
33
- |---|---|---|
34
- | `MADEONSOL_KOL_FEED_ACTION` | $0.005 | "kol trades", "what are kols buying" |
35
- | `MADEONSOL_KOL_COORDINATION_ACTION` | $0.02 | "kol convergence", "tokens kols accumulating" |
36
- | `MADEONSOL_KOL_LEADERBOARD_ACTION` | $0.005 | "top kols", "kol rankings", "best kol" |
37
- | `MADEONSOL_DEPLOYER_ALERTS_ACTION` | $0.01 | "deployer alerts", "pump fun launches" |
38
-
39
- ## Config
40
-
41
- Set `SVM_PRIVATE_KEY` in your agent config for automatic x402 USDC payments. The wallet needs SOL (fees) and USDC on Solana mainnet.
42
-
43
- With `RAPIDAPI_KEY`, webhook and streaming methods are also available. Ultra subscribers get the **DEX Trade Stream** — a real-time WebSocket feed of all Solana DEX trades via `wss://madeonsol.com/ws/v1/dex-stream`.
51
+ | Action | Triggers on |
52
+ |---|---|
53
+ | `MADEONSOL_KOL_FEED_ACTION` | "kol trades", "what are kols buying" |
54
+ | `MADEONSOL_KOL_COORDINATION_ACTION` | "kol convergence", "tokens kols accumulating" |
55
+ | `MADEONSOL_KOL_LEADERBOARD_ACTION` | "top kols", "kol rankings", "best kol" |
56
+ | `MADEONSOL_DEPLOYER_ALERTS_ACTION` | "deployer alerts", "pump fun launches" |
44
57
 
45
58
  ## Also Available
46
59
 
@@ -1,8 +1,11 @@
1
1
  /**
2
- * Tool functions — pure logic that calls MadeOnSol x402 API.
2
+ * Tool functions — pure logic that calls MadeOnSol API.
3
+ * Auth priority: MADEONSOL_API_KEY > RAPIDAPI_KEY > SVM_PRIVATE_KEY (x402).
3
4
  * These are called by Action handlers and can also be used directly via agent.methods.
4
5
  */
5
6
  type Agent = any;
7
+ export declare function initAuth(agent: Agent): Promise<void>;
8
+ /** @deprecated Use initAuth instead */
6
9
  export declare function initPaidFetch(agent: Agent): Promise<typeof fetch>;
7
10
  export declare function kolFeed(agent: Agent, params?: {
8
11
  limit?: number;
@@ -23,6 +26,23 @@ export declare function deployerAlerts(agent: Agent, params?: {
23
26
  since?: string;
24
27
  offset?: number;
25
28
  }): Promise<any>;
29
+ export declare function kolPairs(agent: Agent, params?: {
30
+ period?: string;
31
+ min_shared?: number;
32
+ limit?: number;
33
+ }): Promise<any>;
34
+ export declare function kolHotTokens(agent: Agent, params?: {
35
+ period?: string;
36
+ min_kols?: number;
37
+ limit?: number;
38
+ }): Promise<any>;
39
+ export declare function kolTiming(agent: Agent, params: {
40
+ wallet: string;
41
+ period?: string;
42
+ }): Promise<any>;
43
+ export declare function deployerTrajectory(agent: Agent, params: {
44
+ wallet: string;
45
+ }): Promise<any>;
26
46
  export declare function createWebhook(agent: Agent, params: {
27
47
  url: string;
28
48
  events: string[];
@@ -1,71 +1,120 @@
1
1
  /**
2
- * Tool functions — pure logic that calls MadeOnSol x402 API.
2
+ * Tool functions — pure logic that calls MadeOnSol API.
3
+ * Auth priority: MADEONSOL_API_KEY > RAPIDAPI_KEY > SVM_PRIVATE_KEY (x402).
3
4
  * These are called by Action handlers and can also be used directly via agent.methods.
4
5
  */
5
6
  const BASE_URL = "https://madeonsol.com";
6
- async function query(paidFetch, path, params) {
7
- const url = new URL(path, BASE_URL);
7
+ const RAPIDAPI_HOST = "madeonsol-solana-kol-tracker-tools-api.p.rapidapi.com";
8
+ let _authMode = null;
9
+ let _authHeaders = {};
10
+ let _paidFetch = null;
11
+ function getConfig(agent, key) {
12
+ return agent.config?.[key] || agent.config?.OTHER_API_KEYS?.[key];
13
+ }
14
+ export async function initAuth(agent) {
15
+ if (_authMode)
16
+ return;
17
+ const apiKey = getConfig(agent, "MADEONSOL_API_KEY");
18
+ const rapidApiKey = getConfig(agent, "RAPIDAPI_KEY");
19
+ const privateKey = getConfig(agent, "SVM_PRIVATE_KEY");
20
+ if (apiKey) {
21
+ _authMode = "madeonsol";
22
+ _authHeaders = { Authorization: `Bearer ${apiKey}` };
23
+ _paidFetch = fetch;
24
+ console.log("[madeonsol] Using MadeOnSol API key (Bearer auth)");
25
+ }
26
+ else if (rapidApiKey) {
27
+ _authMode = "rapidapi";
28
+ _authHeaders = { "x-rapidapi-key": rapidApiKey, "x-rapidapi-host": RAPIDAPI_HOST };
29
+ _paidFetch = fetch;
30
+ console.log("[madeonsol] Using RapidAPI key");
31
+ }
32
+ else if (privateKey) {
33
+ const { wrapFetchWithPayment } = await import("@x402/fetch");
34
+ const { x402Client } = await import("@x402/core/client");
35
+ const { ExactSvmScheme } = await import("@x402/svm/exact/client");
36
+ const { createKeyPairSignerFromBytes } = await import("@solana/kit");
37
+ const { base58 } = await import("@scure/base");
38
+ const signer = await createKeyPairSignerFromBytes(base58.decode(privateKey));
39
+ const client = new x402Client();
40
+ client.register("solana:*", new ExactSvmScheme(signer));
41
+ _paidFetch = wrapFetchWithPayment(fetch, client);
42
+ _authMode = "x402";
43
+ console.log(`[madeonsol] x402 payments enabled, wallet: ${signer.address}`);
44
+ }
45
+ else {
46
+ _authMode = "none";
47
+ _paidFetch = fetch;
48
+ console.warn("[madeonsol] No auth configured. Set MADEONSOL_API_KEY (free at madeonsol.com/developer), RAPIDAPI_KEY, or SVM_PRIVATE_KEY.");
49
+ }
50
+ }
51
+ /** @deprecated Use initAuth instead */
52
+ export async function initPaidFetch(agent) {
53
+ await initAuth(agent);
54
+ return _paidFetch;
55
+ }
56
+ async function query(path, params) {
57
+ const apiPath = _authMode === "x402" || _authMode === "none"
58
+ ? path
59
+ : path.replace("/api/x402/", "/api/v1/");
60
+ const url = new URL(apiPath, BASE_URL);
8
61
  if (params) {
9
62
  for (const [k, v] of Object.entries(params)) {
10
63
  if (v !== undefined)
11
64
  url.searchParams.set(k, String(v));
12
65
  }
13
66
  }
14
- const res = await paidFetch(url.toString());
67
+ const res = _authMode === "x402"
68
+ ? await _paidFetch(url.toString())
69
+ : await fetch(url.toString(), { headers: _authHeaders });
15
70
  if (!res.ok) {
16
71
  const body = await res.text().catch(() => "");
17
72
  throw new Error(`MadeOnSol API error ${res.status}: ${body}`);
18
73
  }
19
74
  return res.json();
20
75
  }
21
- let _paidFetch = null;
22
- export async function initPaidFetch(agent) {
23
- if (_paidFetch)
24
- return _paidFetch;
25
- const privateKey = agent.config?.SVM_PRIVATE_KEY || agent.config?.OTHER_API_KEYS?.SVM_PRIVATE_KEY;
26
- if (!privateKey) {
27
- console.warn("[madeonsol] No SVM_PRIVATE_KEY in agent config — x402 payments disabled");
28
- _paidFetch = fetch;
29
- return _paidFetch;
30
- }
31
- const { wrapFetchWithPayment } = await import("@x402/fetch");
32
- const { x402Client } = await import("@x402/core/client");
33
- const { ExactSvmScheme } = await import("@x402/svm/exact/client");
34
- const { createKeyPairSignerFromBytes } = await import("@solana/kit");
35
- const { base58 } = await import("@scure/base");
36
- const signer = await createKeyPairSignerFromBytes(base58.decode(privateKey));
37
- const client = new x402Client();
38
- client.register("solana:*", new ExactSvmScheme(signer));
39
- _paidFetch = wrapFetchWithPayment(fetch, client);
40
- return _paidFetch;
41
- }
42
76
  export async function kolFeed(agent, params = {}) {
43
- const f = await initPaidFetch(agent);
44
- return query(f, "/api/x402/kol/feed", params);
77
+ await initAuth(agent);
78
+ return query("/api/x402/kol/feed", params);
45
79
  }
46
80
  export async function kolCoordination(agent, params = {}) {
47
- const f = await initPaidFetch(agent);
48
- return query(f, "/api/x402/kol/coordination", params);
81
+ await initAuth(agent);
82
+ return query("/api/x402/kol/coordination", params);
49
83
  }
50
84
  export async function kolLeaderboard(agent, params = {}) {
51
- const f = await initPaidFetch(agent);
52
- return query(f, "/api/x402/kol/leaderboard", params);
85
+ await initAuth(agent);
86
+ return query("/api/x402/kol/leaderboard", params);
53
87
  }
54
88
  export async function deployerAlerts(agent, params = {}) {
55
- const f = await initPaidFetch(agent);
56
- return query(f, "/api/x402/deployer-hunter/alerts", params);
89
+ await initAuth(agent);
90
+ return query("/api/x402/deployer-hunter/alerts", params);
91
+ }
92
+ export async function kolPairs(agent, params = {}) {
93
+ await initAuth(agent);
94
+ return query("/api/x402/kol/pairs", params);
95
+ }
96
+ export async function kolHotTokens(agent, params = {}) {
97
+ await initAuth(agent);
98
+ return query("/api/x402/kol/tokens/hot", params);
57
99
  }
58
- // ── Webhook & Streaming (RapidAPI key required) ──
100
+ export async function kolTiming(agent, params) {
101
+ const qs = params.period ? `?period=${params.period}` : "";
102
+ return restQuery(agent, "GET", `/kol/${params.wallet}/timing${qs}`);
103
+ }
104
+ export async function deployerTrajectory(agent, params) {
105
+ return restQuery(agent, "GET", `/deployer-hunter/${params.wallet}/trajectory`);
106
+ }
107
+ // ── Webhook & Streaming (requires API key or RapidAPI key) ──
59
108
  async function restQuery(agent, method, path, body) {
60
- const apiKey = agent.config?.RAPIDAPI_KEY || agent.config?.OTHER_API_KEYS?.RAPIDAPI_KEY;
61
- if (!apiKey)
62
- throw new Error("RAPIDAPI_KEY required for webhook/streaming features");
109
+ await initAuth(agent);
110
+ if (_authMode !== "madeonsol" && _authMode !== "rapidapi") {
111
+ throw new Error("API key or RapidAPI key required for webhook/streaming features. Get a free key at madeonsol.com/developer");
112
+ }
63
113
  const res = await fetch(`${BASE_URL}/api/v1${path}`, {
64
114
  method,
65
115
  headers: {
66
116
  "Content-Type": "application/json",
67
- "x-rapidapi-key": apiKey,
68
- "x-rapidapi-host": "madeonsol-solana-kol-tracker-tools-api.p.rapidapi.com",
117
+ ..._authHeaders,
69
118
  },
70
119
  ...(body ? { body: JSON.stringify(body) } : {}),
71
120
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solana-agent-kit-plugin-madeonsol",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Solana Agent Kit plugin for MadeOnSol — KOL intelligence and deployer analytics via x402 micropayments",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",