Wallet Connect client in Dart.

Overview
Wallet Connect Logo

Wallet Connect

Wallet Connect client in dart highly inspired from wallet-connect-kotlin by Trust Wallet.

Usage

    import 'package:wallet_connect/wallet_connect.dart';
  1. Create instance of Wallet connect client and define callbacks.
    final wcClient = WCClient(
      onConnect: () {
        // Respond to connect callback
      },
      onDisconnect: (code, reason) {
        // Respond to disconnect callback
      },
      onFailure: (error) {
        // Respond to connection failure callback
      },
      onSessionRequest: (id, peerMeta) {
        // Respond to connection request callback
      },
      onEthSign: (id, message) {
        // Respond to personal_sign or eth_sign or eth_signTypedData request callback
      },
      onEthSendTransaction: (id, tx) {
        // Respond to eth_sendTransaction request callback
      },
      onEthSignTransaction: (id, tx) {
        // Respond to eth_signTransaction request callback
      },
    );
  1. Create WCSession object from wc: uri.
    final session = WCSession.from(wcUri);
  1. Create WCPeerMeta object containing metadata for your app.
    final peerMeta = WCPeerMeta(
        name: 'Example Wallet',
        url: 'https://example.wallet',
        description: 'Example Wallet',
        icons: [],
    );
  1. Connect to a new session.
    wcClient.connectNewSession(session: session, peerMeta: peerMeta);
  1. Or connect to a saved session (from step 8).
    wcClient.connectFromSessionStore(sessionStore);
  1. Approve a session connection request.
    wcClient.approveSession(
        accounts: [], // account addresses
        chainId: 1, // chain id
    );
  1. Or reject a session connection request.
    wcClient.rejectSession();
  1. Get active session from sessionStore getter to save for later use.
    final sessionStore = wcClient.sessionStore;
  1. Approve a sign transaction request by signing the transaction and sending the signed hex data.
    wcClient.approveRequest<String>(
        id: id,
        result: signedDataAsHex,
    );
  1. Approve a send transaction request by sending the transaction hash generated from sending the transaction.
    wcClient.approveRequest<String>(
        id: id,
        result: transactionHash,
    );
  1. Approve a sign request by sending the signed data hex generated.
    wcClient.approveRequest<String>(
        id: id,
        result: signedDataAsHex,
    );
  1. Or reject any of the requests above by specifying request id.
    wcClient.rejectRequest(id: id);
  1. Disconnect from a connected session locally.
    wcClient.disconnect();
  1. Permanently close a connected session.
    wcClient.killSession();
