Batch Sign DataItem
Wander Injected API batchSignDataItem() function
Last updated
Was this helpful?
Was this helpful?
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.batchSignDataItem([
{
data: "This is an example transaction 1",
tags: [
{
name: "Content-Type",
value: "text/plain",
},
],
},
{
data: "This is an example transaction 2",
tags: [
{
name: "Content-Type",
value: "text/plain",
},
],
},
]);
// load the result into a DataItem instance
const dataItems = signed.map((buffer) => new DataItem(buffer));
// now you can submit them to a bundler
for (const dataItem of dataItems) {
await fetch(`https://upload.ardrive.io/v1/tx`, {
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
},
body: dataItem.getRaw(),
});
}