Bundlr(Arweave)

Dive into the specifics of connecting and using Bundlr(Arweave) with web3stash

Initialization

To use Bundlr you have to pass "BUNDLR" as the service name. No other name will work!

const bundlrService = Web3Stash("BUNDLR",{currency:"", privateKey:"", testing:false},{Bundlr APIconfig options})

Configuration

To use Bundlr in web3stash, you need three things:

  • currency - Currency You want to use for transactions(Check Bundlr Docs)

  • privateKey - PrivateKey to be used to sign transactions

  • testing- This is optional, Default is false, If you are testing set it to true so that it uses the testing node of bundlr

Note: Use these names only while passing keys in object i.e, {currency:"", privateKey:"", testing:true}

Optional Config Options

You can pass config options that is available with bundlr service- You can check bundlr docs to check what config options are there which you can pass while initialising bundlr

{timeout?: number | undefined; providerUrl?: string | undefined; contractAddress?: string | undefined; currencyOpts?: any}

Methods Available

The following methods are available for this service, More will be added soon

  • Uploading JSON data

bundlrService.uploadJson({name:"example", url:"abc.com"}, {bundlrOptions}).then().catch()
  • Uploading Image

bundlrService.uploadImage("./image.png", {bundlrOptions}).then().catch()
  • Uploading Video

bundlrService.uploadVideo("./video.mp4", {bundlrOptions}).then().catch()
  • Uploading File

bundlrService.uploadFile("./data.txt", {bundlrOptions}).then().catch()
  • Uploading Images from Stream

bundlrService.uploadImageFromStream(readableStream, 1024, "png", {bundlrOptions}).then().catch()
  • Uploading Video from Stream

bundlrService.uploadVideoFromStream(readableStream, 1024, "mp4", {bundlrOptions}).then().catch()
  • Uploading File from Stream

bundlrService.uploadFileFromStream(readableStream, 1024, "txt", {bundlrOptions}).then().catch()

Output

All the functions return id (cid) and metadata (data returned by the service on upload)

{id:"dewfnlpweurmwknrwiojhgcbxczz", metadata:{}}

Last updated