upload.uploadBundle(tx, bundleOptions?)
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. However, most users will use uploadFolder()
, an abstraction that handles the uploading, signing and bundling in a single function call.
Parameters
Notes
If a provided transaction is unsigned, the transaction is signed using a temporary (throwaway) key. This means transactions can be associated with a single "random" address.
If a buffer is provided, it is converted into a transaction and then signed by the throwaway key. The throwaway key, address, and all bundled (provided + throwaway signed + generated) transactions are returned by this method.
Returns
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
block, // Deprecated
validatorSignatures, // Deprecated
verify, // An async function used to verify the receipt at any time
}
Funding
Uploads of less than 100 KiB are are free. For larger uploads, you'll need to fund your account first.
Tags
You can add an optional array of tags in the BundleOptions
object (see code example below)
Example
Use a token-specific version of getIrysUploader()
to connect to an Irys Bundler before uploading. Choose one from here.
const uploadBundle = async () => {
const irys = await getIrysUploader();
const maxTxs = 5;
const txs = [];
// First create and sign a group of transactions
for (let i = 0; i < maxTxs; i++) {
const newTx = await irys.createTransaction(`Hirys World! ${i + 1}`, {
tags: [{ name: "Content-Type", value: "text/plain" }],
});
await newTx.sign(); // ID is now set
txs.push(newTx);
}
// Or send an array of Buffers
// If a Buffer is provided, it is converted into a transaction and then signed by the throwaway key
// const txs: Buffer[] = [
// Buffer.from("This is transaction data 1"),
// Buffer.from("This is transaction data 2"),
// ];
try {
const options = {
// throwawayKey: undefined, // Optional, pass a JWK if you have a throwaway key
bundleOpts: {
tags: [
{ name: "application-id", value: "foo" }, // Add optional tags
],
}
};
const uploadReceipt = await irys.uploader.uploadBundle(txs, options);
console.log(`All Txs uploaded.`);
for (let i = 0; i < uploadReceipt.txs.length; i++) {
console.log(`https://gateway.irys.xyz/${uploadReceipt.txs[i].id}`)
}
} 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/:transactionId.