upload.uploadBundle(tx)
Permanently uploads an array of transactions as a bundle in a single transaction.
This function is provided for users who need to obtain each transaction's ID before uploading. Most users will opt to use irys.uploadFolder()
, an abstraction that handles the uploading, signing and bundling in a single function call.
Parameters
data
: The data to uploadtags
: Optional metatags
Returns
-receipt
: A receipt in the form of a JSON object with the following values:
response = {
id, // Transaction id (used to download the data)
timestamp, // Timestamp (UNIX milliseconds) of when the transaction was created and verified
version, // The version of this JSON file, currently 1.0.0
public, // Public key of the bundler node used
signature, // A signed deep hash of the JSON receipt
deadlineHeight, // The block number by which the transaction must be finalized on Arweave
block, // Deprecated
validatorSignatures, // Deprecated
verify, // An async function used to verify the receipt at any time
}
Example
const irys = await getIrys();
const maxTxs = 5;
const txs = [];
for (let i = 0; i < maxTxs; i++) {
const newTx = irys.createTransaction(`GM World! ${i + 1}`, {
tags: [{ name: "Content-Type", value: "text/plain" }],
});
await newTx.sign(); // ID is now set
txs.push(newTx);
console.log(`Tx created and signed, https://gateway.irys.xyz/${newTx.id}`);
}
try {
const uploadReceipt = await irys.uploader.uploadBundle(txs);
console.log(`All Txs uploaded.`);
} catch (e) {
console.log("Error uploading bundle ", e);
}
ℹ️
The transaction id returned as part of the response is used to download the data, simply create a URL with the format
https://gateway.irys.xyz/[transaction-id].