水龙头 API
水龙头用于铸造测试 APT,便于在进入主网之前进行开发。Devnet 可直接以编程方式调用,无需 Google 登录。Testnet 需要 Google 登录(铸币页面 或带 Firebase ID token 的 POST /fund)。主网没有水龙头。
金额单位为 Octa(1 APT = 100,000,000 Octa)。
| 网络 | 端点 | 如何铸造 |
|---|---|---|
| 开发网 | https://faucet.devnet.aptoslabs.com | SDK、CLI 或无需鉴权的 POST /fund |
| 测试网 | https://faucet.testnet.aptoslabs.com | 铸币页面,或使用 Google ID token 调用 POST /fund |
| 主网 | — | 不可用 |
OpenAPI(实时):Devnet 规范 和 Testnet 规范。浏览器:Devnet /spec。源码:crates/aptos-faucet/doc/spec.yaml。
当前操作为带 JSON FundRequest 请求体的 POST /fund(提供 address、auth_key 或 pub_key,以及可选的 amount)。Devnet 仍接受旧版 POST /mint?amount=&address= 查询;新集成应使用 /fund。
在钱包中使用水龙头
Section titled “在钱包中使用水龙头”大多数钱包(例如 Petra)都提供 Devnet 水龙头按钮。完整列表见 Aptos 钱包目录。
在 Aptos CLI 中使用水龙头
Section titled “在 Aptos CLI 中使用水龙头”完成 CLI 设置 后,可在 Devnet 上为账户充值:
aptos account fund-with-faucet --account 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 --amount 100000000在 Testnet 上请使用铸币页面,而不是此命令。
在 TypeScript SDK 中使用水龙头
Section titled “在 TypeScript SDK 中使用水龙头”以下示例在 Devnet 上向 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 充值 1 APT。
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const aptos = new Aptos(new AptosConfig({ network: Network.DEVNET }));await aptos.fundAccount({ accountAddress: "0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6", amount: 100_000_000,});更多客户端示例见各个 SDK。
在 Python SDK 中使用水龙头
Section titled “在 Python SDK 中使用水龙头”from aptos_sdk.v2 import Aptos, AptosConfig, Network
async with Aptos(AptosConfig(network=Network.DEVNET)) as aptos: await aptos.faucet.fund_account( "0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6", 100_000_000, )在 Go SDK 中使用水龙头
Section titled “在 Go SDK 中使用水龙头”package main
import ( "github.com/aptos-labs/aptos-go-sdk")
func main() { client, err := aptos.NewClient(aptos.DevnetConfig) if err != nil { panic("Failed to create client: " + err.Error()) }
address := aptos.AccountAddress{} err = address.ParseStringRelaxed("0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6") if err != nil { panic("Failed to parse address: " + err.Error()) }
err = client.Fund(address, 100_000_000) if err != nil { panic("Failed to fund account: " + err.Error()) }}不使用 SDK 调用水龙头
Section titled “不使用 SDK 调用水龙头”在 Devnet 上调用 POST /fund:
curl -X POST "https://faucet.devnet.aptoslabs.com/fund" \ -H "Content-Type: application/json" \ -d '{"address":"0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6","amount":100000000}'成功响应类似 {"txn_hashes":["..."]}。如果省略 amount,水龙头会使用配置的默认值(不超过最大铸造额度)。
Testnet:Google 登录
Section titled “Testnet:Google 登录”Testnet 的 POST /fund 需要人工完成 Google 登录。铸币页面 会代你完成该流程。若要直接调用 API,请发送 Firebase 项目 aptos-api-gateway-prod 的 ID token(scopes 为 openid、email、profile):
curl -X POST "https://faucet.testnet.aptoslabs.com/fund" \ -H "Authorization: Bearer FIREBASE_ID_TOKEN" \ -H "x-is-jwt: true" \ -H "Content-Type: application/json" \ -d '{"address":"0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6"}'没有智能体注册捷径。OAuth 发现文档见 /auth.md。