Sending to Arweave with Bundlr
How is the content of a promise sent to Arweave?
How are the files sent with Bundlr?
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 };
};Preparing the transaction
Sending the transaction
Resources
Repository
External
Last updated