Comments
  • feat: Add `wallet_switchEthereumChain` and custom http client support

    feat: Add `wallet_switchEthereumChain` and custom http client support

    for example, while we using https://app.uniswap.org, switch chain from the top right dropdown menu.

    Wallet app should handle onWalletSwithEtherumChain, and update session or reject the request in the handler.

    opened by naiba 2
  • Android Support/Docs

    Android Support/Docs

    I've been trying the example and connecting to Metamask app on my phone, I am unsure if this is web-only, or does it support android too, because it doesn't show a list of apps when I open it on my android phone, do I need to make some additional configurations ? I was unsure as there is not any documentation around it, within the codebase too. It'd be great if I can get some help figuring this out.

    opened by Sameerkash 2
  • Gas should be nullable

    Gas should be nullable

    Hi @thelazyindian, Awesome implementation for flutter Thanks for that! I received an error while trying to execute a certain transaction that hasn't contained gas, here’s the data I received: { "jsonrpc": "2.0", "method": "eth_sendTransaction", "params": [ { "from": "0x862bd4208b2f6ed64ce92aada2669d3c5cc705d9", "to": "0xcdd8964ba8963929867caffcf5942de4f085bfb7", "gasPrice": "0x3b9aca00", "data": "0x095ea7b3000000000000000000000000076bdea1fd4695bdef9ba4579463bc4b3c97d64500000000000000000000000000000000000000000000000013ae155e0b074c84" } ] }

    I've added the nullable option for the gas property.

    opened by LiorAgnin 2
  • Sign message error

    Sign message error

    step1: open the opensea.io, and connect walletconnect

    step2: open profile -> collected, and open the own collect.

    step3: click the sell button, to sell my collect.

    step4: set the price, click "Complete listing" button, then click "unlock" button

    step5: click "sign" button in walletconnect.

    then error: There was an error with your transaction. Please try again.

    WX20211005-115439@2x
    opened by Fury76 2
  • fix: to address would be null when you deploy a smart contract

    fix: to address would be null when you deploy a smart contract

    When us connect on the Ethereum remix using wallet connect and try to deploy using wallet connect package a exception is triggered because TO address is null.

    Then, to address was changed to nullable

    opened by asgartth 1
  • Sending a transaction requires manually switch to Metamask to confirm

    Sending a transaction requires manually switch to Metamask to confirm

    Environment

    I'm trying to develop a mobile app in Flutter which should interact with a very simple contract. The contract contains a basic string which can be read or write.

    My environment is the following:

    • Ganache running on localhost, with the contract deployed at a know address.
    • A physical Android device with adb-reverse to reach the Ganache network.
    • On the Android I've Metamask app installed with the Ganache network set and one of the Ganache account.

    I'm using the following dependencies:

      web3dart: ^2.3.0
      walletconnect_dart: ^0.0.11
      url_launcher: ^6.1.5
    

    I use the Web3Dart code generator to generate the class to interact with my contract.

    Expected behaviour

    The app has a login button, which redirect the user to Metamask for the login, and it initialise the session. After that it displays a screen with a text containing the value of the contract variable, a textField and a button. Tapping on the button should execute a transaction that updates the value on the contract with the textField content.

    Problem

    After looking around on Github for examples I was able to assemble the code and make it work. The EthClient, the Connector and the Contract are initialised correctly. At login button tap the user is switched to Metamask and a popup ask to connect to the mobile app. After that the user can interact with the TextField and submit the new value.

    I copied the WalletConnectEthereumCredentials from the example folder and here's my version:

    class WalletConnectEthereumCredentials extends CustomTransactionSender {
      WalletConnectEthereumCredentials(
          {required this.provider});
    
      final EthereumWalletConnectProvider provider;
    
      @override
      Future<EthereumAddress> extractAddress() => Future(
          () => EthereumAddress.fromHex(provider.connector.session.accounts.first));
    
      @override
      Future<String> sendTransaction(Transaction transaction) async {
        final from = await this.extractAddress();
        final hash = await provider.sendTransaction(
          from: from.hex,
          to: transaction.to?.hex,
          data: transaction.data,
          gas: transaction.maxGas,
          gasPrice: transaction.gasPrice?.getInWei,
          value: transaction.value?.getInWei,
          nonce: transaction.nonce,
        );
    
        return hash;
      }
    
      @override
      Future<MsgSignature> signToSignature(Uint8List payload,
          {int? chainId, bool isEIP1559 = false}) {
        // TODO: implement signToSignature
        throw UnimplementedError();
      }
    }
    

    When the user tap on the button, a transaction is sent. Now if the user want to proceed he has to open manually Metamask and confirm the transaction through a popoup.

    Is there a way to avoid having to move in Metamask and confirm every simple transaction every time, then switch back in the app?

    I was able to automatically open Metamask every time a transaction is sent, with this code inside the sendTransaction:

     launchUrlString(metamaskUri, mode: LaunchMode.externalApplication);
    

    But still a confirmation for every transaction is needed.

    Thanks

    opened by GangemiLorenzo 1
  • Update Session never updates.

    Update Session never updates.

    Future<void> updateSession({ List<String>? accounts, int? chainId, bool approved = true, }) async { final param = WCSessionUpdate( approved: approved, chainId: _chainId ?? chainId, accounts: accounts, ); final request = JsonRpcRequest( id: DateTime.now().millisecondsSinceEpoch, method: WCMethod.SESSION_UPDATE, params: [param.toJson()], ); return _encryptAndSend(jsonEncode(request.toJson())); }

    In this block chainId is never updated. It always uses current _chainId.

    to Update Session we need to call approveSession method first then call updateSession method

    opened by erginersoy 1
  • Not Working  for Android

    Not Working for Android

    I tried with sample app in android but it is not working. Not connect or not showing up other things like application selection. Is there any way to use it in android app.

    opened by Flaming19 1
  • personal sign error

    personal sign error

    step 1: open url: https://opensea.io/asset/create connect walletconnect with qr code

    step2: sign message

    then error: Authentication error: Relay request for authLoginMutation failed by the following reasons: 1. [401] Not authorized. login(address: $address, identity: $identity, message: $ ^^^ WX20211004-210911@2x

    opened by Fury76 1
  • fix: to address would be null when you deploy a smart contract

    fix: to address would be null when you deploy a smart contract

    When us connect on the Ethereum remix using wallet connect and try to deploy using wallet connect package a exception is triggered because TO address is null.

    Then, to address was changed to nullable

    opened by asgartth 0
  • Unable to connect wallet in android release mode

    Unable to connect wallet in android release mode

    I tried to connect MetaMask wallet in debug mode and is working fine. But when we create release build it stops working. It still able to open MetaMask, but after unlock the MetaMask account it won't prompt the dialog for connect wallet.

    opened by McDreamy 0
  • have a Wallet Connect v2 upgrade schedule?

    have a Wallet Connect v2 upgrade schedule?

    Wallet Connect v1 is will end of support. ( 2022. 12. 16 ) Do you have any plan support Wallet Connect v2? [(https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e)

    opened by kangjuhyup 0
  • ERC20 tokens

    ERC20 tokens

    Hello. I see only eth example, but how can I check and handle erc20 token transaction? Cause if this is a token transfer that it should be other handling in web3. Can you show an example with tokens?

    opened by sylvestrevgenhiveon 0
  • Unhandled Exception: HandshakeException: Hmac from payload and calculated hmac doesn't match.

    Unhandled Exception: HandshakeException: Hmac from payload and calculated hmac doesn't match.

    After connecting to opensea with walletconnect, I connect to uniswap. When I want to operate on opensea again, I get a HandshakeException error, how can I follow. I only get a request from the last dapp I connected to.

    opened by emrbli 0
Web3 Ethereum, Etherjs and Wallet Connect wrapper for Flutter Web.

flutter_web3 This is a fork of flutter_web3_provider. Be sure to check out the original package. Introduction flutter_web3 v2 is full Dart class and f

yoisha 105 Jan 2, 2023
Blaise Wallet - A wallet for the Pascal cryptocurrency, made with Flutter

Blaise - Simple, Sleek & Secure PASCAL Wallet [ What is Blaise? Blaise is a cross-platform mobile wallet for the PASCAL cryptocurrency. It is written

Appditto 209 Dec 4, 2022
Microsoft Teams Clone is a Video conference application with a rich integrated chat experience, to connect with friends,family & colleagues. Developed as a redesign of Microsoft Teams during my menteeship at Microsoft Engage 2021

Microsoft Teams Clone by Karanjot Singh About Microsoft Teams Clone is a Video conference application with a rich integrated chat experience, to conne

Karanjot Singh 60 Dec 28, 2022
Plaso Connect is an application which acts as a one-stop solution where the people requiring blood plasma/oxygen can directly find and contact the donors and healthcare units as per their requirements

PLASO CONNECT - The Lifeline A one-stop platform for COVID relief resources -- Connecting patients with Plasma donors and oxygen suppliers. Built for

Niloy Sikdar 11 Oct 28, 2022
a software to connect you and your friends and others, are you guys also just tensed over the overuse of social media so we have a solution, appx (name not decided yet)

appx a software to connect you and your friends and others, are you guys also just tensed over the overuse of social media so we have a solution, appx

null 8 Jun 9, 2022
Connect over 300 participants on meetings with the open source meeting service Confab Meetings

Confab Meetings is an open-source, free, and cross-platform service that is intended to make people secure on the internet ecosystem. Confab excels to

Shivam Yadav 1 Oct 20, 2021
Tesla Connect build in Flutter

Tesla Connect Its build-in Flutter Screen Door lock. Battery. Temperature. Tyre Status. In App Download You can download the latest installable versio

Hoang Son 4 Nov 26, 2021
A Wonderful app to connect us with famous dishes across the world.

Recipe App A Wonderful app to connect us with famous dishes across the world. About APP It is a simple flutter app with dummy data ,it show recipes of

null 2 Jan 24, 2022
An app to help students and teachers connect each other.

korek An app to help students and teachers connect each other. Technologies: Project is created with: React.JS (Typescript) Express (Typescript) Flutt

Bruno Dzięcielski 3 Jan 10, 2022
a software to connect you and your friends and others, are you guys also just tensed over the overuse of social media so we have a solution, sociio

APPX A software that will allow you to connect with your friends and family ! Are you guys also tensed over the over-use of social media ?? We have a

null 8 Jun 9, 2022
Showwcase is a professional network built for developers to connect, build community, and find new opportunities.

Showwcase Generated by the Very Good CLI ?? Showwcase is a professional network built for developers to connect, build community, and find new opportu

Luis Ciber 4 Jan 13, 2022
P2P payment solution using Stream's Flutter SDK and Rapyd's Wallet API

Peer-to-peer payment integration to a messaging app using Flutter ?? This project shows how to integrate a peer-to-peer payment solution to your Strea

Souvik Biswas 15 Dec 8, 2022
Mobile Wallet for Solana

Solana Mobile Wallet A mobile wallet for Solana made in flutter Features: Watch over any address Import wallets with it's seedphrase (devnet only for

Marc Espín 68 Jan 3, 2023
A mobile wallet for Spacemesh.io

sm_mobile_wallet A new Flutter project. Getting Started FlutterFlow projects are built to run on the Flutter stable release. IMPORTANT: For projects w

Andrei Voinea 2 Dec 26, 2022
A Tezos Wallet built with Flutter

Anthos A Tezos Wallet built using Flutter at Hackout 2021 Problem it solves Easy way to send and receive Tezos XTZ Built with Flutter - Runs on web, m

Sameer Kashyap 4 Aug 4, 2022
Online wallet app for money transfer and bill payment.

shapshapcoins Payment Platform Getting Started This project is a starting point for a Flutter application. A few

Ndoye Philip Ndula 1 Nov 14, 2021
Wallet app ui

wallify A wallet app ui. Exploring modals Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Chiemela Uzoma 10 Nov 22, 2021
Zcash and Ycash light shielded wallet

ZWallet The fastest, most advanced, shielded wallet for Zcash Main Features Warp Sync: PROCESSES ~10 000 BLOCKS PER SECOND (1) Transparent and Shielde

null 21 Dec 19, 2022
Natrium - Fast, Robust & Secure NANO Wallet, now written with Flutter.

Natrium - Fast, Robust & Secure NANO Wallet What is Natrium? Natrium is a cross-platform mobile wallet for the NANO cryptocurrency. It is written in D

Appditto 702 Dec 30, 2022