Last active
September 22, 2022 17:00
-
-
Save MarcoCiaramella/097b28e308817b2b7143d95a5e8d84f2 to your computer and use it in GitHub Desktop.
How to use Walletconnect v2.0 with Stellar network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see https://docs.walletconnect.com/2.0/quick-start/dapps/client | |
import WalletConnectClient from "@walletconnect/client"; | |
import { CLIENT_EVENTS } from "@walletconnect/client"; | |
const TESTNET = 'stellar:testnet'; | |
const PUBNET = 'stellar:pubnet'; | |
const STELLAR_METHODS = { | |
SIGN: 'stellar_signAndSubmitXDR', | |
}; | |
const client = await WalletConnectClient.init({ | |
projectId: "your project id from https://walletconnect.com/", | |
relayUrl: "wss://relay.walletconnect.org", | |
metadata: { | |
name: "Example Dapp", | |
description: "Example Dapp", | |
url: "#", | |
icons: ["https://walletconnect.com/walletconnect-logo.png"], | |
}, | |
}); | |
client.on( | |
CLIENT_EVENTS.pairing.proposal, | |
async (proposal) => { | |
// uri should be shared with the Wallet either through QR Code scanning or mobile deep linking | |
const { uri } = proposal.signal.params; | |
} | |
); | |
try { | |
const session = await client.connect({ | |
permissions: { | |
blockchain: { | |
chains: [PUBNET], | |
}, | |
jsonrpc: { | |
methods: [STELLAR_METHODS.SIGN], | |
}, | |
}, | |
}); | |
} catch (error) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feel free to ping me on https://twitter.com/BenRacicot
Are you using RC-2?