Giter VIP home page Giter VIP logo

react-native-walletconnect's Introduction

react-native-walletconnect

โš›๏ธ ๐Ÿ‘› This is an unofficial package which supports integrating WalletConnect with React Native without requiring linking. This is basically achieved using a WebView.

If your project supports using Native Modules, I strongly recommend you use the official @walletconnect/react-native library.

Compatible with Android, iOS, Web and Expo.

๐Ÿ”ฅ Features

  • Supports the complete WalletConnect Client Interface.
  • Persists connected wallets between executions.

๐Ÿš€ Getting Started

Using Yarn:

yarn add react-native-webview react-native-walletconnect

โœ๏ธ Usage

First you need to wrap the graphical root of your application with the <WalletConnectProvider />. Once this is done, you can make a call to the useWalletConnect hook to utilize the complete WalletConnect Client API within your app.

import React from "react";
import { SafeAreaView, Button } from "react-native";

import WalletConnectProvider, { useWalletConnect } from "react-native-walletconnect";

const WalletConnectExample = () => {
  const {
    createSession,
    killSession,
    session,
    signTransaction,
  } = useWalletConnect();
  const hasWallet = !!session.length;
  return (
    <>
      {!hasWallet && (
        <Button title="Connect" onPress={createSession} />
      )}
      {!!hasWallet && (
        <Button
          title="Sign Transaction"
          onPress={() => signTransaction({
            from: "0xbc28Ea04101F03aA7a94C1379bc3AB32E65e62d3",
            to: "0x89D24A7b4cCB1b6fAA2625Fe562bDd9A23260359",
            data: "0x",
            gasPrice: "0x02540be400",
            gas: "0x9c40",
            value: "0x00", 
            nonce: "0x0114",
          })}
        />
      )}
      {!!hasWallet && (
        <Button
          title="Disconnect"
          onPress={killSession}
        />
      )}
    </>
  );
};

export default function App() {
  return (
    <WalletConnectProvider>
      <WalletConnectExample />
    </WalletConnectProvider>
  );
}

useWalletConnect

The useWalletConnect hook provides the following functionality:

โœŒ๏ธ License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.