Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

This package has been deprecated

Author message:

Package deprecated in favor of @walletconnect/react-native

rn-walletconnect-wallet

0.7.28 • Public • Published

React-Native WalletConnect Wallet

Library to connect React-Native mobile wallets to desktop Dapps using WalletConnect

You can read more about WalletConnect standard here: http://walletconnect.org/

Setup

  1. Install NPM Package
yarn add rn-walletconnect-wallet
 
# OR 
 
npm install --save rn-walletconnect-wallet
  1. Nodify 'crypto' package for cryptography
# install "crypto" shims and run package-specific hacks 
rn-nodeify --install "crypto" --hack

Getting Started

import RNWalletConnect from 'rn-walletconnect-wallet'
 
/**
 *  Create WalletConnector
 */
const walletConnector = new RNWalletConnect({
  uri: 'ethereum:wc-8a5e5bdc-a0e4-47...TJRNmhWJmoxdFo6UDk2WlhaOyQ5N0U=',
  push: {
    type: 'fcm',
    token: 'cSgGd8BWURk:APA91bGXsLd_...YdFbutyfc8pScl0Qe8-',
    webhook: 'https://push.walletconnect.org/notification/new',
  }
})
 
 
/**
 *  Approve Session
 */
await walletConnector.approveSession({
  accounts: [
    '0x4292...931B3',
    '0xa4a7...784E8',
    ...
  ]
})
 
/**
 *  Reject Session
 */
await walletConnector.rejectSession()
 
 
/**
 *  Kill Session
 */
await walletConnector.killSession()
 
/**
 *  Handle push notification events & get call data
 */
FCM.on(FCMEvent.Notification, event => {
  const { sessionId, callId } = event;
 
  const callData = await walletConnector.getCallRequest(callId);
 
  // example callData
  {
    method: 'eth_sendTransaction',
    data: {
      from: '0xbc28ea04101f03ea7a94c1379bc3ab32e65e62d3',
      to: '0x0',
      nonce: 1,
      gas: 100000,
      value: 0,
      data: '0x0'
    }
  }
});
 
/**
 *  Get all calls from bridge
 */
const allCalls = await walletConnector.getAllCallRequests();
 
/**
 *  Approve and share call result
 */
walletConnector.approveCallRequest(
  callId,
  {
    result: '0xabcd...873'
  }
)
 
/**
 *  Reject call request
 */
walletConnector.rejectCallRequest(
  callId
)

Install

npm i rn-walletconnect-wallet

DownloadsWeekly Downloads

61

Version

0.7.28

License

LGPL-3.0

Unpacked Size

997 kB

Total Files

6

Last publish

Collaborators

  • avatar
  • avatar