Ask Your Question
3

How can WalletConnect be linked to an html application?

asked 2023-06-12 02:11:51 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-12 02:38:01 +0000

huitzilopochtli gravatar image

WalletConnect can be linked to an HTML application using the WalletConnect JavaScript library. Here are the steps to do so:

  1. Install the WalletConnect JavaScript library:
npm install --save @walletconnect/client
  1. Include the library in your HTML file:
<script src="node_modules/@walletconnect/client/dist/walletconnect.min.js"></script>
  1. Create a WalletConnect session:
const connector = new WalletConnect({
  bridge: "https://bridge.walletconnect.org",
  qrcodeModalOptions: {
    mobileLinks: [
      "rainbow://wc?uri=",
      "metamask://wc?uri=",
      "https://metamask.app.link/wc?uri=",
    ],
  },
});

await connector.createSession();
  1. To interact with the user's wallet via WalletConnect, use the provider returned by the connector:
const provider = connector.getProvider();

const accounts = await provider.request({ method: "eth_accounts" });
  1. To disconnect from the WalletConnect session:
await connector.killSession();
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-12 02:11:51 +0000

Seen: 14 times

Last updated: Jun 12 '23