Dispatch Transaction

Wander Injected API dispatch() function

The dispatch() function allows you to quickly sign and send a transaction to the network in a bundled format. It is best for smaller datas and contract interactions. If the bundled transaction cannot be submitted, it will fall back to a base layer transaction. The function returns the result of the API call.

Argument
Type
Description

transaction

A valid Arweave transaction instance (without a keyfile)

options?

Arweave transaction signature options

Note: This function requires the DISPATCH permission.

Note: The options argument is optional, if it is not provided, the extension will use the default signature options (default salt length) to sign the transaction.

Dispatch result

The dispatch() function returns the result of the operation, including the ID of the submitted transaction, as well as if it was submitted in a bundle or on the base layer.

export interface DispatchResult {
  id: string;
  type?: "BASE" | "BUNDLED";
}

Example usage

import Arweave from "arweave";

// create arweave client
const arweave = new Arweave({
  host: "ar-io.net",
  port: 443,
  protocol: "https"
});

// connect to the extension
await window.arweaveWallet.connect(["DISPATCH"]);

// create a transaction
const transaction = await arweave.createTransaction({
  data: '<html><head><meta charset="UTF-8"><title>Hello permanent world! This was signed via Wander!!!</title></head><body></body></html>'
});

// dispatch the tx
const res = await window.arweaveWallet.dispatch(transaction);

console.log(`The transaction was dispatched as a ${res.type === "BUNDLED" ? "bundled" : "base layer"} Arweave transaction.`)

Last updated

Was this helpful?