Algorand智能合约示例搜索工具 search-algorand-examples

这是一个专门用于搜索Algorand区块链智能合约示例代码和开发模式的工具。它能够快速查找BoxMap、内部交易、投票合约、NFT实现等特定模式的代码示例,支持从Algorand Foundation官方代码库(如devportal-code-examples、puya-ts)中检索TypeScript和Python智能合约代码。适用于区块链开发者、智能合约工程师、Web3开发人员快速学习和参考Algorand开发最佳实践。关键词:Algorand智能合约、区块链开发、智能合约示例、BoxMap搜索、投票合约代码、NFT实现、TypeScript智能合约、Python区块链开发、Web3开发工具、Algorand代码库搜索。

智能合约 0 次安装 0 次浏览 更新于 3/4/2026

name: search-algorand-examples description: 在GitHub上搜索Algorand智能合约示例和模式。适用于查找特定模式(BoxMap、内部交易)的示例实现、查询合约功能用法、发现Algorand代码库或从algorandfoundation代码库检索文件。强触发词包括“查找…的示例”、“展示如何使用BoxMap”、“搜索投票合约示例”、“从puya-ts示例获取代码”、“查找Algorand NFT代码库”。

搜索Algorand示例

使用GitHub工具从Algorand Foundation代码库中查找可运行的合约示例和代码模式。

概述 / 核心工作流程

  1. 确定用户需要的模式或示例
  2. 选择合适的工具(github_search_codegithub_get_file_contentsgithub_search_repositories
  3. 优先搜索官方代码库(devportal-code-examples、puya-ts)
  4. 检索相关文件
  5. 同时获取对应的测试文件(如果适用)

操作步骤

  1. 确定搜索类型:

    • 查找特定模式 → 使用github_search_code
    • 需要特定文件 → 使用github_get_file_contents
    • 发现代码库 → 使用github_search_repositories
  2. 优先搜索官方代码库:

    优先级 代码库 最适合
    1 algorandfoundation/devportal-code-examples 初学者友好模式
    2 algorandfoundation/puya-ts 高级TypeScript示例
    3 algorandfoundation/puya Python示例
    4 algorandfoundation/algokit-* 模板和工具
  3. 执行搜索:

    # 搜索代码模式
    github_search_code query:"BoxMap org:algorandfoundation language:typescript"
    
    # 获取特定文件
    github_get_file_contents owner:algorandfoundation repo:puya-ts path:examples/voting/contract.algo.ts
    
    # 列出目录内容
    github_get_file_contents owner:algorandfoundation repo:puya-ts path:examples
    
    # 查找代码库
    github_search_repositories query:"topic:algorand smart-contract"
    
  4. 始终获取测试文件:

    • 对于任何合约文件,检查对应的*.spec.ts*_test.py
    • 测试文件展示如何调用方法和验证行为

重要规则 / 指南

  • 优先搜索algorandfoundation — 官方代码库包含经过验证且最新的示例
  • 始终包含测试文件 — 它们展示正确的使用模式
  • 使用具体查询 — 包含org:algorandfoundationlanguage:typescript以获得更好结果
  • 检查devportal-code-examples中的文件路径:
    • TypeScript:projects/typescript-examples/contracts/
    • Python:projects/python-examples/contracts/
  • 复杂模式优先选择puya-ts/examples — 投票、AMM、拍卖示例非常全面

如果GitHub MCP工具不可用

使用网页搜索作为备选方案:

  • 代码搜索site:github.com algorandfoundation {模式} language:typescript
  • 特定文件:直接浏览https://github.com/algorandfoundation/puya-ts/tree/main/examples
  • 代码库搜索:搜索site:github.com algorand {主题}

可直接浏览的关键URL:

常见变体 / 边缘情况

场景 方法
在algorandfoundation中未找到模式 扩展到整个GitHub搜索
需要Python而非TypeScript 搜索algorandfoundation/puya
查找部署模式 检查algokit-*-template代码库
需要ARC标准实现 在代码中搜索“ARC-{编号}”

参考 / 进一步阅读