Sign DataItem
ArConnect Injected API signDataItem() function
Argument | Type | Description |
---|---|---|
dataItem | The bundled data item to sign |
Warning: The function returns a buffer of the signed data item. You'll need to manually load it into an
arbundles
DataItem
instance as seen in the example usage.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;
}[];
}
import { DataItem } from "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://node2.bundlr.network/tx`, {
method: "POST",
headers: {
"Content-Type": "application/octet-stream"
},
body: dataItem.getRaw()
});
Last modified 1mo ago