项目作者: cawfree

项目描述 :
⚛️ 👛 WalletConnect for React Native! Zero linking, full awesome. (Android/iOS/Web/Expo)
高级语言: JavaScript
项目地址: git://github.com/cawfree/react-native-walletconnect.git
创建时间: 2020-10-07T21:12:51Z
项目社区:https://github.com/cawfree/react-native-walletconnect

开源协议:MIT License

下载


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:

  1. yarn add react-native-webview react-native-walletconnect

✍️ Usage

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

  1. import React from "react";
  2. import { SafeAreaView, Button } from "react-native";
  3. import WalletConnectProvider, { useWalletConnect } from "react-native-walletconnect";
  4. const WalletConnectExample = () => {
  5. const {
  6. createSession,
  7. killSession,
  8. session,
  9. signTransaction,
  10. } = useWalletConnect();
  11. const hasWallet = !!session.length;
  12. return (
  13. <>
  14. {!hasWallet && (
  15. <Button title="Connect" onPress={createSession} ></Button>
  16. )}
  17. {!!hasWallet && (
  18. <Button
  19. title="Sign Transaction"
  20. onPress={() => signTransaction({
  21. from: "0xbc28Ea04101F03aA7a94C1379bc3AB32E65e62d3",
  22. to: "0x89D24A7b4cCB1b6fAA2625Fe562bDd9A23260359",
  23. data: "0x",
  24. gasPrice: "0x02540be400",
  25. gas: "0x9c40",
  26. value: "0x00",
  27. nonce: "0x0114",
  28. })}
  29. />
  30. )}
  31. {!!hasWallet && (
  32. <Button
  33. title="Disconnect"
  34. onPress={killSession}
  35. ></Button>
  36. )}
  37. </>
  38. );
  39. };
  40. export default function App() {
  41. return (
  42. <WalletConnectProvider>
  43. <WalletConnectExample ></WalletConnectExample>
  44. </WalletConnectProvider>
  45. );
  46. }

useWalletConnect

The useWalletConnect hook provides the following functionality:

✌️ License

MIT