Skip to main content

Connecting To A Node

To connect to a Bundlr node, provide your private key to allow for access to stored funds and for signing transactions.

When creating a Bundlr object there are two methods, depending on if you're using JavaScript or TypeScript:

  1. TypeScript: const bundlr = new Bundlr("", "arweave", “<arweave_private_key>”);
  2. JavaScript: const bundlr = new Bundlr.default("", "matic", “<polygon_private_key>”);

The Bundlr constructor accepts three arguments:

  1. Node address: Address of the node you’ll connect to, current options are, and
  2. Currency: Name of the currency used to pay.
  3. Key: Your private key.

You can optionally specify a custom RPC:

const bundlr = new Bundlr("", "solana", "<solana_private key>", { providerUrl: "" });

import Bundlr from "@bundlr-network/client";
import fs from "fs";

// Change this line to match the name of the wallet key file
// you downloaded from
// Physically move your key file from the download directory to the
// project directory that holds this JS file.
const privateKey = "arweave-key-aOTcToJZnW6wQQE6fKSFCta7etFX5Gy8KjJ_B-GsS14.json";

const jwk = JSON.parse(fs.readFileSync(privateKey).toString());

// NOTE: Depending on the version of JavaScript you use, you may need to use
// the commented out line below to create a new Bundlr object.
// const bundlr = new Bundlr("", "arweave", jwk);
const bundlr = new Bundlr.default("", "arweave", jwk);

// Print your wallet address
console.log(`wallet address = ${bundlr.address}`);