Skip to content

Instantly share code, notes, and snippets.

@MarcoCiaramella
Last active September 22, 2022 17:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoCiaramella/097b28e308817b2b7143d95a5e8d84f2 to your computer and use it in GitHub Desktop.
Save MarcoCiaramella/097b28e308817b2b7143d95a5e8d84f2 to your computer and use it in GitHub Desktop.
How to use Walletconnect v2.0 with Stellar network
// 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) {
}
@FosterSOAsare
Copy link

There are stuff that don't work any more like
WalletConnectClient.init
and {CLIENT_EVENTS}
is there a way around it ?

@FosterSOAsare
Copy link

I also get key : null as part of the client hence the URI generated becomes invalid. Can you please help?

@MarcoCiaramella
Copy link
Author

Sorry I cannot help you. Maybe something is changed with the latest releases and I no longer use walletconnect in my project. For further helps better to write on walletconnect repo

@BenRacicot
Copy link

I also get key : null as part of the client hence the URI generated becomes invalid. Can you please help?

Feel free to ping me on https://twitter.com/BenRacicot
Are you using RC-2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment