@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,86 @@
|
|
|
1
|
+
# AlgoKit Init CLI Reference
|
|
2
|
+
|
|
3
|
+
## Templates
|
|
4
|
+
|
|
5
|
+
| Template | Language | Use Case |
|
|
6
|
+
| ------------ | ---------- | --------------------------------------------- |
|
|
7
|
+
| `typescript` | TypeScript | Smart contracts (Algorand TypeScript/PuyaTs) |
|
|
8
|
+
| `python` | Python | Smart contracts (Algorand Python/PuyaPy) |
|
|
9
|
+
| `tealscript` | TypeScript | Smart contracts (TealScript - alternative) |
|
|
10
|
+
| `react` | TypeScript | Frontend dApp with wallet integration |
|
|
11
|
+
| `fullstack` | Both | Smart contracts + React frontend combined |
|
|
12
|
+
| `base` | N/A | Minimal workspace template |
|
|
13
|
+
|
|
14
|
+
**Default for smart contracts:** `typescript`
|
|
15
|
+
|
|
16
|
+
## Presets
|
|
17
|
+
|
|
18
|
+
### TypeScript
|
|
19
|
+
|
|
20
|
+
| Preset | Description |
|
|
21
|
+
| ------------ | ---------------------------- |
|
|
22
|
+
| `Starter` | Simple starting point |
|
|
23
|
+
| `Production` | Tests, CI/CD, linting, audit |
|
|
24
|
+
|
|
25
|
+
### Python
|
|
26
|
+
|
|
27
|
+
| Preset | Description |
|
|
28
|
+
| ------------ | ------------------------------------ |
|
|
29
|
+
| `Starter` | Simple starting point |
|
|
30
|
+
| `Production` | Tests, CI/CD, linting, type checking |
|
|
31
|
+
|
|
32
|
+
## Command Patterns
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# TypeScript (Production preset)
|
|
36
|
+
algokit init -n <name> -t typescript --answer preset_name production --answer author_name "<author>" --defaults
|
|
37
|
+
|
|
38
|
+
# TypeScript (Starter preset)
|
|
39
|
+
algokit init -n <name> -t typescript --answer author_name "<author>" --defaults
|
|
40
|
+
|
|
41
|
+
# Python (Production preset)
|
|
42
|
+
algokit init -n <name> -t python --answer preset_name production --answer author_name "<author>" --defaults
|
|
43
|
+
|
|
44
|
+
# Python (Starter preset)
|
|
45
|
+
algokit init -n <name> -t python --answer author_name "<author>" --defaults
|
|
46
|
+
|
|
47
|
+
# Skip git and bootstrap
|
|
48
|
+
algokit init -n <name> -t <template> --no-git --no-bootstrap --defaults
|
|
49
|
+
|
|
50
|
+
# Python with TypeScript deployment
|
|
51
|
+
algokit init -n <name> -t python --answer deployment_language "typescript" --defaults
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Options
|
|
55
|
+
|
|
56
|
+
| Flag | Description |
|
|
57
|
+
| ---------------------------- | ------------------------------------------------ |
|
|
58
|
+
| `-n, --name <name>` | Project directory name (required) |
|
|
59
|
+
| `-t, --template <name>` | Template name (see Templates table above) |
|
|
60
|
+
| `--answer "<key>" "<value>"` | Answer template prompts |
|
|
61
|
+
| `--defaults` | Accept all defaults |
|
|
62
|
+
| `--no-git` | Skip git initialization |
|
|
63
|
+
| `--no-bootstrap` | Skip dependency installation |
|
|
64
|
+
| `--workspace` | Create within workspace structure (default) |
|
|
65
|
+
| `--no-workspace` | Create standalone project |
|
|
66
|
+
| `--ide` / `--no-ide` | Open IDE after creation (default: auto-detect) |
|
|
67
|
+
|
|
68
|
+
## Initialize from Examples
|
|
69
|
+
|
|
70
|
+
AlgoKit can also initialize projects from pre-built examples:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Interactive example selector
|
|
74
|
+
algokit init example
|
|
75
|
+
|
|
76
|
+
# List available examples
|
|
77
|
+
algokit init example --list
|
|
78
|
+
|
|
79
|
+
# Initialize specific example
|
|
80
|
+
algokit init example <example_id>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Full Reference
|
|
84
|
+
|
|
85
|
+
- [AlgoKit Init Command](https://dev.algorand.co/reference/algokit-cli/#init)
|
|
86
|
+
- [AlgoKit Templates](https://dev.algorand.co/algokit/official-algokit-templates/)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# AlgoKit Project Initialization
|
|
2
|
+
|
|
3
|
+
Create new Algorand projects using AlgoKit's official templates.
|
|
4
|
+
|
|
5
|
+
## Overview / Core Workflow
|
|
6
|
+
|
|
7
|
+
1. Confirm project details with user (name, template, customizations)
|
|
8
|
+
2. Run `algokit init` with appropriate flags
|
|
9
|
+
3. Handle any initialization errors
|
|
10
|
+
4. Provide next steps for building/testing
|
|
11
|
+
|
|
12
|
+
## How to Proceed
|
|
13
|
+
|
|
14
|
+
1. **Confirm project details with user:**
|
|
15
|
+
- Project name (directory name)
|
|
16
|
+
- Template choice (TypeScript or Python)
|
|
17
|
+
- Any customizations (`--no-git`, `--no-bootstrap`, author name)
|
|
18
|
+
- Preset selection (Production or Starter)
|
|
19
|
+
|
|
20
|
+
2. **Run initialization command:**
|
|
21
|
+
|
|
22
|
+
**TypeScript (Production Preset):**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
algokit init -n <project-name> -t typescript --answer preset_name production --answer author_name "<name>" --defaults
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**TypeScript (Starter Preset):**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
algokit init -n <project-name> -t typescript --answer author_name "<name>" --defaults
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Python (Production Preset):**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
algokit init -n <project-name> -t python --answer preset_name production --answer author_name "<name>" --defaults
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Python (Starter Preset):**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
algokit init -n <project-name> -t python --answer author_name "<name>" --defaults
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**With custom options (no git, no bootstrap):**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
algokit init -n <project-name> -t <template> --no-git --no-bootstrap --defaults
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
3. **Handle errors:**
|
|
53
|
+
- **Existing directory** -- Check and warn if the project directory already exists before running init
|
|
54
|
+
- **AlgoKit not installed** -- Verify AlgoKit is installed with `algokit --version`
|
|
55
|
+
- **Invalid template** -- Valid templates: `typescript`, `python`, `tealscript`, `react`, `fullstack`, `base`
|
|
56
|
+
- **Permissions** -- Ensure target directory is writable
|
|
57
|
+
|
|
58
|
+
4. **Provide next steps:**
|
|
59
|
+
- `cd <project-name>`
|
|
60
|
+
- `algokit project run build` -- Compile contracts
|
|
61
|
+
- `algokit project run test` -- Run test suite
|
|
62
|
+
- `algokit localnet start` -- Start local network (if deploying)
|
|
63
|
+
- `algokit project run deploy` -- Deploy contracts to local network
|
|
64
|
+
|
|
65
|
+
## Important Rules / Guidelines
|
|
66
|
+
|
|
67
|
+
- **Always confirm with user before executing** -- Never run `algokit init` without explicit confirmation
|
|
68
|
+
- **Use production preset** -- For any serious project because it includes testing framework and deployment scripts
|
|
69
|
+
- **Include author name** -- Pass `--answer author_name "<name>"` for attribution
|
|
70
|
+
- **Use `--defaults`** -- Accepts all other default values for non-interactive mode
|
|
71
|
+
|
|
72
|
+
## Common Variations / Edge Cases
|
|
73
|
+
|
|
74
|
+
| Scenario | Approach |
|
|
75
|
+
|----------|----------|
|
|
76
|
+
| Existing directory | Check and warn if directory already exists |
|
|
77
|
+
| No Git initialization | Use `--no-git` flag |
|
|
78
|
+
| No dependency installation | Use `--no-bootstrap` flag |
|
|
79
|
+
| Custom author name | `--answer author_name "Your Name"` |
|
|
80
|
+
| Fullstack (frontend + contracts) | Use `-t fullstack` template |
|
|
81
|
+
| React frontend only | Use `-t react` template |
|
|
82
|
+
| Standalone (no workspace) | Use `--no-workspace` flag |
|
|
83
|
+
| Initialize from example | Use `algokit init example` subcommand |
|
|
84
|
+
|
|
85
|
+
## References / Further Reading
|
|
86
|
+
|
|
87
|
+
- [CLI Reference](./create-project-reference.md)
|
|
88
|
+
- [AlgoKit CLI Init Documentation](https://dev.algorand.co/algokit/cli/init/)
|
|
89
|
+
- [AlgoKit CLI Init Reference](https://dev.algorand.co/reference/algokit-cli#init)
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
# ARC-32 and ARC-56: Application Specifications
|
|
2
|
+
|
|
3
|
+
Application specifications describe a smart contract's interface, state schema, and metadata. They enable typed client generation, IDE support, and enhanced developer experience.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [ARC-32 vs ARC-56 Comparison](#arc-32-vs-arc-56-comparison)
|
|
8
|
+
- [Generating App Specs](#generating-app-specs)
|
|
9
|
+
- [ARC-56 Contract Structure](#arc-56-contract-structure)
|
|
10
|
+
- [Method Descriptions](#method-descriptions)
|
|
11
|
+
- [ARC-56 Method Format](#arc-56-method-format)
|
|
12
|
+
- [Action Configuration](#action-configuration)
|
|
13
|
+
- [Default Argument Values](#default-argument-values)
|
|
14
|
+
- [Named Structs](#named-structs)
|
|
15
|
+
- [State Schema](#state-schema)
|
|
16
|
+
- [Events (ARC-28)](#events-arc-28)
|
|
17
|
+
- [Source Information](#source-information-optional)
|
|
18
|
+
- [Template Variables](#template-variables)
|
|
19
|
+
- [Common Mistakes](#common-mistakes)
|
|
20
|
+
|
|
21
|
+
## ARC-32 vs ARC-56 Comparison
|
|
22
|
+
|
|
23
|
+
| Feature | ARC-32 | ARC-56 |
|
|
24
|
+
|---------|--------|--------|
|
|
25
|
+
| **Status** | Deprecated | Current Standard |
|
|
26
|
+
| **ARC-4 methods** | Yes | Yes |
|
|
27
|
+
| **State schema** | Yes | Yes |
|
|
28
|
+
| **Method hints** | Partial | Full |
|
|
29
|
+
| **Named structs** | No | Yes |
|
|
30
|
+
| **Default argument values** | Limited | Full support |
|
|
31
|
+
| **Source code info** | No | Yes (optional) |
|
|
32
|
+
| **Source maps** | No | Yes (optional) |
|
|
33
|
+
| **ARC-28 events** | No | Yes |
|
|
34
|
+
| **Bare action config** | Yes | Yes |
|
|
35
|
+
| **Template variables** | No | Yes |
|
|
36
|
+
| **Scratch variables** | No | Yes |
|
|
37
|
+
|
|
38
|
+
**Recommendation:** Use ARC-56 for all new projects. ARC-32 is maintained for legacy compatibility only.
|
|
39
|
+
|
|
40
|
+
## Generating App Specs
|
|
41
|
+
|
|
42
|
+
### From Algorand Python
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Compile contract - generates both .arc32.json and .arc56.json
|
|
46
|
+
puyapy contracts/my_contract.py
|
|
47
|
+
|
|
48
|
+
# Or via AlgoKit
|
|
49
|
+
algokit project run build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### From Algorand TypeScript
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Compile contract
|
|
56
|
+
npx puya-ts contracts/my_contract.ts
|
|
57
|
+
|
|
58
|
+
# Or via AlgoKit
|
|
59
|
+
algokit project run build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Output files:
|
|
63
|
+
- `MyContract.arc32.json` - Legacy app spec
|
|
64
|
+
- `MyContract.arc56.json` - Modern app spec
|
|
65
|
+
|
|
66
|
+
## ARC-56 Contract Structure
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"arcs": [4, 22, 28, 56],
|
|
71
|
+
"name": "Calculator",
|
|
72
|
+
"desc": "A simple calculator contract",
|
|
73
|
+
"networks": {
|
|
74
|
+
"mainnet-v1.0": { "appID": 12345 },
|
|
75
|
+
"testnet-v1.0": { "appID": 67890 }
|
|
76
|
+
},
|
|
77
|
+
"structs": {
|
|
78
|
+
"UserInfo": [
|
|
79
|
+
{ "name": "name", "type": "string" },
|
|
80
|
+
{ "name": "balance", "type": "uint64" }
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"methods": [...],
|
|
84
|
+
"state": {
|
|
85
|
+
"schema": {
|
|
86
|
+
"global": { "ints": 2, "bytes": 1 },
|
|
87
|
+
"local": { "ints": 1, "bytes": 0 }
|
|
88
|
+
},
|
|
89
|
+
"keys": {
|
|
90
|
+
"global": {
|
|
91
|
+
"counter": {
|
|
92
|
+
"key": "Y291bnRlcg==",
|
|
93
|
+
"keyType": "AVMString",
|
|
94
|
+
"valueType": "uint64"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"local": {},
|
|
98
|
+
"box": {}
|
|
99
|
+
},
|
|
100
|
+
"maps": {
|
|
101
|
+
"global": {},
|
|
102
|
+
"local": {},
|
|
103
|
+
"box": {
|
|
104
|
+
"users": {
|
|
105
|
+
"keyType": "address",
|
|
106
|
+
"valueType": "UserInfo",
|
|
107
|
+
"prefix": "dXNlcl8="
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"bareActions": {
|
|
113
|
+
"create": ["NoOp"],
|
|
114
|
+
"call": ["NoOp", "OptIn"]
|
|
115
|
+
},
|
|
116
|
+
"events": [...]
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Method Descriptions
|
|
121
|
+
|
|
122
|
+
### ARC-56 Method Format
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"name": "transfer",
|
|
127
|
+
"desc": "Transfer tokens to another account",
|
|
128
|
+
"args": [
|
|
129
|
+
{
|
|
130
|
+
"name": "receiver",
|
|
131
|
+
"type": "address",
|
|
132
|
+
"desc": "The account to receive tokens"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "amount",
|
|
136
|
+
"type": "uint64",
|
|
137
|
+
"desc": "The amount to transfer"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"returns": {
|
|
141
|
+
"type": "bool",
|
|
142
|
+
"desc": "True if transfer succeeded"
|
|
143
|
+
},
|
|
144
|
+
"actions": {
|
|
145
|
+
"create": [],
|
|
146
|
+
"call": ["NoOp"]
|
|
147
|
+
},
|
|
148
|
+
"readonly": false,
|
|
149
|
+
"events": [
|
|
150
|
+
{ "name": "Transfer", "args": [...] }
|
|
151
|
+
],
|
|
152
|
+
"recommendations": {
|
|
153
|
+
"innerTransactionCount": 1,
|
|
154
|
+
"accounts": [],
|
|
155
|
+
"apps": [],
|
|
156
|
+
"assets": [],
|
|
157
|
+
"boxes": []
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Action Configuration
|
|
163
|
+
|
|
164
|
+
The `actions` field specifies when a method can be called:
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"actions": {
|
|
169
|
+
"create": ["NoOp", "OptIn"],
|
|
170
|
+
"call": ["NoOp", "OptIn", "CloseOut", "UpdateApplication", "DeleteApplication"]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- **create**: OnComplete actions allowed when creating the app (appID === 0)
|
|
176
|
+
- **call**: OnComplete actions allowed when calling existing app (appID !== 0)
|
|
177
|
+
|
|
178
|
+
### Default Argument Values
|
|
179
|
+
|
|
180
|
+
ARC-56 supports specifying default values for method arguments:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"name": "fee",
|
|
185
|
+
"type": "uint64",
|
|
186
|
+
"defaultValue": {
|
|
187
|
+
"source": "literal",
|
|
188
|
+
"data": "AAAAAAAAAGQ=",
|
|
189
|
+
"type": "uint64"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Sources for default values:
|
|
195
|
+
- `literal`: Base64-encoded value
|
|
196
|
+
- `global`: Read from global state key
|
|
197
|
+
- `local`: Read from sender's local state
|
|
198
|
+
- `box`: Read from box storage
|
|
199
|
+
- `method`: Call a readonly method to get the value
|
|
200
|
+
|
|
201
|
+
## Named Structs
|
|
202
|
+
|
|
203
|
+
ARC-56 supports named structs that map to ABI tuples:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"structs": {
|
|
208
|
+
"UserInfo": [
|
|
209
|
+
{ "name": "name", "type": "string" },
|
|
210
|
+
{ "name": "balance", "type": "uint64" },
|
|
211
|
+
{ "name": "active", "type": "bool" }
|
|
212
|
+
],
|
|
213
|
+
"TransferRequest": [
|
|
214
|
+
{ "name": "from", "type": "address" },
|
|
215
|
+
{ "name": "to", "type": "address" },
|
|
216
|
+
{ "name": "info", "type": "UserInfo" }
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
In methods, reference structs by name:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"args": [
|
|
227
|
+
{ "name": "user", "type": "(string,uint64,bool)", "struct": "UserInfo" }
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## State Schema
|
|
233
|
+
|
|
234
|
+
### Schema Definition
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"state": {
|
|
239
|
+
"schema": {
|
|
240
|
+
"global": { "ints": 5, "bytes": 3 },
|
|
241
|
+
"local": { "ints": 2, "bytes": 1 }
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
These values are used when creating the application.
|
|
248
|
+
|
|
249
|
+
### Storage Keys
|
|
250
|
+
|
|
251
|
+
Named storage keys with type information:
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"keys": {
|
|
256
|
+
"global": {
|
|
257
|
+
"total_supply": {
|
|
258
|
+
"key": "dG90YWxfc3VwcGx5",
|
|
259
|
+
"keyType": "AVMString",
|
|
260
|
+
"valueType": "uint64",
|
|
261
|
+
"desc": "Total token supply"
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"local": {
|
|
265
|
+
"balance": {
|
|
266
|
+
"key": "YmFsYW5jZQ==",
|
|
267
|
+
"keyType": "AVMString",
|
|
268
|
+
"valueType": "uint64"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
"box": {
|
|
272
|
+
"metadata": {
|
|
273
|
+
"key": "bWV0YQ==",
|
|
274
|
+
"keyType": "AVMString",
|
|
275
|
+
"valueType": "(string,uint64)"
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Storage Maps
|
|
283
|
+
|
|
284
|
+
For dynamic key storage (like BoxMap):
|
|
285
|
+
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"maps": {
|
|
289
|
+
"box": {
|
|
290
|
+
"users": {
|
|
291
|
+
"keyType": "address",
|
|
292
|
+
"valueType": "UserInfo",
|
|
293
|
+
"prefix": "dXNlcl8="
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Events (ARC-28)
|
|
301
|
+
|
|
302
|
+
```json
|
|
303
|
+
{
|
|
304
|
+
"events": [
|
|
305
|
+
{
|
|
306
|
+
"name": "Transfer",
|
|
307
|
+
"desc": "Emitted when tokens are transferred",
|
|
308
|
+
"args": [
|
|
309
|
+
{ "name": "from", "type": "address" },
|
|
310
|
+
{ "name": "to", "type": "address" },
|
|
311
|
+
{ "name": "amount", "type": "uint64" }
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Events are emitted using `arc4.emit()`:
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
from algopy import arc4
|
|
322
|
+
|
|
323
|
+
class Transfer(arc4.Struct):
|
|
324
|
+
from_addr: arc4.Address
|
|
325
|
+
to_addr: arc4.Address
|
|
326
|
+
amount: arc4.UInt64
|
|
327
|
+
|
|
328
|
+
# In contract method
|
|
329
|
+
arc4.emit(Transfer(
|
|
330
|
+
from_addr=arc4.Address(sender),
|
|
331
|
+
to_addr=arc4.Address(receiver),
|
|
332
|
+
amount=arc4.UInt64(amount),
|
|
333
|
+
))
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Source Information (Optional)
|
|
337
|
+
|
|
338
|
+
ARC-56 can include source maps for debugging:
|
|
339
|
+
|
|
340
|
+
```json
|
|
341
|
+
{
|
|
342
|
+
"sourceInfo": {
|
|
343
|
+
"approval": {
|
|
344
|
+
"sourceInfo": [
|
|
345
|
+
{
|
|
346
|
+
"pc": [10, 11, 12],
|
|
347
|
+
"errorMessage": "Assertion failed: balance >= amount"
|
|
348
|
+
}
|
|
349
|
+
],
|
|
350
|
+
"pcOffsetMethod": "cblocks"
|
|
351
|
+
},
|
|
352
|
+
"clear": {
|
|
353
|
+
"sourceInfo": []
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
"source": {
|
|
357
|
+
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCg...",
|
|
358
|
+
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCg..."
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Template Variables
|
|
364
|
+
|
|
365
|
+
For contracts with configurable values:
|
|
366
|
+
|
|
367
|
+
```json
|
|
368
|
+
{
|
|
369
|
+
"templateVariables": {
|
|
370
|
+
"ADMIN_ADDRESS": {
|
|
371
|
+
"type": "address",
|
|
372
|
+
"value": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ"
|
|
373
|
+
},
|
|
374
|
+
"MAX_SUPPLY": {
|
|
375
|
+
"type": "uint64"
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Common Mistakes
|
|
382
|
+
|
|
383
|
+
| Mistake | Problem | Fix |
|
|
384
|
+
|---------|---------|-----|
|
|
385
|
+
| Using ARC-32 for new projects | Missing features | Use ARC-56 instead |
|
|
386
|
+
| Missing schema in deployment | App creation fails | Include schema from app spec |
|
|
387
|
+
| Wrong action configuration | Method call rejected | Verify `actions` field |
|
|
388
|
+
| Struct name mismatch | Client type errors | Ensure struct names match |
|
|
389
|
+
| Not regenerating client | Stale types | Regenerate after contract changes |
|
|
390
|
+
|
|
391
|
+
## References
|
|
392
|
+
|
|
393
|
+
- [ARC-32 Specification](https://dev.algorand.co/arc-standards/arc-0032/)
|
|
394
|
+
- [ARC-56 Specification](https://dev.algorand.co/arc-standards/arc-0056/)
|
|
395
|
+
- [AlgoKit Utils TypeScript](https://dev.algorand.co/algokit/utils/typescript/overview/)
|
|
396
|
+
- [AlgoKit Utils Python](https://dev.algorand.co/algokit/utils/python/overview/)
|