搜尋套件、儲存庫與 APP 分類

walletconnect_dart 封面
套件詳情v0.0.11

walletconnect_dart

一種開放協議,透過QR碼掃描或深度連結將去中心化應用連接到行動錢包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
773
喜歡數
115
Pub 分數
130

安裝套件

flutter pub add walletconnect_dart

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

WalletConnect Dart 是一個輕量級 SDK,可讓去中心化應用透過掃描 QR 碼或深度連結安全地連接到行動錢包。它支援跨平台整合,涵蓋 Android、iOS、Web、macOS、Windows 與 Linux,實現無縫的區塊鏈互動。基於開放的 WalletConnect 協定建構,確保 dApp 與錢包之間的通訊加密,且不會暴露私鑰。該套件簡化了 Flutter 應用中的錢包配對、會話管理與交易簽署。非常適合開發者建構需要安全、使用者友善錢包連接功能的加密原生應用。

適用情境

  • 將 dApps 連接到行動錢包
  • 啟用區塊鏈交易
  • 支援多平台加密應用
  • 促進安全的錢包配對
  • 實現基於二維碼的驗證
  • 與以太坊及其他區塊鏈整合

主要特色

  • 跨平台支援
  • QR碼與深度連結配對
  • 加密會話通訊
  • 安全交易簽名
  • 與 Flutter 的輕鬆整合
  • 輕量且模組化的設計

適合對象

  • Flutter 開發人員建構 dApps
  • 加密錢包整合
  • Web3 應用程式創建者
  • 區塊鏈項目團隊
  • 以行動裝置為首的加密貨幣平台
  • 去中心化金融(DeFi)應用

使用建議

  • 需要相容的行動錢包
  • 需要對連接失敗情況進行適當的錯誤處理
  • 依賴外部錢包的可用性
  • 可能需要額外的使用者介面用於QR碼掃描
  • 不適用於非區塊鏈使用案例
  • 會話管理必須謹慎處理

原始 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 項

原始碼儲存庫

使用此套件的專案