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
  • Data item
  • Example usage

Was this helpful?

Edit on GitHub
  1. API

Sign DataItem

Wander Injected API signDataItem() function

PreviousDispatch TransactionNextBatch Sign DataItem

Last updated 3 months ago

Was this helpful?

The signDataItem() function allows you to create and sign a data item object, compatible with . These data items can then be submitted to an compatible bundler.

Argument
Type
Description

dataItem

The bundled data item to sign

Note: This function requires the permission.

Warning: The function returns a buffer of the signed data item. You'll need to manually load it into an DataItem instance as seen in the .

Data item

This function requires a valid data item object, like so:

export interface DataItem {
  data: string | Uint8Array;
  target?: string;
  anchor?: string;
  tags?: {
    name: string;
    value: string;
  }[];
}

Example usage

import { DataItem } from "@dha-team/arbundles";

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

// sign the data item
const signed = await window.arweaveWallet.signDataItem({
  data: "This is an example data",
  tags: [
    {
      name: "Content-Type",
      value: "text/plain",
    },
  ],
});

// load the result into a DataItem instance
const dataItem = new DataItem(signed);

// now you can submit it to a bunder
await fetch(`https://upload.ardrive.io/v1/tx`, {
  method: "POST",
  headers: {
    "Content-Type": "application/octet-stream",
  },
  body: dataItem.getRaw(),
});

๐Ÿงช
DataItem
arbundles
ANS-104
arbundles
example usage
SIGN_TRANSACTION