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
  • Basic usage
  • Advanced usage
  • TypeScript types
  • Additional Injected API fields

Was this helpful?

Edit on GitHub
  1. API

Intro

Introducing the Wander Injected API

PreviousArLocal DevtoolsNextEvents

Last updated 3 months ago

Was this helpful?

The Wander API is a JavaScript object, injected into each browser tab. To interact with it, you simply need to call one of the functions in the window.arweaveWallet object.

Basic usage

// create Arweave transaction
const tx = await arweave.createTransaction({
  /* tx options */
});

// sign transaction
await arweave.transactions.sign(tx);

// TODO: handle signed transaction

Once the transaction is signed, you can safely post it to the network.

Advanced usage

The Wander Injected API provides extra functionalities in case you wish to utilize the user's wallet to its full extent securely. These features are not integrated in the arweave-js package, but can be useful to further customize your app. The above mentioned window.arweaveWallet object holds the api functions necessary for this.

Each function is described in detail in the following pages.

TypeScript types

To support Wander types for window.arweaveWallet, you can install the npm package arconnect, like this:

Wander was formerly know as ArConnect. There are some API references that still use ArConnect

npm i -D arconnect

or

yarn add -D arconnect

To add the types to your project, you should either include the package in your tsconfig.json, or add the following to your env.d.ts file:

/// <reference types="arconnect" />

Additional Injected API fields

The Wander Injected API provides some additional information about the extension. You can retrieve the wallet version (window.arweaveWallet.walletVersion) and you can even verify that the currently used wallet API indeed belongs to Wander using the wallet name (window.arweaveWallet.walletName).

addEventListener("arweaveWalletLoaded", () => {
  console.log(`You are using the ${window.arweaveWallet.walletName} wallet.`);
  console.log(`Wallet version is ${window.arweaveWallet.walletVersion}`);
});

To use Wander in your application, you don't need to integrate or learn how the Wander Injected API works. Using , you can easily sign a transaction through Wander in the background:

When signing a transaction through , you'll need to omit the second argument of the sign() function, or set it to "use_wallet". This will let the package know to use the extension in the background to sign the transaction.

Please remember: to interact with the API, make sure that the arweaveWalletLoaded event has already been fired. Read more about that .

๐Ÿงช
arweave-js
arweave-js
here