搜索插件、代码仓与 APP 分类

walletconnect_dart 封面
插件详情v0.0.11

walletconnect_dart

一种开放协议,通过二维码扫描或深度链接将去中心化应用连接到移动钱包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
773
喜欢数
115
Pub 分数
130

安装插件

flutter pub add walletconnect_dart

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

WalletConnect Dart 是一个轻量级 SDK,可让去中心化应用通过扫描二维码或深度链接安全地连接到移动钱包。它支持跨平台集成,涵盖 Android、iOS、Web、macOS、Windows 和 Linux,实现无缝的区块链交互。基于开放的 WalletConnect 协议构建,确保 dApp 与钱包之间的通信加密,且不会暴露私钥。该包简化了 Flutter 应用中的钱包配对、会话管理和交易签名。非常适合需要安全、用户友好的钱包连接功能的开发者构建原生加密应用。

适合场景

  • 将 dApps 连接到移动钱包
  • 启用区块链交易
  • 支持多平台加密应用
  • 促进安全的钱包配对
  • 实现基于二维码的认证
  • 与以太坊及其他区块链集成

主要特点

  • 跨平台支持
  • 二维码和深度链接配对
  • 加密会话通信
  • 安全交易签名
  • 与 Flutter 的轻松集成
  • 轻量且模块化的设计

适合对象

  • Flutter 开发人员构建 dApps
  • 加密钱包集成
  • Web3 应用程序创建者
  • 区块链项目团队
  • 以移动设备为优先的加密货币平台
  • 去中心化金融(DeFi)应用

使用建议

  • 需要兼容的移动钱包
  • 需要对连接失败情况进行适当的错误处理
  • 依赖外部钱包的可用性
  • 可能需要额外的用户界面用于二维码扫描
  • 不适用于非区块链用例
  • 会话管理必须谨慎处理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

pub.dev Effective Dart Stars Issues MIT License

WalletConnect is an open source protocol for connecting decentralised applications to mobile wallets with QR code scanning or deep linking. A user can interact securely with any Dapp from their mobile phone, making WalletConnect wallets a safer choice compared to desktop or browser extension wallets.

Introduction

WalletConnect connects mobile & web applications to supported mobile wallets. The WalletConnect session is started by scanning a QR code (desktop) or by clicking an application deep link (mobile).

WalletConnect-Dart-SDK is a community SDK and port of the official WalletConnect-monorepo.

WalletConnect-Dart currently supports:

  • Algorand
  • Ethereum

You can easily add your own network by extending from WalletConnectProvider and implementing the required methods using sendCustomRequest. An example from Binance Smart Chain can be found here. For more information regarding the implementation, check out EthereumWalletConnectProvider and AlgorandWalletConnectProvider.

WalletConnect lets you build:

  • Decentralized web applications and display QR codes with qr_flutter
  • Mobile dApps with deep linking using url_launcher
  • Cross-platform wallets

Once installed, you can simply connect your application to a wallet.

// Create a connector
final connector = WalletConnect(
    bridge: 'https://bridge.walletconnect.org',
    clientMeta: PeerMeta(
      name: 'WalletConnect',
      description: 'WalletConnect Developer App',
      url: 'https://walletconnect.org',
      icons: [
        'https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
      ],
    ),
);

Usage

Dapps

Initiate connection

// Create a connector
final connector = WalletConnect(
    bridge: 'https://bridge.walletconnect.org',
    clientMeta: PeerMeta(
      name: 'WalletConnect',
      description: 'WalletConnect Developer App',
      url: 'https://walletconnect.org',
      icons: [
        'https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
      ],
    ),
);

// Subscribe to events
connector.on('connect', (session) => print(session));
connector.on('session_update', (payload) => print(payload));
connector.on('disconnect', (session) => print(session));

// Create a new session
if (!connector.connected) {
    final session = await connector.createSession(
        chainId: 4160,
        onDisplayUri: (uri) => print(uri),
    );
}

Sign transaction

final sender = Address.fromAlgorandAddress(address: session.accounts[0]);

// Fetch the suggested transaction params
final params = await algorand.getSuggestedTransactionParams();

// Build the transaction
final tx = await (PaymentTransactionBuilder()
  ..sender = sender
  ..noteText = 'Signed with WalletConnect'
  ..amount = Algo.toMicroAlgos(0.0001)
  ..receiver = sender
  ..suggestedParams = params)
    .build();

// Sign the transaction
final signedBytes = await provider.signTransaction(
    tx.toBytes(),
    params: {
    'message': 'Optional description message',
    },
);

// Broadcast the transaction
final txId = await algorand.sendRawTransactions(
    signedBytes,
    waitForConfirmation: true,
);

// Kill the session
connector.killSession();
Wallets

Initiate connection

// Create a connector
final connector = WalletConnect(
    uri: 'wc:8a5e5bdc-a0e4-47...TJRNmhWJmoxdFo6UDk2WlhaOyQ5N0U=',
    clientMeta: PeerMeta(
      name: 'WalletConnect',
      description: 'WalletConnect Developer App',
      url: 'https://walletconnect.org',
      icons: [
        'https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
      ],
    ),
);

// Subscribe to events
connector.on('connect', (session) => print(session));
connector.on('session_request', (payload) => print(payload));
connector.on('disconnect', (session) => print(session));

Manage connection

// Approve session
await connector.approveSession(chainId: 4160, accounts: ['0x4292...931B3']);

// Reject session
await connector.rejectSession(message: 'Optional error message');

// Update session
await connector.updateSession(SessionStatus(chainId: 4000, accounts: ['0x4292...931B3']));

Kill session

await connector.killSession();

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing & Pull Requests

Feel free to send pull requests.

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目