AgentSkillsCN

use-algokit-utils

AlgoKit Utils 库可用于从 TypeScript 或 Python 应用程序与 Algorand 区块链进行交互。当需要连接到 Algorand 网络(LocalNet、TestNet、MainNet)、发送支付或转移资产、创建并管理账户、从客户端代码部署或交互智能合约,或组合交易组时,可使用此技能。本技能不适用于编写智能合约代码(请使用“构建智能合约”技能)。强烈触发条件包括:“我该如何连接到 Algorand?”、“发送一笔支付交易”、“创建一个账户”、“部署我的合约”、“获取一个 AlgorandClient”、“AlgorandClient.fromEnvironment”。

SKILL.md
--- frontmatter
name: use-algokit-utils
description: AlgoKit Utils library for interacting with the Algorand blockchain from TypeScript or Python applications. Use when connecting to Algorand networks (LocalNet, TestNet, MainNet), sending payments or transferring assets, creating and managing accounts, deploying or interacting with smart contracts from client code, or composing transaction groups. NOT for writing smart contract code (use build-smart-contracts skill). Strong triggers include "How do I connect to Algorand?", "send a payment transaction", "create an account", "deploy my contract", "get an AlgorandClient", "AlgorandClient.fromEnvironment".

AlgoKit Utils

Use AlgoKit Utils to interact with the Algorand blockchain from TypeScript or Python applications.

Overview / Core Workflow

  1. Create an AlgorandClient instance
  2. Get or create accounts for signing
  3. Send transactions using algorand.send.* methods
  4. Or compose groups using algorand.newGroup()

How to proceed

  1. Initialize AlgorandClient:

    TypeScript:

    typescript
    import { AlgorandClient } from '@algorandfoundation/algokit-utils'
    
    const algorand = AlgorandClient.fromEnvironment()
    // Or: AlgorandClient.defaultLocalNet()
    // Or: AlgorandClient.testNet()
    // Or: AlgorandClient.mainNet()
    

    Python:

    python
    from algokit_utils import AlgorandClient
    
    algorand = AlgorandClient.from_environment()
    # Or: AlgorandClient.default_localnet()
    # Or: AlgorandClient.testnet()
    # Or: AlgorandClient.mainnet()
    
  2. Get accounts:

    TypeScript:

    typescript
    const account = await algorand.account.fromEnvironment('DEPLOYER')
    

    Python:

    python
    account = algorand.account.from_environment("DEPLOYER")
    
  3. Send transactions:

    TypeScript:

    typescript
    await algorand.send.payment({
      sender: account.addr,
      receiver: 'RECEIVERADDRESS',
      amount: algo(1),
    })
    

    Python:

    python
    algorand.send.payment(PaymentParams(
      sender=account.address,
      receiver="RECEIVERADDRESS",
      amount=AlgoAmount(algo=1),
    ))
    

Important Rules / Guidelines

  • Use AlgorandClient — It's the main entry point; avoid deprecated function-based APIs
  • Default to fromEnvironment() — Works locally and in production via env vars
  • Register signers — Use algorand.account to get accounts; signers are auto-registered
  • Use algo() helper — For TypeScript, use algo(1) instead of raw microAlgos

Common Variations / Edge Cases

ScenarioApproach
LocalNet developmentAlgorandClient.defaultLocalNet()
TestNet/MainNetAlgorandClient.testNet() or .mainNet()
Custom nodeAlgorandClient.fromConfig({ algodConfig: {...} })
Deploy contractUse typed app client factory (see app-client docs)
Transaction groupsalgorand.newGroup().addPayment(...).addAssetOptIn(...).send()

References / Further Reading

Language-specific references are organized in subfolders:

External documentation: