Tezos Bundler Node

1.0.2 · active · verified Tue Apr 21

tezos-bundler is a JavaScript/TypeScript library, currently stable at version 1.0.2, designed to facilitate cross-chain interactions between the Tezos and Arweave ecosystems. It provides a REST API endpoint for accepting Arweave ANS-104 bundles that have been cryptographically signed using a Tezos wallet keypair. This functionality enables developers to build applications where Tezos users can directly and securely publish immutable data to the Arweave permaweb. The library's core differentiator is its integrated Tezos signature verification for Arweave bundles, simplifying the deployment of decentralized applications that leverage both chains. It requires a specific Node.js environment (v16.13.2) and relies on a configured Arweave instance (e.g., a production gateway or a local ArLocal server) to function correctly. While a formal release cadence isn't explicitly stated, its current version suggests active development and maintenance.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically initialize and start the TezosBundler node, including secure (simulated) JWK loading and Arweave client configuration for local or remote instances.

import Arweave from 'arweave'
import TezosBundler from 'tezos-bundler'
import path from 'path'
import fs from 'fs'

// In a real application, securely load your Arweave JWK, e.g., from environment variables or a secure vault.
// For this example, we'll simulate loading from a local file.
// DO NOT commit your private keys to version control.
const arweaveJWKPath = path.join(process.cwd(), 'my-arweave-keyfile.json');
let arweaveJWK;
try {
  if (fs.existsSync(arweaveJWKPath)) {
    arweaveJWK = JSON.parse(fs.readFileSync(arweaveJWKPath, 'utf-8'));
  } else {
    console.warn(`Warning: Arweave JWK file not found at ${arweaveJWKPath}. Using placeholder; this will likely fail.`)
    arweaveJWK = { /* Placeholder for invalid JWK */ };
  }
} catch (error) {
  console.error('Failed to load arweave JWK:', error);
  arweaveJWK = { /* Placeholder for invalid JWK */ };
}

// Configure Arweave client. Use ArLocal defaults for testing, or a production gateway.
const arweave = new Arweave({
  host: process.env.ARWEAVE_HOST ?? '127.0.0.1', // e.g., 'arweave.net'
  port: parseInt(process.env.ARWEAVE_PORT ?? '1984'), // e.g., 443
  protocol: process.env.ARWEAVE_PROTOCOL ?? 'http' // e.g., 'https'
});

const tezosBundler = new TezosBundler(arweaveJWK, arweave);

async function startBundler() {
  try {
    await tezosBundler.start();
    console.log('Tezos Bundler Node started successfully.');
    console.log('REST API available at POST /bundle/xtz');
  } catch (error) {
    console.error('Failed to start Tezos Bundler Node:', error);
    // Gracefully handle startup failure, perhaps exit the process or retry.
    process.exit(1);
  }
}

startBundler();

// Example for server middleware (e.g., Next.js API route or Nuxt.js server middleware)
// export default tezosBundler.app.callback();

view raw JSON →