@goplausible/openclaw-algorand-plugin 0.5.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 +112 -0
- package/index.ts +361 -0
- package/lib/mcp-servers.ts +14 -0
- package/lib/x402-fetch.ts +213 -0
- package/memory/algorand-plugin.md +82 -0
- package/openclaw.plugin.json +30 -0
- package/package.json +41 -0
- package/setup.ts +80 -0
- package/skills/algorand-development/SKILL.md +90 -0
- package/skills/algorand-development/references/build-smart-contracts-reference.md +79 -0
- package/skills/algorand-development/references/build-smart-contracts.md +52 -0
- package/skills/algorand-development/references/create-project-reference.md +86 -0
- package/skills/algorand-development/references/create-project.md +89 -0
- package/skills/algorand-development/references/implement-arc-standards-arc32-arc56.md +396 -0
- package/skills/algorand-development/references/implement-arc-standards-arc4.md +265 -0
- package/skills/algorand-development/references/implement-arc-standards.md +92 -0
- package/skills/algorand-development/references/search-algorand-examples-reference.md +119 -0
- package/skills/algorand-development/references/search-algorand-examples.md +89 -0
- package/skills/algorand-development/references/troubleshoot-errors-contract.md +373 -0
- package/skills/algorand-development/references/troubleshoot-errors-transaction.md +599 -0
- package/skills/algorand-development/references/troubleshoot-errors.md +105 -0
- package/skills/algorand-development/references/use-algokit-cli-reference.md +228 -0
- package/skills/algorand-development/references/use-algokit-cli.md +64 -0
- package/skills/algorand-interaction/SKILL.md +223 -0
- package/skills/algorand-interaction/references/algorand-mcp.md +743 -0
- package/skills/algorand-interaction/references/examples-algorand-mcp.md +647 -0
- package/skills/algorand-python/SKILL.md +95 -0
- package/skills/algorand-python/references/build-smart-contracts-decorators.md +413 -0
- package/skills/algorand-python/references/build-smart-contracts-reference.md +55 -0
- package/skills/algorand-python/references/build-smart-contracts-storage.md +452 -0
- package/skills/algorand-python/references/build-smart-contracts-transactions.md +445 -0
- package/skills/algorand-python/references/build-smart-contracts-types.md +438 -0
- package/skills/algorand-python/references/build-smart-contracts.md +82 -0
- package/skills/algorand-python/references/create-project-reference.md +55 -0
- package/skills/algorand-python/references/create-project.md +75 -0
- package/skills/algorand-python/references/implement-arc-standards-arc32-arc56.md +101 -0
- package/skills/algorand-python/references/implement-arc-standards-arc4.md +154 -0
- package/skills/algorand-python/references/implement-arc-standards.md +39 -0
- package/skills/algorand-python/references/troubleshoot-errors-contract.md +355 -0
- package/skills/algorand-python/references/troubleshoot-errors-transaction.md +430 -0
- package/skills/algorand-python/references/troubleshoot-errors.md +46 -0
- package/skills/algorand-python/references/use-algokit-utils-reference.md +350 -0
- package/skills/algorand-python/references/use-algokit-utils.md +76 -0
- package/skills/algorand-typescript/SKILL.md +131 -0
- package/skills/algorand-typescript/references/algorand-ts-migration-from-beta.md +448 -0
- package/skills/algorand-typescript/references/algorand-ts-migration-from-tealscript.md +487 -0
- package/skills/algorand-typescript/references/algorand-ts-migration.md +102 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-methods-and-abi.md +134 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-reference.md +58 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-storage.md +154 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-transactions.md +187 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-types-and-values.md +150 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax.md +84 -0
- package/skills/algorand-typescript/references/build-smart-contracts-reference.md +52 -0
- package/skills/algorand-typescript/references/build-smart-contracts.md +74 -0
- package/skills/algorand-typescript/references/call-smart-contracts-reference.md +237 -0
- package/skills/algorand-typescript/references/call-smart-contracts.md +183 -0
- package/skills/algorand-typescript/references/create-project-reference.md +53 -0
- package/skills/algorand-typescript/references/create-project.md +86 -0
- package/skills/algorand-typescript/references/deploy-react-frontend-examples.md +527 -0
- package/skills/algorand-typescript/references/deploy-react-frontend-reference.md +412 -0
- package/skills/algorand-typescript/references/deploy-react-frontend.md +239 -0
- package/skills/algorand-typescript/references/implement-arc-standards-arc32-arc56.md +73 -0
- package/skills/algorand-typescript/references/implement-arc-standards-arc4.md +126 -0
- package/skills/algorand-typescript/references/implement-arc-standards.md +44 -0
- package/skills/algorand-typescript/references/test-smart-contracts-examples.md +245 -0
- package/skills/algorand-typescript/references/test-smart-contracts-unit-tests.md +147 -0
- package/skills/algorand-typescript/references/test-smart-contracts.md +127 -0
- package/skills/algorand-typescript/references/troubleshoot-errors-contract.md +296 -0
- package/skills/algorand-typescript/references/troubleshoot-errors-transaction.md +438 -0
- package/skills/algorand-typescript/references/troubleshoot-errors.md +56 -0
- package/skills/algorand-typescript/references/use-algokit-utils-reference.md +342 -0
- package/skills/algorand-typescript/references/use-algokit-utils.md +74 -0
- package/skills/algorand-x402-python/SKILL.md +113 -0
- package/skills/algorand-x402-python/references/create-python-x402-client-examples.md +469 -0
- package/skills/algorand-x402-python/references/create-python-x402-client-reference.md +313 -0
- package/skills/algorand-x402-python/references/create-python-x402-client.md +207 -0
- package/skills/algorand-x402-python/references/create-python-x402-facilitator-examples.md +924 -0
- package/skills/algorand-x402-python/references/create-python-x402-facilitator-reference.md +629 -0
- package/skills/algorand-x402-python/references/create-python-x402-facilitator.md +408 -0
- package/skills/algorand-x402-python/references/create-python-x402-server-examples.md +703 -0
- package/skills/algorand-x402-python/references/create-python-x402-server-reference.md +303 -0
- package/skills/algorand-x402-python/references/create-python-x402-server.md +221 -0
- package/skills/algorand-x402-python/references/explain-algorand-x402-python-examples.md +605 -0
- package/skills/algorand-x402-python/references/explain-algorand-x402-python-reference.md +315 -0
- package/skills/algorand-x402-python/references/explain-algorand-x402-python.md +167 -0
- package/skills/algorand-x402-python/references/use-python-x402-core-avm-examples.md +554 -0
- package/skills/algorand-x402-python/references/use-python-x402-core-avm-reference.md +278 -0
- package/skills/algorand-x402-python/references/use-python-x402-core-avm.md +166 -0
- package/skills/algorand-x402-typescript/SKILL.md +129 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-client-examples.md +879 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-client-reference.md +371 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-client.md +236 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator-examples.md +875 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator-reference.md +461 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator.md +270 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs-examples.md +1181 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs-reference.md +360 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs.md +251 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall-examples.md +870 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall-reference.md +323 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall.md +281 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-server-examples.md +1135 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-server-reference.md +382 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-server.md +216 -0
- package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript-examples.md +616 -0
- package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript-reference.md +323 -0
- package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript.md +232 -0
- package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm-examples.md +1417 -0
- package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm-reference.md +504 -0
- package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm.md +158 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402-fetch: Agent-oriented HTTP fetch with x402 payment protocol support.
|
|
3
|
+
*
|
|
4
|
+
* Two-step flow:
|
|
5
|
+
* 1. Fetch URL → if 402, returns structured PaymentRequirements + instructions
|
|
6
|
+
* 2. Agent builds payment via algorand-mcp tools, retries with paymentHeader
|
|
7
|
+
*
|
|
8
|
+
* No @x402-avm/fetch dependency — plain fetch() with manual 402 parsing.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface X402FetchParams {
|
|
12
|
+
url: string;
|
|
13
|
+
method?: string;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
body?: string;
|
|
16
|
+
paymentHeader?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface X402FetchResult {
|
|
20
|
+
status: number;
|
|
21
|
+
paymentRequired?: boolean;
|
|
22
|
+
x402Version?: number;
|
|
23
|
+
accepts?: unknown[];
|
|
24
|
+
instructions?: string;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
body?: string;
|
|
27
|
+
paymentSettled?: unknown;
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const PAYMENT_INSTRUCTIONS = `To pay for this resource, follow these steps using algorand-mcp tools:
|
|
32
|
+
|
|
33
|
+
1. Check wallet: wallet_get_info { network: "<network>" }
|
|
34
|
+
— Map CAIP-2 identifier to network:
|
|
35
|
+
"algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=" → "testnet"
|
|
36
|
+
"algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=" → "mainnet"
|
|
37
|
+
|
|
38
|
+
2. Build fee payer transaction (facilitator sponsors fees for the group):
|
|
39
|
+
make_payment_txn {
|
|
40
|
+
from: "<feePayer from accepts[].extra.feePayer>",
|
|
41
|
+
to: "<feePayer>",
|
|
42
|
+
amount: 0,
|
|
43
|
+
fee: 2000,
|
|
44
|
+
flatFee: true,
|
|
45
|
+
network: "<network>"
|
|
46
|
+
}
|
|
47
|
+
— fee: 2000 covers both transactions in the group (1000 each). flatFee: true prevents SDK override.
|
|
48
|
+
|
|
49
|
+
3. Build payment transaction (fee = 0 since facilitator covers it):
|
|
50
|
+
— For native ALGO (asset "0"):
|
|
51
|
+
make_payment_txn { from: "<your_address>", to: "<payTo>", amount: <maxAmountRequired>, fee: 0, flatFee: true, network: "<network>" }
|
|
52
|
+
— For ASA (asset is ASA ID):
|
|
53
|
+
make_asset_transfer_txn { from: "<your_address>", to: "<payTo>", assetIndex: <asset>, amount: <maxAmountRequired>, fee: 0, flatFee: true, network: "<network>" }
|
|
54
|
+
|
|
55
|
+
4. Group the transactions:
|
|
56
|
+
assign_group_id { transactions: [fee_payer_txn, payment_txn] }
|
|
57
|
+
|
|
58
|
+
5. Sign ONLY the payment transaction (index 1) with wallet:
|
|
59
|
+
wallet_sign_transaction { transaction: <grouped_payment_txn>, network: "<network>" }
|
|
60
|
+
— Leave the fee payer transaction (index 0) unsigned — the facilitator signs it.
|
|
61
|
+
|
|
62
|
+
6. Encode the unsigned fee payer transaction to base64:
|
|
63
|
+
encode_unsigned_transaction { transaction: <grouped_fee_payer_txn> }
|
|
64
|
+
— Returns base64 bytes of the unsigned transaction (canonical algosdk encoding).
|
|
65
|
+
|
|
66
|
+
7. Construct the PAYMENT-SIGNATURE payload as JSON:
|
|
67
|
+
{
|
|
68
|
+
"x402Version": 2,
|
|
69
|
+
"scheme": "exact",
|
|
70
|
+
"network": "<CAIP-2 network identifier from accepts>",
|
|
71
|
+
"payload": {
|
|
72
|
+
"paymentGroup": ["<base64 from encode_unsigned_transaction>", "<base64 from wallet_sign_transaction>"],
|
|
73
|
+
"paymentIndex": 1
|
|
74
|
+
},
|
|
75
|
+
"accepted": <the exact accepts[] entry you chose — copy it verbatim as an object, including all fields: scheme, network, price, payTo, asset, maxAmountRequired, extra, etc.>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
IMPORTANT: The "accepted" field MUST be an exact copy of the accepts[] entry you chose to pay with.
|
|
79
|
+
Without it, the server cannot match your payment to a requirement and will reject with 402.
|
|
80
|
+
|
|
81
|
+
8. Retry the request using x402_fetch with paymentHeader set to the JSON string above.
|
|
82
|
+
|
|
83
|
+
Load the algorand-interaction skill for the full x402 payment workflow reference.`;
|
|
84
|
+
|
|
85
|
+
export async function x402Fetch(params: X402FetchParams): Promise<X402FetchResult> {
|
|
86
|
+
const { url, method = "GET", headers = {}, body, paymentHeader } = params;
|
|
87
|
+
|
|
88
|
+
const requestHeaders: Record<string, string> = { ...headers };
|
|
89
|
+
|
|
90
|
+
if (paymentHeader) {
|
|
91
|
+
// x402 v2 protocol requires base64-encoded JSON in the PAYMENT-SIGNATURE header
|
|
92
|
+
const encoded = Buffer.from(paymentHeader).toString("base64");
|
|
93
|
+
requestHeaders["PAYMENT-SIGNATURE"] = encoded;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const fetchOptions: RequestInit = {
|
|
98
|
+
method,
|
|
99
|
+
headers: requestHeaders,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
if (body && (method === "POST" || method === "PUT" || method === "PATCH")) {
|
|
103
|
+
fetchOptions.body = body;
|
|
104
|
+
if (!requestHeaders["Content-Type"]) {
|
|
105
|
+
requestHeaders["Content-Type"] = "application/json";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const response = await fetch(url, fetchOptions);
|
|
110
|
+
|
|
111
|
+
// Collect response headers
|
|
112
|
+
const responseHeaders: Record<string, string> = {};
|
|
113
|
+
response.headers.forEach((value, key) => {
|
|
114
|
+
responseHeaders[key] = value;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Handle 402 Payment Required
|
|
118
|
+
if (response.status === 402) {
|
|
119
|
+
return await handle402Response(response, responseHeaders);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Handle all other responses
|
|
123
|
+
const responseBody = await response.text();
|
|
124
|
+
|
|
125
|
+
const result: X402FetchResult = {
|
|
126
|
+
status: response.status,
|
|
127
|
+
headers: responseHeaders,
|
|
128
|
+
body: responseBody,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Check for payment settlement response header
|
|
132
|
+
const paymentResponse =
|
|
133
|
+
responseHeaders["payment-response"] ||
|
|
134
|
+
responseHeaders["x-payment-response"];
|
|
135
|
+
if (paymentResponse) {
|
|
136
|
+
try {
|
|
137
|
+
result.paymentSettled = JSON.parse(paymentResponse);
|
|
138
|
+
} catch {
|
|
139
|
+
result.paymentSettled = paymentResponse;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
result.error = `HTTP ${response.status}: ${response.statusText}`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return result;
|
|
148
|
+
} catch (err) {
|
|
149
|
+
return {
|
|
150
|
+
status: 0,
|
|
151
|
+
error: `Fetch failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function handle402Response(
|
|
157
|
+
response: Response,
|
|
158
|
+
responseHeaders: Record<string, string>,
|
|
159
|
+
): Promise<X402FetchResult> {
|
|
160
|
+
let bodyText = "";
|
|
161
|
+
try {
|
|
162
|
+
bodyText = await response.text();
|
|
163
|
+
} catch {
|
|
164
|
+
// Body may not be readable
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Try to parse x402 payment requirements
|
|
168
|
+
let parsed: {
|
|
169
|
+
x402Version?: number;
|
|
170
|
+
accepts?: unknown[];
|
|
171
|
+
error?: string;
|
|
172
|
+
resource?: unknown;
|
|
173
|
+
} | null = null;
|
|
174
|
+
|
|
175
|
+
// First, check the payment-required header (base64-encoded JSON)
|
|
176
|
+
const paymentRequiredHeader = responseHeaders["payment-required"];
|
|
177
|
+
if (paymentRequiredHeader) {
|
|
178
|
+
try {
|
|
179
|
+
const decoded = Buffer.from(paymentRequiredHeader, "base64").toString("utf-8");
|
|
180
|
+
parsed = JSON.parse(decoded);
|
|
181
|
+
} catch {
|
|
182
|
+
// Header not valid base64 JSON — try body next
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Fallback: try parsing the body as JSON
|
|
187
|
+
if (!parsed) {
|
|
188
|
+
try {
|
|
189
|
+
parsed = JSON.parse(bodyText);
|
|
190
|
+
} catch {
|
|
191
|
+
// Not JSON — return raw
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (parsed && parsed.accepts && Array.isArray(parsed.accepts)) {
|
|
196
|
+
return {
|
|
197
|
+
status: 402,
|
|
198
|
+
paymentRequired: true,
|
|
199
|
+
x402Version: parsed.x402Version || 2,
|
|
200
|
+
accepts: parsed.accepts,
|
|
201
|
+
instructions: PAYMENT_INSTRUCTIONS,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Fallback: 402 but not standard x402 format
|
|
206
|
+
return {
|
|
207
|
+
status: 402,
|
|
208
|
+
paymentRequired: true,
|
|
209
|
+
error: "Received 402 but could not parse x402 payment requirements",
|
|
210
|
+
body: bodyText,
|
|
211
|
+
headers: responseHeaders,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Algorand Plugin Guide
|
|
2
|
+
|
|
3
|
+
This plugin enables three core capabilities:
|
|
4
|
+
|
|
5
|
+
1. **Algorand Development** — Smart contracts, typed clients, React frontends via AlgoKit CLI and skills
|
|
6
|
+
2. **Blockchain Interaction** — Algorand MCP server (99 tools) via mcporter
|
|
7
|
+
3. **x402 Payment Protocol** — HTTP-native payments with Algorand as first-class chain
|
|
8
|
+
|
|
9
|
+
## Skill Routing
|
|
10
|
+
|
|
11
|
+
| Capability | Task | Skill |
|
|
12
|
+
|------------|------|-------|
|
|
13
|
+
| Development | CLI, examples, general workflows | `algorand-development` |
|
|
14
|
+
| Development | TypeScript contracts & tools | `algorand-typescript` |
|
|
15
|
+
| Development | Python contracts & tools | `algorand-python` |
|
|
16
|
+
| Interaction | Blockchain interaction via MCP | `algorand-interaction` |
|
|
17
|
+
| x402 | TypeScript x402 development | `algorand-x402-typescript` |
|
|
18
|
+
| x402 | Python x402 development | `algorand-x402-python` |
|
|
19
|
+
|
|
20
|
+
## Using Algorand MCP Tools
|
|
21
|
+
|
|
22
|
+
The Algorand MCP server is configured in **mcporter** as `algorand-mcp`. Call tools like this:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# List all tools
|
|
26
|
+
mcporter list algorand-mcp
|
|
27
|
+
|
|
28
|
+
# Call a tool
|
|
29
|
+
mcporter call algorand-mcp.wallet_get_info
|
|
30
|
+
mcporter call algorand-mcp.get_account_info address=XXXXX network=testnet
|
|
31
|
+
mcporter call algorand-mcp.search_assets name=USDC network=mainnet
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Key tool categories:**
|
|
35
|
+
- `wallet_*` — Wallet operations (get_info, create, send transactions)
|
|
36
|
+
- `get_account_*` / `search_*` — Account and asset queries
|
|
37
|
+
- `algo_*` / `asa_*` — ALGO and ASA transfers
|
|
38
|
+
- `nfd_*` — NFD (.algo) name lookups
|
|
39
|
+
- `tinyman_*` — DEX swaps
|
|
40
|
+
- `get_knowledge_*` — Developer documentation
|
|
41
|
+
|
|
42
|
+
## Key things to remember
|
|
43
|
+
|
|
44
|
+
- Always check wallet with `wallet_get_info` before blockchain operations
|
|
45
|
+
- Use `get_knowledge_doc` for Algorand developer documentation
|
|
46
|
+
- Mainnet = real value — always confirm with user before mainnet transactions
|
|
47
|
+
- Default to testnet during development
|
|
48
|
+
- Every transaction costs 0.001 ALGO minimum
|
|
49
|
+
- Account needs 0.1 ALGO base + 0.1 per asset/app opt-in (MBR)
|
|
50
|
+
|
|
51
|
+
## Common Mainnet Assets
|
|
52
|
+
|
|
53
|
+
| Asset | ASA ID | Decimals |
|
|
54
|
+
|-------|--------|----------|
|
|
55
|
+
| ALGO | native (0) | 6 |
|
|
56
|
+
| USDC | 31566704 | 6 |
|
|
57
|
+
| USDT | 312769 | 6 |
|
|
58
|
+
| goETH | 386192725 | 8 |
|
|
59
|
+
| goBTC | 386195940 | 8 |
|
|
60
|
+
|
|
61
|
+
## Important patterns
|
|
62
|
+
|
|
63
|
+
- **NEVER use PyTEAL or Beaker** — these are legacy. Use Algorand TypeScript or Algorand Python.
|
|
64
|
+
- **NEVER use AlgoExplorer** — obsolete. Use Allo.info for block/account/transaction data.
|
|
65
|
+
- **NFD (.algo names)**: Always use `depositAccount` field for transactions.
|
|
66
|
+
|
|
67
|
+
## External resources
|
|
68
|
+
|
|
69
|
+
- GoPlausible: https://goplausible.com
|
|
70
|
+
- Algorand: https://algorand.co
|
|
71
|
+
- Algorand x402: https://x402.goplausible.xyz
|
|
72
|
+
- Algorand x402 test endpoints: https://example.x402.goplausible.xyz/
|
|
73
|
+
- Algorand x402 Facilitator: https://facilitator.goplausible.xyz
|
|
74
|
+
- Testnet Faucet: https://lora.algokit.io/testnet/fund
|
|
75
|
+
- Testnet USDC Faucet: https://faucet.circle.com/
|
|
76
|
+
- Algorand Developer Docs: https://dev.algorand.co/
|
|
77
|
+
- Algorand Developer Docs Github : https://github.com/algorandfoundation/devportal
|
|
78
|
+
- Algorand Developer Examples Github : https://github.com/algorandfoundation/devportal-code-examples
|
|
79
|
+
- GoPlausible x402-avm Documentation and Example code : https://github.com/GoPlausible/.github/blob/main/profile/algorand-x402-documentation/README.md
|
|
80
|
+
- GoPlausible x402-avm Examples template Projects : https://github.com/GoPlausible/x402-avm/tree/branch-v2-algorand-publish/examples/
|
|
81
|
+
- CAIP-2 Specification : https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md
|
|
82
|
+
- Coinbase x402 Protocol : https://github.com/coinbase/x402
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "openclaw-algorand-plugin",
|
|
3
|
+
"name": "Algorand Integration",
|
|
4
|
+
"description": "Algorand blockchain integration with MCP and skills — by GoPlausible",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"skills": [
|
|
7
|
+
"skills/algorand-development",
|
|
8
|
+
"skills/algorand-typescript",
|
|
9
|
+
"skills/algorand-python",
|
|
10
|
+
"skills/algorand-interaction",
|
|
11
|
+
"skills/algorand-x402-typescript",
|
|
12
|
+
"skills/algorand-x402-python"
|
|
13
|
+
],
|
|
14
|
+
"configSchema": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"properties": {
|
|
18
|
+
"enableX402": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"default": true,
|
|
21
|
+
"description": "Enable x402 micropayments skills"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"uiHints": {
|
|
26
|
+
"enableX402": {
|
|
27
|
+
"label": "Enable x402 Micropayments"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@goplausible/openclaw-algorand-plugin",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Algorand blockchain integration for OpenClaw — by GoPlausible",
|
|
8
|
+
"author": "GoPlausible <info@goplausible.com>",
|
|
9
|
+
"homepage": "https://goplausible.com",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/GoPlausible/openclaw-algorand-plugin"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"openclaw",
|
|
16
|
+
"openclaw-plugin",
|
|
17
|
+
"algorand",
|
|
18
|
+
"blockchain",
|
|
19
|
+
"mcp",
|
|
20
|
+
"x402",
|
|
21
|
+
"goplausible"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "index.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"index.ts",
|
|
28
|
+
"setup.ts",
|
|
29
|
+
"lib/",
|
|
30
|
+
"skills/",
|
|
31
|
+
"memory/",
|
|
32
|
+
"openclaw.plugin.json"
|
|
33
|
+
],
|
|
34
|
+
"openclaw": {
|
|
35
|
+
"extensions": ["./index.ts"]
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@clack/prompts": "^0.7.0",
|
|
39
|
+
"algorand-mcp": "latest"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/setup.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import { ALGORAND_MCP, GOPLAUSIBLE_SERVICES } from "./lib/mcp-servers.js";
|
|
4
|
+
|
|
5
|
+
export interface AlgorandPluginConfig {
|
|
6
|
+
enableX402: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function runSetup(
|
|
10
|
+
existingConfig?: Partial<AlgorandPluginConfig>
|
|
11
|
+
): Promise<AlgorandPluginConfig | null> {
|
|
12
|
+
p.intro("🔷 Algorand Plugin Setup — powered by GoPlausible");
|
|
13
|
+
|
|
14
|
+
// Step 1: Verify algorand-mcp binary is available
|
|
15
|
+
let mcpAvailable = false;
|
|
16
|
+
let mcpPath = "";
|
|
17
|
+
try {
|
|
18
|
+
mcpPath = execSync("which algorand-mcp", { encoding: "utf-8" }).trim();
|
|
19
|
+
mcpAvailable = true;
|
|
20
|
+
} catch {
|
|
21
|
+
// Binary not found in PATH
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (mcpAvailable) {
|
|
25
|
+
p.note(
|
|
26
|
+
`MCP Server: ${ALGORAND_MCP.name}\n` +
|
|
27
|
+
`Type: ${ALGORAND_MCP.type} (local)\n` +
|
|
28
|
+
`Command: ${ALGORAND_MCP.command}\n` +
|
|
29
|
+
`Path: ${mcpPath}\n` +
|
|
30
|
+
`Status: ✅ Available`,
|
|
31
|
+
"Algorand MCP"
|
|
32
|
+
);
|
|
33
|
+
} else {
|
|
34
|
+
p.log.warn(
|
|
35
|
+
`algorand-mcp binary not found in PATH.\n\n` +
|
|
36
|
+
`Options:\n` +
|
|
37
|
+
` • Run with npx: npx algorand-mcp\n` +
|
|
38
|
+
` • Install globally: npm install -g algorand-mcp\n` +
|
|
39
|
+
` • Add node_modules/.bin to PATH`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Step 2: x402 integration
|
|
44
|
+
const enableX402 = await p.confirm({
|
|
45
|
+
message: "Enable x402 micropayments integration?",
|
|
46
|
+
initialValue: existingConfig?.enableX402 ?? true,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (p.isCancel(enableX402)) {
|
|
50
|
+
p.cancel("Setup cancelled.");
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Summary
|
|
55
|
+
const config: AlgorandPluginConfig = {
|
|
56
|
+
enableX402: enableX402 as boolean,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
p.note(
|
|
60
|
+
`x402 Micropayments: ${config.enableX402 ? "Enabled" : "Disabled"}\n\n` +
|
|
61
|
+
`MCP Server Setup:\n` +
|
|
62
|
+
` The Algorand MCP server (${ALGORAND_MCP.command}) provides 99 blockchain tools.\n` +
|
|
63
|
+
` Configure it in your coding agent's MCP config:\n` +
|
|
64
|
+
` • Claude Code: .mcp.json\n` +
|
|
65
|
+
` • Cursor: .cursor/mcp.json\n` +
|
|
66
|
+
` • OpenCode: opencode.json`,
|
|
67
|
+
"Configuration"
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
p.outro(
|
|
71
|
+
`🔷 Algorand plugin configured!\n\n` +
|
|
72
|
+
` Next steps:\n` +
|
|
73
|
+
` 1. Run \`openclaw algorand-plugin init\` to add plugin memory\n` +
|
|
74
|
+
` 2. Configure algorand-mcp in your coding agent's MCP config\n` +
|
|
75
|
+
` 3. Restart OpenClaw gateway\n\n` +
|
|
76
|
+
` Docs: ${GOPLAUSIBLE_SERVICES.website}`
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return config;
|
|
80
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: algorand-development
|
|
3
|
+
description: Comprehensive guide for Algorand development with AlgoKit — project initialization, CLI commands, example search, contract building workflows, ARC standards, and error troubleshooting. This is the parent skill for language-agnostic Algorand development. Use when working with AlgoKit CLI, searching for examples, understanding ARC standards, creating new projects, or troubleshooting errors. Strong triggers include "algokit init", "algokit project run build", "start localnet", "find an example", "search for contract", "ARC-4", "ARC-56", "logic eval error", "transaction rejected", "overspend", "create a new project", "initialize project".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Algorand Development
|
|
7
|
+
|
|
8
|
+
This is the aggregated parent skill for language-agnostic Algorand development tools, workflows, and standards. Use the reference files below to find detailed guidance for each topic.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Install AlgoKit CLI
|
|
14
|
+
pipx install algokit
|
|
15
|
+
|
|
16
|
+
# Create a new project
|
|
17
|
+
algokit init -n my-project -t typescript --answer preset_name production --defaults
|
|
18
|
+
|
|
19
|
+
# Development cycle
|
|
20
|
+
algokit project run build # Compile contracts
|
|
21
|
+
algokit project run test # Run tests
|
|
22
|
+
algokit localnet start # Start local network
|
|
23
|
+
algokit project deploy localnet # Deploy
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Reference Guide
|
|
27
|
+
|
|
28
|
+
Navigate to the appropriate reference based on your task.
|
|
29
|
+
|
|
30
|
+
### AlgoKit CLI Commands
|
|
31
|
+
|
|
32
|
+
Build, test, deploy, and manage local networks with AlgoKit CLI.
|
|
33
|
+
|
|
34
|
+
- [use-algokit-cli.md](./references/use-algokit-cli.md) — CLI workflow and common commands
|
|
35
|
+
- [use-algokit-cli-reference.md](./references/use-algokit-cli-reference.md) — Full CLI command reference
|
|
36
|
+
|
|
37
|
+
### Searching Algorand Examples
|
|
38
|
+
|
|
39
|
+
Find working contract examples and code patterns from Algorand Foundation repositories using WebFetch with raw GitHub URLs.
|
|
40
|
+
|
|
41
|
+
- [search-algorand-examples.md](./references/search-algorand-examples.md) — Search workflow and priority repos
|
|
42
|
+
- [search-algorand-examples-reference.md](./references/search-algorand-examples-reference.md) — WebFetch patterns and knowledge base reference
|
|
43
|
+
|
|
44
|
+
### Creating Projects
|
|
45
|
+
|
|
46
|
+
Initialize new Algorand projects using AlgoKit templates.
|
|
47
|
+
|
|
48
|
+
- [create-project.md](./references/create-project.md) — Project creation workflow
|
|
49
|
+
- [create-project-reference.md](./references/create-project-reference.md) — Templates, presets, and CLI options
|
|
50
|
+
|
|
51
|
+
### Building Smart Contracts
|
|
52
|
+
|
|
53
|
+
General workflow for building Algorand smart contracts (language-agnostic steps).
|
|
54
|
+
|
|
55
|
+
- [build-smart-contracts.md](./references/build-smart-contracts.md) — Contract building workflow
|
|
56
|
+
- [build-smart-contracts-reference.md](./references/build-smart-contracts-reference.md) — Repository priorities and pattern lookups
|
|
57
|
+
|
|
58
|
+
### Implementing ARC Standards
|
|
59
|
+
|
|
60
|
+
ARC-4 ABI encoding, ARC-32/ARC-56 application specifications, and related standards.
|
|
61
|
+
|
|
62
|
+
- [implement-arc-standards.md](./references/implement-arc-standards.md) — ARC overview and key standards
|
|
63
|
+
- [implement-arc-standards-arc4.md](./references/implement-arc-standards-arc4.md) — ARC-4 ABI types, encoding, and method invocation
|
|
64
|
+
- [implement-arc-standards-arc32-arc56.md](./references/implement-arc-standards-arc32-arc56.md) — Application specification format and usage
|
|
65
|
+
|
|
66
|
+
### Troubleshooting Errors
|
|
67
|
+
|
|
68
|
+
Diagnose and fix common Algorand development errors.
|
|
69
|
+
|
|
70
|
+
- [troubleshoot-errors.md](./references/troubleshoot-errors.md) — Error diagnosis overview
|
|
71
|
+
- [troubleshoot-errors-contract.md](./references/troubleshoot-errors-contract.md) — Smart contract and logic errors
|
|
72
|
+
- [troubleshoot-errors-transaction.md](./references/troubleshoot-errors-transaction.md) — Transaction and account errors
|
|
73
|
+
|
|
74
|
+
## Topic Quick Reference
|
|
75
|
+
|
|
76
|
+
| Topic | Files | Description |
|
|
77
|
+
| ----- | ----- | ----------- |
|
|
78
|
+
| AlgoKit CLI | 2 | Build, test, deploy commands and localnet management |
|
|
79
|
+
| Search Examples | 2 | WebFetch patterns for finding Algorand code examples |
|
|
80
|
+
| Create Project | 2 | algokit init templates, presets, and options |
|
|
81
|
+
| Build Contracts | 2 | Language-agnostic contract building workflow |
|
|
82
|
+
| ARC Standards | 3 | ARC-4 ABI, ARC-32/56 app specs |
|
|
83
|
+
| Troubleshoot | 3 | Error diagnosis for contracts and transactions |
|
|
84
|
+
|
|
85
|
+
## How to Use This Skill
|
|
86
|
+
|
|
87
|
+
1. **Start here** to understand which reference you need
|
|
88
|
+
2. **Read the topic `.md`** file for step-by-step guidance
|
|
89
|
+
3. **Consult the `-reference.md`** file for detailed API/CLI details
|
|
90
|
+
4. **For language-specific content**, see the `algorand-typescript` or `algorand-python` parent skills
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Algorand Smart Contract Development Workflow Reference
|
|
2
|
+
|
|
3
|
+
Follow this exact order when building smart contracts in either Algorand TypeScript or Algorand Python.
|
|
4
|
+
|
|
5
|
+
## Step 1: Search Documentation
|
|
6
|
+
|
|
7
|
+
Use `search_algorand_knowledge_sources` for conceptual guidance, best practices, and official documentation.
|
|
8
|
+
|
|
9
|
+
If no results: proceed with caution, explain limitations, use known patterns.
|
|
10
|
+
|
|
11
|
+
## Step 2: Retrieve Canonical Examples
|
|
12
|
+
|
|
13
|
+
Use GitHub tools to get code from these repositories in priority order:
|
|
14
|
+
|
|
15
|
+
### Priority 1: DevPortal Code Examples
|
|
16
|
+
`algorandfoundation/devportal-code-examples`
|
|
17
|
+
- TypeScript: `projects/typescript-examples/contracts/`
|
|
18
|
+
- Python: `projects/python-examples/contracts/`
|
|
19
|
+
- Always include corresponding test files
|
|
20
|
+
|
|
21
|
+
### Priority 2: Puya Compiler Examples
|
|
22
|
+
- TypeScript: `algorandfoundation/puya-ts` -> `examples/`
|
|
23
|
+
- Python: `algorandfoundation/puya` -> `examples/`
|
|
24
|
+
- Examples: hello_world_arc4, voting, amm
|
|
25
|
+
|
|
26
|
+
### Priority 3: AlgoKit Templates
|
|
27
|
+
- TypeScript: `algorandfoundation/algokit-typescript-template`
|
|
28
|
+
- Python: `algorandfoundation/algokit-python-template`
|
|
29
|
+
|
|
30
|
+
### Priority 4: AlgoKit Utilities
|
|
31
|
+
- `algorandfoundation/algokit-cli`
|
|
32
|
+
- `algorandfoundation/algokit-client-generator-ts`
|
|
33
|
+
- `algorandfoundation/algokit-utils-ts`
|
|
34
|
+
|
|
35
|
+
## Step 3: Pattern-Specific Lookups
|
|
36
|
+
|
|
37
|
+
For specific patterns, search these locations:
|
|
38
|
+
|
|
39
|
+
### Box Storage
|
|
40
|
+
- TypeScript: `devportal-code-examples/projects/typescript-examples/contracts/BoxStorage/`
|
|
41
|
+
- Python: `puya/examples/voting/` or `puya/examples/amm/` (BoxMap patterns)
|
|
42
|
+
|
|
43
|
+
### Common Patterns
|
|
44
|
+
State management, ABI methods, inner transactions: Start in `contracts/` subdirectories of Priority 1 repos.
|
|
45
|
+
|
|
46
|
+
| Scenario | TypeScript Path | Python Path |
|
|
47
|
+
|----------|----------------|-------------|
|
|
48
|
+
| Box storage | `typescript-examples/contracts/BoxStorage/` | `puya/examples/voting/`, `puya/examples/amm/` |
|
|
49
|
+
| Inner transactions | `puya-ts/examples/` (search for itxn) | `puya/examples/` (search for itxn) |
|
|
50
|
+
| ARC-4 methods | `puya-ts/examples/hello_world_arc4/` | `puya/examples/hello_world_arc4/` |
|
|
51
|
+
| State management | GlobalState, LocalState in examples | GlobalState, LocalState in examples |
|
|
52
|
+
|
|
53
|
+
## Step 4: Generate Code
|
|
54
|
+
|
|
55
|
+
- Carefully adapt canonical examples
|
|
56
|
+
- Preserve all safety checks and efficient patterns
|
|
57
|
+
- For TypeScript: follow rules from the `algorand-typescript` skill
|
|
58
|
+
- For Python: follow rules from the `algorand-python` skill
|
|
59
|
+
|
|
60
|
+
## Step 5: Include Tests
|
|
61
|
+
|
|
62
|
+
- Always include or suggest integration tests
|
|
63
|
+
- Use generated clients for testing contracts
|
|
64
|
+
- Only include unit tests if explicitly requested by user
|
|
65
|
+
|
|
66
|
+
## Step 6: Build and Test
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
algokit project run build # Compile contracts
|
|
70
|
+
algokit project run test # Run tests
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Iterate on fixes if compilation errors or test failures occur.
|
|
74
|
+
|
|
75
|
+
### Key Points
|
|
76
|
+
|
|
77
|
+
- **Use CLI for deployment**: `algokit project deploy localnet` handles large app specs
|
|
78
|
+
- **Use `methodSignature` for calls**: Simpler than passing full app spec
|
|
79
|
+
- **Get App ID from deployment output**: Required for all MCP calls
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Building Smart Contracts
|
|
2
|
+
|
|
3
|
+
Create modern Algorand smart contracts in Algorand TypeScript (PuyaTs) or Algorand Python (PuyaPy) -- statically-typed subsets compiled to TEAL bytecode by the Puya compiler.
|
|
4
|
+
|
|
5
|
+
## Core Workflow
|
|
6
|
+
|
|
7
|
+
1. **Search documentation** for concepts and best practices
|
|
8
|
+
2. **Retrieve canonical examples** from priority repositories
|
|
9
|
+
3. **Generate code** adapting examples to requirements
|
|
10
|
+
4. **Include integration tests** using generated clients
|
|
11
|
+
5. **Build and test** with AlgoKit commands
|
|
12
|
+
|
|
13
|
+
## How to Proceed
|
|
14
|
+
|
|
15
|
+
1. **Search documentation first:**
|
|
16
|
+
- Use `get_knowledge_doc` or `list_knowledge_docs` from the Algorand MCP server (Remote Full or Local) for conceptual guidance
|
|
17
|
+
- Categories: `arcs`, `sdks`, `algokit`, `algokit-utils`, `tealscript`, `puya`, `developers`, `clis`, `nodes`
|
|
18
|
+
- If MCP unavailable, use web search: `site:dev.algorand.co {concept}`
|
|
19
|
+
|
|
20
|
+
2. **Retrieve canonical examples:**
|
|
21
|
+
- Use WebFetch with raw GitHub URLs from priority repositories:
|
|
22
|
+
- Priority 1: `https://raw.githubusercontent.com/algorandfoundation/devportal-code-examples/main/`
|
|
23
|
+
- Priority 2: `https://raw.githubusercontent.com/algorandfoundation/puya-ts/main/examples/` (TypeScript) or `https://raw.githubusercontent.com/algorandfoundation/puya/main/examples/` (Python)
|
|
24
|
+
- Priority 3: `https://raw.githubusercontent.com/algorandfoundation/algokit-typescript-template/main/` or `https://raw.githubusercontent.com/algorandfoundation/algokit-python-template/main/`
|
|
25
|
+
- Always include corresponding test files
|
|
26
|
+
|
|
27
|
+
3. **Generate code:**
|
|
28
|
+
- Choose TypeScript or Python based on user preference
|
|
29
|
+
- Adapt examples carefully, preserving safety checks
|
|
30
|
+
- Follow syntax rules from the language-specific skill (`algorand-typescript` or `algorand-python`)
|
|
31
|
+
|
|
32
|
+
4. **Include tests:**
|
|
33
|
+
- Always include or suggest integration tests
|
|
34
|
+
- Use generated clients for testing contracts
|
|
35
|
+
|
|
36
|
+
5. **Build and test:**
|
|
37
|
+
```bash
|
|
38
|
+
algokit project run build # Compile contracts
|
|
39
|
+
algokit project run test # Run tests
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Important Rules
|
|
43
|
+
|
|
44
|
+
- **NEVER use PyTEAL or Beaker** -- these are legacy, superseded by Puya
|
|
45
|
+
- **NEVER write raw TEAL** -- always use Algorand TypeScript or Algorand Python
|
|
46
|
+
- **NEVER import external libraries** into contract code
|
|
47
|
+
- **Always search docs first** before writing code
|
|
48
|
+
- **Always retrieve examples** from priority repositories
|
|
49
|
+
|
|
50
|
+
## References
|
|
51
|
+
|
|
52
|
+
- [Detailed Workflow](./build-smart-contracts-reference.md)
|