Skip to content

Connect wallet

<kadia-connect-wallet> is a UI-only component. It holds no wallet logic. The app gives it an adapter, shaped like the one in @kadia/dex-sdk.

import "@kadia/ui/elements";
const el = document.querySelector("kadia-connect-wallet");
el.adapter = {
discoverWallets: () => discoverWallets(globalThis.ergoConnector),
connectWallet,
disconnectWallet: async (session) => { /* app-specific */ },
};
el.addEventListener("kadia:wallet-connected", (e) => console.log(e.detail.session));
  • Nothing is discovered until the person clicks Connect wallet.
  • Nothing connects until they pick a wallet in the chooser. No wallet is connected automatically.
  • Nautilus is listed first when advertised. Other advertised connectors are listed after it.
  • An identityWarning from the adapter is shown next to that wallet.
Event Detail
kadia:wallet-connected { session }
kadia:wallet-disconnected { session }
kadia:wallet-error { message }

EIP-12 (dApp-Wallet Web Bridge) was never merged. The spec is the open draft ergoplatform/eips#23, checked at commit b70f406. The component itself contains no wallet calls, so it does not depend on the draft; the differences below are in the adapter an app supplies (such as the one in @kadia/dex-sdk).

Matches the draft

  • Wallet methods used after connecting: get_change_address() and sign_tx(), plus the optional get_used_addresses() and get_utxos().
  • Keys stay in the wallet, and the wallet asks the person before signing.

Differs from the draft

  • Discovery and connecting. The draft describes one wallet: the page calls ergo_request_read_access() (and ergo_check_read_access()), and the wallet injects a global ergo object. @kadia/dex-sdk instead reads an ergoConnector registry keyed by wallet id and calls connect({ createErgoObject: false }) then getContext(). This is a connector convention used by Nautilus-style wallets. It is not in the draft, and that is what makes a multi-wallet chooser possible.
  • get_current_height(). @kadia/dex-sdk uses it as an optional read-only observation. The draft does not define it.
  • disconnect(). The draft has no disconnect call. It defines a "ergo_wallet_disconnected" event instead.
  • Wallet-initiated disconnects. The component does not listen for "ergo_wallet_disconnected". If the wallet disconnects on its own, the button stays in the connected state until the person clicks it, unless the app’s adapter or code calls back. Wiring this up needs a change in the app or the component, and has not been done.

Because the draft is still open, treat all of this as subject to change.