Wander Docs
HomeGithub
  • ๐Ÿ‘‹Welcome to Wander
  • โ›๏ธDeveloper tooling
    • Wander Devtools
    • ArLocal Devtools
  • ๐Ÿ“šExternal libraries
    • Arweave Wallet Kit
    • arweave-js
  • ๐Ÿ”ญDemos
    • Applications
  • ๐ŸงชAPI
    • Intro
    • Events
    • Connect
    • Disconnect
    • Get active address
    • Get active public key
    • Get all addresses
    • Get wallet names
    • Sign Transaction
    • Dispatch Transaction
    • Sign DataItem
    • Batch Sign DataItem
    • Sign message
    • Verify message
    • Private hash
    • User Tokens
    • Token Balance
    • Encrypt
    • Decrypt
    • Crypto signature
    • Subscriptions
    • Retrive permissions
    • Retrive Gateway Config
  • ๐ŸŒWander.app
Powered by GitBook
On this page
  • arweaveWalletLoaded event
  • Example
  • walletSwitch event
  • Example
  • Event emitter

Was this helpful?

Edit on GitHub
  1. API

Events

Wander DOM events

PreviousIntroNextConnect

Last updated 3 months ago

Was this helpful?

Wander provides useful custom events to track the state of the extension. These events implement the browser API.

arweaveWalletLoaded event

This event is dispatched once the Wander Injected API has been initialized in the window object. Before this event is fired, you cannot interact with Wander and the window.arweaveWallet object will be undefined.

Example

addEventListener("arweaveWalletLoaded", () => {
  // now we can interact with Wander
  const permissions = await window.arweaveWallet.getPermissions();

  if (permissions.length <= 0) {
    await window.arweaveWallet.connect(["ACCESS_ADDRESS"]);
  }
});

walletSwitch event

This event is fired when the user manually switches their active wallet. The even also includes the new active wallet's address, if the user allowed the ACCESS_ADDRESS and the ACCESS_ALL_ADDRESSES permissions.

Example

addEventListener("walletSwitch", (e) => {
  const newAddress = e.detail.address;

  // handle wallet switch
});

Event emitter

The event emitter is available under window.arweaveWallet.events as a more advanced event system for the extension.

Note: This documentation is incomplete and the feature is experimental.

๐Ÿงช
CustomEvent