├── .expo-shared └── assets.json ├── .gitignore ├── App.tsx ├── Demo.gif ├── README.md ├── WalletConnectExperience.tsx ├── app.json ├── assets ├── adaptive-icon.png ├── favicon.png ├── icon.png └── splash.png ├── babel.config.js ├── expo-qrcode.png ├── global.ts ├── metro.config.js ├── package.json ├── tsconfig.json └── yarn.lock /.expo-shared/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true, 3 | "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .expo/ 3 | dist/ 4 | npm-debug.* 5 | *.jks 6 | *.p8 7 | *.p12 8 | *.key 9 | *.mobileprovision 10 | *.orig.* 11 | web-build/ 12 | 13 | # macOS 14 | .DS_Store 15 | -------------------------------------------------------------------------------- /App.tsx: -------------------------------------------------------------------------------- 1 | import "./global"; 2 | 3 | import * as React from "react"; 4 | import { StatusBar } from "expo-status-bar"; 5 | import { StyleSheet, View, Platform } from "react-native"; 6 | import WalletConnectProvider from "@walletconnect/react-native-dapp"; 7 | import AsyncStorage from "@react-native-async-storage/async-storage"; 8 | 9 | import WalletConnectExperience from "./WalletConnectExperience"; 10 | 11 | const SCHEME_FROM_APP_JSON = "walletconnect-example"; 12 | 13 | export default function App() { 14 | return ( 15 | 25 | 26 | 27 | 28 | 29 | 30 | ); 31 | } 32 | 33 | const styles = StyleSheet.create({ 34 | container: { 35 | flex: 1, 36 | backgroundColor: "#fff", 37 | alignItems: "center", 38 | justifyContent: "center", 39 | }, 40 | }); 41 | -------------------------------------------------------------------------------- /Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/draftbit/expo-walletconnect-demo/60b9634a01a1c86437057b03809786547e67b828/Demo.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Expo WalletConnect Demo 2 | 3 | Without ejecting, we're able to connect an Expo app to MetaMask via WalletConnect. 4 | 5 | 6 | 7 | ## What do these changes consist of? 8 | 9 | - Polyfilling NodeJS libraries within [metro.config.js](./metro.config.js) 10 | - Creating and updating [global.ts](./global.ts) 11 | 12 | ## Run this on your own 13 | - clone repo 14 | - yarn install 15 | - expo start 16 | - scan QR code 17 | -------------------------------------------------------------------------------- /WalletConnectExperience.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Text, TouchableOpacity, StyleSheet } from "react-native"; 3 | import { useWalletConnect } from "@walletconnect/react-native-dapp"; 4 | 5 | const shortenAddress = (address: string) => { 6 | return `${address.slice(0, 6)}...${address.slice( 7 | address.length - 4, 8 | address.length 9 | )}`; 10 | }; 11 | 12 | function Button({ onPress, label }: any) { 13 | return ( 14 | 15 | {label} 16 | 17 | ); 18 | } 19 | 20 | export default function WalletConnectExperience() { 21 | const connector = useWalletConnect(); 22 | 23 | const connectWallet = React.useCallback(() => { 24 | return connector.connect(); 25 | }, [connector]); 26 | 27 | const killSession = React.useCallback(() => { 28 | return connector.killSession(); 29 | }, [connector]); 30 | 31 | return ( 32 | <> 33 | {!connector.connected ? ( 34 |