Sending to Arweave with Bundlr
How is the content of a promise sent to Arweave?
If the option is selected, files are zipped and sent to Arweave using Bundlr - which is a PoS network built on top of Arweave. Bundlr nodes bundle multiple transactions, each time for two minutes, and submit them onto Arweave, which makes the process way faster and cheaper, whilst remaining as reliable (Learn more).
How are the files sent with Bundlr?
The process is different from the one used to send files to IPFS, and requires more input from the user. It can be condensed into the following steps:
Connect the user wallet to the Bundlr node.
Prepare the upload
Create the zip archive
Find the price in MATIC for
namount of data.Fund the Bundlr "wallet" - the address associated to the user's private key
Create the transaction and upload the data.
Each stage is outlined below, with details in the relevant code.
Connecting to Bundlr
const initializeBundlr = async (provider, chainId) => {
// Find the RPC url based on the chain (mainnet or testnet)
const rpcUrl =
chainId === 80001
? process.env.NEXT_PUBLIC_MUMBAI_RPC_URL
: process.env.NEXT_PUBLIC_POLYGON_RPC_URL;
// Get the appropriate bundler url (mainnet or devnet)
const bundlrUrl = networkMapping[chainId].Bundlr[0];
// Connect with MATIC as a currency to the appropriate node
const bundlr = new WebBundlr(bundlrUrl, 'matic', provider, {
providerUrl: rpcUrl,
});
await bundlr.ready().catch((err) => {
console.log(err);
toast.error('Please connect to the Arweave network to continue');
});
let isReady;
if (bundlr.address === 'Please run `await bundlr.ready()`') {
isReady = false;
} else {
isReady = true;
}
return { instance: bundlr, isReady };
};After the user is connected, they can start interacting with the network.
Preparing the transaction
Sending the transaction
Resources
Last updated