水龙头 API
水龙头允许用户在 Devnet 上获取 APT。在 Testnet 上,您只能通过铸币页面铸造代币。Mainnet 不提供水龙头。
水龙头端点如下:
每个 SDK 都集成了 Devnet 水龙头。以下提供几个示例;更多信息请参阅各个 SDK 文档。
在钱包中使用水龙头
Section titled “在钱包中使用水龙头”大多数钱包(例如 Petra)都提供 Devnet 水龙头按钮。完整列表请参阅 Aptos 钱包。
在 Aptos CLI 中使用水龙头
Section titled “在 Aptos CLI 中使用水龙头”完成 CLI 设置后,您只需调用 fund-with-faucet。金额单位为 Octa(1 APT = 100,000,000 Octa)。
aptos account fund-with-faucet --account 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 --amount 100000000在 TypeScript SDK 中使用水龙头
Section titled “在 TypeScript SDK 中使用水龙头”以下示例在 Devnet 中向账户 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 充值 1 APT。金额单位为 Octa(1 APT = 100,000,000 Octa)。
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
const aptos = new Aptos(new AptosConfig({network: Network.Devnet}));aptos.fundAccount({accountAddress: "0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6", amount: 100000000});在 Go SDK 中使用水龙头
Section titled “在 Go SDK 中使用水龙头”以下示例在 Devnet 中向账户 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 充值 1 APT。金额单位为 Octa(1 APT = 100,000,000 Octa)。
import "github.com/aptos-labs/aptos-go-sdk"
func main() { client, err := aptos.NewClient(aptos.LocalnetConfig) if err != nil { panic(err) }
client.Fund("0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6", 100000000)}调用水龙头:SDK 不支持的其他语言
Section titled “调用水龙头:SDK 不支持的其他语言”如果您尝试在其他语言中调用水龙头,有两种选择:
- 根据 OpenAPI 规范生成客户端。
- 自行调用水龙头。
对于后一种方式,请构建类似以下的查询:
curl -X POST'https://faucet.devnet.aptoslabs.com/mint?amount=10000&address=0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6'这意味着向地址 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 铸造 10000 个 Octa。