@walletconnect/react-native
@walletconnect/react-native
npm i @walletconnect/react-native
Deprecated!
Packaged deprecated in favor of @walletconnect/client. Please check docs.walletconnect.com
@walletconnect/react-native

@walletconnect/react-native

WalletConnect Monorepo

by WalletConnect

1.0.0 (see all)License:LGPL-3.0TypeScript:Built-In
npm i @walletconnect/react-native
Readme

WalletConnect React-Native Client

React Native Client for WalletConnect

For more details, read the documentation

Install

// Install NPM Package

yarn add @walletconnect/react-native

# OR

npm install --save @walletconnect/react-native

// Polyfill NodeJS modules for React-Native

npm install --save rn-nodeify

rn-nodeify --install --hack

Initiate Connection

import RNWalletConnect from "@walletconnect/react-native";

// Create WalletConnector
const connector = new RNWalletConnect(
  {
    uri: "wc:8a5e5bdc-a0e4-47...TJRNmhWJmoxdFo6UDk2WlhaOyQ5N0U=", // Required
  },
  {
    clientMeta: {
      // Required
      description: "WalletConnect Developer App",
      url: "https://walletconnect.org",
      icons: ["https://walletconnect.org/walletconnect-logo.png"],
      name: "WalletConnect",
    },
    push: {
      // Optional
      url: "https://push.walletconnect.org",
      type: "fcm",
      token: token,
      peerMeta: true,
      language: language,
    },
  },
);

// Subscribe to session requests
connector.on("session_request", (error, payload) => {
  if (error) {
    throw error;
  }

  // Handle Session Request

  /* payload:
  {
    id: 1,
    jsonrpc: '2.0'.
    method: 'session_request',
    params: [{
      peerId: '15d8b6a3-15bd-493e-9358-111e3a4e6ee4',
      peerMeta: {
        name: "WalletConnect Example",
        description: "Try out WalletConnect v1.x.x",
        icons: ["https://example.walletconnect.org/favicon.ico"],
        url: "https://example.walletconnect.org"
      }
    }]
  }
  */
});

// Subscribe to call requests
connector.on("call_request", (error, payload) => {
  if (error) {
    throw error;
  }

  // Handle Call Request

  /* payload:
  {
    id: 1,
    jsonrpc: '2.0'.
    method: 'eth_sign',
    params: [
      "0xbc28ea04101f03ea7a94c1379bc3ab32e65e62d3",
      "My email is john@doe.com - 1537836206101"
    ]
  }
  */
});

connector.on("disconnect", (error, payload) => {
  if (error) {
    throw error;
  }

  // Delete connector
});

Manage Connection

// Approve Session
connector.approveSession({
  accounts: [
    '0x4292...931B3',
    '0xa4a7...784E8',
    ...
  ],
  chainId: 1
})

// Reject Session
connector.rejectSession({
  message: 'OPTIONAL_ERROR_MESSAGE'
})


// Kill Session
connector.killSession()

Manage Call Requests

// Approve Call Request
connector.approveRequest({
  id: 1,
  result: "0x41791102999c339c844880b23950704cc43aa840f3739e365323cda4dfa89e7a",
});

// Reject Call Request
connector.rejectRequest({
  id: 1,
  error: {
    message: "OPTIONAL_ERROR_MESSAGE",
  },
});

Downloads/wk

824

GitHub Stars

929

LAST COMMIT

7mos ago

MAINTAINERS

1

CONTRIBUTORS

96

OPEN ISSUES

291

OPEN PRs

22
VersionTagPublished
1.0.0
latest
2yrs ago
1.0.0-rc.4
next
2yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate