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.
const bundlr = new Bundlr("http://node1.bundlr.network", "arweave", “<arweave_private_key>”);
const bundlr = new Bundlr("http://node2.bundlr.network", "matic", “<polygon_private_key>”);
The Bundlr constructor accepts three arguments:
- Node address: Address of the node you’ll connect to, current options are:
- Currency: Name of the currency used to pay.
- Key: Your private key.
You can optionally specify a custom RPC:
const bundlr = new Bundlr("https://devnet.bundlr.network", "solana", "<solana_private key>", {
providerUrl: "https://api.devnet.solana.com",
});
Code example:
import Bundlr from "@bundlr-network/client";
const myPrivateKey = ""; // Change to match your private key
const bundlr = new Bundlr("http://node1.bundlr.network", "matic", myPrivateKey);
// Print your wallet address
console.log(`wallet address = ${bundlr.address}`);
note
As of the 0.11.0 SDK release, it is no longer required to use the following format when instantiating a Bundlr object via JavaScript. If your code still uses the .default() format, you will need to update it when upgrading your SDK.
const bundlr = new Bundlr.default("http://node1.bundlr.network", "matic", “<polygon_private_key>”);