WalletConnect / kotlin-walletconnect-lib

library to use WalletConnect with Kotlin or Java
MIT License
156 stars 100 forks source link

WalletConnect #81

Open bryanwong030 opened 2 years ago

bryanwong030 commented 2 years ago

import WalletConnect from "@walletconnect/client"; import QRCodeModal from "@walletconnect/qrcode-modal";

// Create a connector const connector = new WalletConnect({ bridge: "https://bridge.walletconnect.org", // Required qrcodeModal: QRCodeModal, });

// Check if connection is already established if (!connector.connected) { // create new session connector.createSession(); }

// Subscribe to connection events connector.on("connect", (error, payload) => { if (error) { throw error; }

// Get provided accounts and chainId const { accounts, chainId } = payload.params[0]; });

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

// Get updated accounts and chainId const { accounts, chainId } = payload.params[0]; });

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

// Delete connector });