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
  • Example usage
  • With arweave-js (recommended)
  • Directly using Wander

Was this helpful?

Edit on GitHub
  1. API

Sign Transaction

Wander Injected API sign() function

PreviousGet wallet namesNextDispatch Transaction

Last updated 3 months ago

Was this helpful?

To submit a transaction to the Arweave Network, it first has to be signed using a private key. The sign() function is meant to replicate the behavior of the transactions.sign() function of , but instead of mutating the transaction object, it returns a new and signed transaction instance.

Argument
Type
Description

transaction

A valid Arweave transaction instance (without a keyfile)

options?

Arweave transaction signature options

Note: This function requires the 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.

Tip: A better alternative to this function is using the transactions.sign() instead. Just omit the second parameter (JWK key) when calling the method, and will automatically use Wander.

Note: If you are trying to sign a larger piece of data (5 MB <), make sure to notify the user to not switch / close the browser tab. Larger transactions are split into chunks in the background and will take longer to sign.

Example usage

With arweave-js (recommended)

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(["SIGN_TRANSACTION"]);

// 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>'
});

// sign using arweave-js
await arweave.transactions.sign(transaction);

// TODO: post the transaction to the network

Directly using Wander

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(["SIGN_TRANSACTION"]);

// create a transaction
let 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>'
});

// sign using arweave-js
const signedFields = await window.arweaveWallet.sign(transaction);

// update transaction fields with the
// signed transaction's fields
transaction.setSignature({
  id: signedFields.id,
  owner: signedFields.owner,
  reward: signedFields.reward,
  tags: signedFields.tags,
  signature: signedFields.signature
});

// TODO: post the transaction to the network

๐Ÿงช
Transaction
SignatureOptions
arweave-js
arweave-js
arweave-js
SIGN_TRANSACTION