Aptos开发者文档
  • Aptos 开发者文档
  • 开发环境准备
  • 开发者教程
    • 你的第一笔交易
    • 你的第一个 Move 模块
    • 第一个代币
    • 你的第一个 DApp
    • 第一个 NFT
  • 概念
    • 交易和状态
    • 帐户
    • 事件
    • 燃料和交易费用
    • 验证
    • 全节点
    • 验证节点
    • 节点网络和同步
    • 质押
    • 治理
  • Guides 指南
    • 交易的生命周期
    • 创建签名交易
    • 与 Aptos 区块链交互
    • 安装 Petra 扩展
    • 构建钱包扩展
    • 系统集成商指南
    • 基于本地测试网的开发流程
    • Move 教程
      • 在 Aptos 上使用 Move 语言开发
      • Move 包更新
      • Move 事务测试
  • 节点
    • 不同环境下的 Aptos 区块链部署
    • AIT-3
      • AIT-3的新功能
      • AIT-3的参与步骤
      • 节点要求
      • 节点活跃度标准
      • 链接到Aptos激励测试网
      • 激励测试网的附加文档
    • Validators
      • 在 AWS 上运行
      • 在 Azure 上运行
      • 在 GCP 上运行
      • 使用 Docker
      • 使用 Aptos-core 源代码
    • FullNode for Devnet
      • 用Aptos源或Docker来搭建全节点
      • 通过新版本来更新全节点
      • 全节点的网络身份
      • 全节点设置故障排除
      • 在 CGP 上运行全节点
    • 本地测试网
      • 用 CLI 运行本地测试网
      • 用验证器运行本地测试网
    • 节点健康检测器
    • Aptos 节点健康检查器
  • SDKs
    • Python SDK
    • Typescript
      • Typescript SDK
      • Typescript SDK 概览
    • Rust SDK
  • Aptos CLI
    • 安装 Aptos CLI
    • 使用 Aptos CLI
  • Telemetry
    • Telemetry 遥测
  • Aptos White Paper
  • Glossary 术语表
    • Glossary 词汇表
Powered by GitBook
On this page
  • 步骤 1) 在 Chrome 上安装钱包
  • 步骤 2) 钱包功能
  • 步骤 3) dApp 集成
  • 使用
  1. Guides 指南

构建钱包扩展

本教程介绍如何构建钱包扩展以及如何将其与您的 dApp 一起使用

  1. 在 Chrome 上安装钱包

  2. 钱包功能

  3. dApp 集成

步骤 1) 在 Chrome 上安装钱包

  1. 下载最新的钱包版本并解压

  2. 打开 Chrome 窗口并导航到 chrome://extensions 3.在扩展页面右上角启用开发者模式

  3. 点击 Load unpacked 并将其指向您刚刚下载的文件夹 现在您应该在 chrome 扩展程序中看到 Aptos 钱包! 提示:通过单击 Chrome 工具栏中的拼图图标打开下载的扩展程序

步骤 2) 钱包功能

钱包已经实现了与 Aptos 交互的一些基础知识

  • 创建一个新账户

  • 用测试币为您的账户注资

  • 将硬币发送到另一个地址

  • 链接到您在资源管理器上的帐户资源

  • 查看和创建 NFT

  • 选择不同的网络

步骤 3) dApp 集成

dApp 可以从他们的网站向钱包发出请求:

  • connect():提示用户允许来自 dApp 的连接(需要发出其他请求)

  • isConnected():如果 dApp 已与钱包建立连接,则返回

  • account(): 获取登录钱包的账户地址

  • signAndSubmitTransaction(transaction):签署给定的交易并提交给链

  • signTransaction(transaction):签署给定的交易并将其返回以由 dApp 提交

  • disconnect():删除 dApp 和钱包之间的连接。当用户想要删除连接时很有用。

使用

// import transaction build from aptos sdk: 
https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/typescript/sdk
 import { BCS, TxnBuilderTypes } from 'aptos';
// Establish connection to the wallet const result = await (window as any).aptos.connect()
// Check connection status of wallet const status = await (window as any).aptos.isConnected()
// Gets the address of the account signed into the wallet const accountAddress = await (window as any).aptos.account()
// Create a transaction const transaction = { arguments: [address, '717'], function: '0x1:

:transfer', type: 'entry_function_payload', type_arguments: ['0x1::aptos_coin::TestCoin'], };
// Send transaction to the extension to be signed and submitted to chain const response = await (window as any).aptos.signAndSubmitTransaction(transaction)
// Send transaction to the extension to be signed and returns const signedTransaction = await (window as any).aptos.signTransaction(transaction)
// Disconnect dApp from the wallet await (window as any).aptos.disconnect(transaction)
Previous安装 Petra 扩展Next系统集成商指南

Last updated 2 years ago