build-smart-contracts
Build Algorand smart contracts using Algorand TypeScript (PuyaTs) or Algorand Python (PuyaPy). Use when creating new smart contracts from scratch, adding features or methods to existing contracts, understanding Algorand contract development patterns, or getting guidance on contract architecture. Strong triggers include "create a smart contract", "write a contract that...", "build a voting contract", "implement an NFT contract", "add a method to the contract".
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Building Smart Contracts
Create modern Algorand smart contracts in Algorand TypeScript or Algorand Python—statically-typed subsets compiled to TEAL bytecode by the Puya compiler.
Overview / Core Workflow
- Search Algorand documentation for concepts and best practices
- Retrieve canonical examples from priority repositories
- Generate code adapting examples to requirements
- Include integration tests using generated clients
- Build and test with AlgoKit commands
How to proceed
-
Search documentation first:
- Use
kappa_search_algorand_knowledge_sourcesMCP tool for conceptual guidance - If MCP unavailable, use web search: "site:dev.algorand.co {concept}"
- If no results, proceed with caution using known patterns
- Use
-
Retrieve canonical examples:
- Priority 1:
algorandfoundation/devportal-code-examples - Priority 2:
algorandfoundation/puya-ts(examples/) - Priority 3:
algorandfoundation/algokit-typescript-template - Always include corresponding test files
- Priority 1:
-
Generate code:
- Default to TypeScript unless user explicitly requests Python
- Adapt examples carefully, preserving safety checks
- Follow syntax rules from
algorand-typescriptskill
-
Include tests:
- Always include or suggest integration tests
- Use generated clients for testing contracts
- See
test-smart-contractsskill for patterns
-
Build and test:
algokit project run build # Compile contracts algokit project run test # Run tests
Important Rules / Guidelines
- NEVER use PyTEAL or Beaker — these are legacy, superseded by Puya
- NEVER write raw TEAL — always use Algorand TypeScript/Python
- NEVER import external libraries into contract code
- Default to TypeScript unless user explicitly requests Python
- Always search docs first before writing code
- Always retrieve examples from priority repositories
Common Variations / Edge Cases
| Scenario | Approach |
|---|---|
| Box storage patterns | Check devportal-code-examples/contracts/BoxStorage/ |
| Inner transactions | Search for "itxn" patterns in puya-ts examples |
| ARC-4 methods | See puya-ts/examples/hello_world_arc4/ |
| State management | Check GlobalState, LocalState patterns in examples |
| Python contracts | Use algorandfoundation/puya instead of puya-ts |
| Python syntax help | Consult references/python/ subfolder for Python-specific patterns |
References / Further Reading
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!