2.0.0 • Published 1 year ago

@kcf/kda-wallet-walletconnect-connect-button v2.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@kcf/kda-wallet-walletconnect-connect-button

A ready-to-use WalletConnect connect wallet button.

Usage Notes

  • As with all other @kcf/kda-wallet-* web components, the element is completely unstyled and not encapsulated in a shadow DOM to allow for easy customizability. The raw html is available in template.js
  • Uses @web3modal/standalone to present the WalletConect QR code

Attributes

namedescriptionrequireddefault
autoresumewhen set, the component will save the current wallet connected session to localStorage and attempt to resume from it the next time the user enters the sitenofalse
autoresumekeythe localStorage key to use to save autoresume datano@kcf/kda-wallets-web-components-base.DEFAULT_AUTORESUME_LOCALSTORAGE_KEY
network-idthe chainweb network IDno"mainnet01"
wc-relay-urlWalletConnect Relay URLno"relay.walletconnect.com"
wc-project-idWalletConnect project IDyes-
wc-project-nameWalletConnect project nameyes-
wc-project-descriptionWalletConnect project descriptionyes-
wc-project-urlWalletConnect project URLyes-
wc-project-iconWalletConnect project icon image URLyes-

Custom Events

See @kcf/kda-wallet-web-components-base for custom events' detail schema

namedispatched after
kdawallet:beginconnectuser clicks the button
kdawallet:abandonconnectuser closes the web3modal without connecting
kdawallet:connectedwallet connected
kdawallet:disconnectedwallet disconnected
kdawallet:errorerror

Example

<kda-wallet-walletconnect-connect-button
  autoresume
  network-id="testnet04"
  wc-project-id="67ce47db9e4c2585385be3581ee3cb9d"
  wc-project-name="Example Kadena Wallet Adapter App"
  wc-project-description="A simple webapp for testing kadena wallets"
  wc-project-url="http://localhost"
  wc-project-icon="https://altcoinsbox.com/wp-content/uploads/2023/01/kadena-logo-300x300.webp"
></kda-wallet-walletconnect-connect-button>
import { defineCustomElement } from "@kcf/kda-wallet-walletconnect-connect-button";

// must be called before use
defineCustomElement();

const btn = document.querySelector("kda-wallet-walletconnect-connect-button");
const wallet = btn.connectedWallet;
if (wallet) {
  console.log(wallet.accounts);
}