Skip to main content

Bundlr in the browser


The client now includes WebBundlr, for use in the browser. WebBundlr supports injected providers instead of raw private keys.

Example (Matic + MetaMask)

// example imports 
import { providers } from "ethers"
// import WebBundlr
import { WebBundlr } from "@bundlr-network/client";

const initialiseBundlr = async () => {

await window.ethereum.enable()

const provider = new providers.Web3Provider(window.ethereum);
await provider._ready()

const bundlr = new WebBundlr("", "matic", provider);
await bundlr.ready();

return bundlr; // done!

(More complete demo code can be found here and interacted with here)

Now whenever any functions that require signing are called (upload, fund, withdraw etc.) the provided signer (in this case MetaMask) will prompt the user to confirm the required actions.