use-algokit-utils
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAlgoKit Utils
AlgoKit Utils
Use AlgoKit Utils to interact with the Algorand blockchain from TypeScript or Python applications.
使用 AlgoKit Utils 在 TypeScript 或 Python 应用中与 Algorand 区块链进行交互。
Overview / Core Workflow
概述 / 核心工作流
- Create an instance
AlgorandClient - Get or create accounts for signing
- Send transactions using methods
algorand.send.* - Or compose groups using
algorand.newGroup()
- 创建 实例
AlgorandClient - 获取或创建用于签名的账户
- 使用 方法发送交易
algorand.send.* - 或使用 组合交易组
algorand.newGroup()
How to proceed
操作步骤
-
Initialize AlgorandClient:TypeScript:typescript
import { AlgorandClient } from '@algorandfoundation/algokit-utils' const algorand = AlgorandClient.fromEnvironment() // Or: AlgorandClient.defaultLocalNet() // Or: AlgorandClient.testNet() // Or: AlgorandClient.mainNet()Python:pythonfrom algokit_utils import AlgorandClient algorand = AlgorandClient.from_environment() # Or: AlgorandClient.default_localnet() # Or: AlgorandClient.testnet() # Or: AlgorandClient.mainnet() -
Get accounts:TypeScript:typescript
const account = await algorand.account.fromEnvironment('DEPLOYER')Python:pythonaccount = algorand.account.from_environment("DEPLOYER") -
Send transactions:TypeScript:typescript
await algorand.send.payment({ sender: account.addr, receiver: 'RECEIVERADDRESS', amount: algo(1), })Python:pythonalgorand.send.payment(PaymentParams( sender=account.address, receiver="RECEIVERADDRESS", amount=AlgoAmount(algo=1), ))
-
初始化 AlgorandClient:TypeScript:typescript
import { AlgorandClient } from '@algorandfoundation/algokit-utils' const algorand = AlgorandClient.fromEnvironment() // Or: AlgorandClient.defaultLocalNet() // Or: AlgorandClient.testNet() // Or: AlgorandClient.mainNet()Python:pythonfrom algokit_utils import AlgorandClient algorand = AlgorandClient.from_environment() # Or: AlgorandClient.default_localnet() # Or: AlgorandClient.testnet() # Or: AlgorandClient.mainnet() -
获取账户:TypeScript:typescript
const account = await algorand.account.fromEnvironment('DEPLOYER')Python:pythonaccount = algorand.account.from_environment("DEPLOYER") -
发送交易:TypeScript:typescript
await algorand.send.payment({ sender: account.addr, receiver: 'RECEIVERADDRESS', amount: algo(1), })Python:pythonalgorand.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 to get accounts; signers are auto-registered
algorand.account - Use algo() helper — For TypeScript, use instead of raw microAlgos
algo(1)
- 使用 AlgorandClient — 这是主要入口点;避免使用已弃用的基于函数的 API
- 优先使用 fromEnvironment() — 通过环境变量可在本地和生产环境中使用
- 注册签名者 — 使用 获取账户;签名者会自动注册
algorand.account - 使用 algo() 辅助函数 — 在 TypeScript 中,使用 替代原生 microAlgos 数值
algo(1)
Common Variations / Edge Cases
常见变体 / 边缘场景
| Scenario | Approach |
|---|---|
| LocalNet development | |
| TestNet/MainNet | |
| Custom node | |
| Deploy contract | Use typed app client factory (see app-client docs) |
| Transaction groups | |
| 场景 | 处理方式 |
|---|---|
| LocalNet 开发 | |
| TestNet/MainNet 开发 | |
| 自定义节点 | |
| 部署合约 | 使用类型化应用客户端工厂(查看 app-client 文档) |
| 交易组 | |
References / Further Reading
参考资料 / 扩展阅读
Language-specific references are organized in subfolders:
- TypeScript (): AlgorandClient
references/typescript/ - Python (): AlgorandClient
references/python/
External documentation:
特定语言的参考资料按子文件夹分类:
- TypeScript():AlgorandClient
references/typescript/ - Python():AlgorandClient
references/python/
外部文档: