or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cryptographic-operations.mdcurrency-utilities.mddata-upload-chunking.mddata-utilities.mdencrypted-storage-silo.mdindex.mdnetwork-blockchain.mdtransaction-management.mdwallet-operations.md
tile.json

tessl/npm-arweave

JavaScript/TypeScript client library for the Arweave decentralized permanent data storage network

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/arweave@1.15.x

To install, run

npx @tessl/cli install tessl/npm-arweave@1.15.0

index.mddocs/

Arweave

Arweave is a comprehensive JavaScript/TypeScript client library for interacting with the Arweave network, a decentralized permanent data storage protocol. It enables developers to create and manage wallets, send transactions, store data permanently on the Arweave permaweb, query blockchain data, and perform various blockchain operations. The library supports both Node.js and web browser environments with seamless integration.

Package Information

  • Package Name: arweave
  • Package Type: npm
  • Language: TypeScript/JavaScript
  • Installation: npm install arweave

Core Imports

import Arweave from "arweave";

For CommonJS:

const Arweave = require("arweave");

Basic Usage

import Arweave from "arweave";

// Initialize Arweave client
const arweave = Arweave.init({
  host: "arweave.net",
  port: 443,
  protocol: "https"
});

// Generate a new wallet
const key = await arweave.wallets.generate();
const address = await arweave.wallets.jwkToAddress(key);

// Check wallet balance
const balance = await arweave.wallets.getBalance(address);
console.log(arweave.ar.winstonToAr(balance));

// Create and post a data transaction
const transaction = await arweave.createTransaction({
  data: "Hello, Arweave!"
}, key);

await arweave.transactions.sign(transaction, key);
await arweave.transactions.post(transaction);

Architecture

Arweave is built around several key components:

  • Core Client: Arweave class providing factory initialization and unified transaction creation
  • Module API: Specialized modules (wallets, transactions, network, blocks, ar, silo, chunks) for different operations
  • Static Utilities: Arweave.crypto for cryptographic operations and Arweave.utils for data conversion
  • Transaction System: Comprehensive transaction lifecycle management with chunked uploads and verification
  • Multi-Environment: Separate entry points for Node.js and Web with appropriate crypto drivers

Capabilities

Client Initialization

Core Arweave client initialization and configuration for connecting to Arweave nodes.

static init(apiConfig?: ApiConfig): Arweave;

interface ApiConfig {
  host?: string;
  protocol?: string;
  port?: string | number;
  timeout?: number;
  logging?: boolean;
  logger?: Function;
  network?: string;
}

Wallet Operations

Comprehensive wallet management including generation, address derivation, and balance queries.

// Main wallet operations
getBalance(address: string): Promise<string>;
generate(): Promise<JWKInterface>;
jwkToAddress(jwk?: JWKInterface | "use_wallet"): Promise<string>;
getAddress(jwk?: JWKInterface | "use_wallet"): Promise<string>;

Wallet Operations

Transaction Management

Complete transaction lifecycle management including creation, signing, submission, and monitoring.

// Core transaction methods
createTransaction(attributes: Partial<CreateTransactionInterface>, jwk?: JWKInterface | "use_wallet"): Promise<Transaction>;
sign(transaction: Transaction, jwk?: JWKInterface | "use_wallet", options?: SignatureOptions): Promise<void>;
post(transaction: Transaction | Buffer | string | object): Promise<{status: number; statusText: string; data: any}>;
get(id: string): Promise<Transaction>;
getStatus(id: string): Promise<TransactionStatusResponse>;

Transaction Management

Data Upload and Chunking

Advanced data upload capabilities with chunked uploading for large files and progress monitoring.

// Upload management
getUploader(upload: Transaction | SerializedUploader | string, data?: Uint8Array | ArrayBuffer): Promise<TransactionUploader>;
upload(upload: Transaction | SerializedUploader | string, data: Uint8Array): AsyncGenerator<TransactionUploader>;

// Chunk operations  
getChunk(offset: string | number | BigInt): Promise<TransactionChunkResponse>;
downloadChunkedData(id: string): Promise<Uint8Array>;

Data Upload and Chunking

Network and Blockchain Operations

Network information queries, peer discovery, and block data retrieval.

// Network operations
getInfo(): Promise<NetworkInfoInterface>;
getPeers(): Promise<PeerList>;

// Block operations
get(indepHash: string): Promise<BlockData>;
getCurrent(): Promise<BlockData>;
getByHeight(height: number): Promise<BlockData>;

Network and Blockchain Operations

Currency Utilities

AR/winston currency conversion and arithmetic operations for handling Arweave's native currency.

// Currency conversion
winstonToAr(winstonString: string, options?): string;
arToWinston(arString: string, options?): string;

// Currency arithmetic
compare(winstonStringA: string, winstonStringB: string): number;
add(winstonStringA: string, winstonStringB: string): string;
sub(winstonStringA: string, winstonStringB: string): string;

Currency Utilities

Cryptographic Operations

Low-level cryptographic functions for signing, verification, encryption, and hashing.

// Key management
generateJWK(): Promise<JWKInterface>;

// Signing and verification
sign(jwk: JWKInterface, data: Uint8Array, options?: SignatureOptions): Promise<Uint8Array>;
verify(publicModulus: string, data: Uint8Array, signature: Uint8Array): Promise<boolean>;

// Encryption and hashing
encrypt(data: Uint8Array, key: string | Uint8Array, salt?: string): Promise<Uint8Array>;
hash(data: Uint8Array, algorithm?: string): Promise<Uint8Array>;

Cryptographic Operations

Data Utilities

Utility functions for data conversion, encoding/decoding, and buffer manipulation.

// Buffer/string conversion
stringToBuffer(string: string): Uint8Array;
bufferToString(buffer: Uint8Array | ArrayBuffer): string;

// Base64 URL encoding/decoding
bufferTob64Url(buffer: Uint8Array): string;
b64UrlToBuffer(b64UrlString: string): Uint8Array;

Data Utilities

Encrypted Storage (Silo)

Silo protocol implementation for encrypted data storage with URI-based access control.

// Silo operations
get(siloURI: string): Promise<Uint8Array>;
parseUri(siloURI: string): Promise<SiloResource>;
createSiloTransaction(attributes: Partial<CreateTransactionInterface>, jwk: JWKInterface, siloUri: string): Promise<Transaction>;

Encrypted Storage (Silo)

Deprecated APIs

The following APIs are deprecated and maintained for backward compatibility:

// Deprecated ArQL query method (use GraphQL instead)
arql(query: object): Promise<string[]>;

// Deprecated transaction search (use GraphQL instead)
search(tagName: string, tagValue: string): Promise<string[]>;

// Deprecated instance access to static utilities
get crypto(): CryptoInterface; // Use Arweave.crypto instead
get utils(): ArweaveUtilsInterface; // Use Arweave.utils instead

Types

Core Interfaces

interface JWKInterface {
  kty: string;
  e: string;
  n: string;
  d?: string;
  p?: string;
  q?: string;
  dp?: string;
  dq?: string;
  qi?: string;
}

interface Tag {
  name: string;
  value: string;
}

interface CreateTransactionInterface {
  format: number;
  last_tx: string;
  owner: string;
  tags: Tag[];
  target: string;
  quantity: string;
  data: string | Uint8Array | ArrayBuffer;
  data_size: string;
  data_root: string;
  reward: string;
}

interface ArweaveUtilsInterface {
  /** Convert string to Uint8Array buffer */
  stringToBuffer(string: string): Uint8Array;
  /** Convert buffer to UTF-8 string */
  bufferToString(buffer: Uint8Array | ArrayBuffer): string;
  /** Convert buffer to base64url string */
  bufferTob64Url(buffer: Uint8Array): string;
  /** Convert base64url string to buffer */
  b64UrlToBuffer(b64UrlString: string): Uint8Array;
  /** Convert string to base64url */
  stringToB64Url(string: string): string;
  /** Convert base64url to string */
  b64UrlToString(b64UrlString: string): string;
  /** Concatenate multiple buffers */
  concatBuffers(buffers: Uint8Array[] | ArrayBuffer[]): Uint8Array;
}