Skip to content

luxfi/js

Repository files navigation


Lux Logo

Official Lux JavaScript/TypeScript SDKs and tools.

Getting Started 🚀

pnpm i        # installs all dependencies
pnpm build    # builds all packages

What's inside? 🔍

Core Packages

These Packages are published to NPM

  • luxnet: Lux Network JavaScript SDK.
  • @luxfi/cloud: Lux Cloud JavaScript SDK.
  • @luxfi/vue-components: Lux Wallet Vue Components and Vue SDK.
  • @luxfi/wallet-sdk: Lux Wallet SDK.
  • @luxfi/vm-parser: Parse arbitrary VM data for display in the Lux Network Explorer.

Dev Packages

These packages are only used internally for development

  • @luxfi/tsconfig: tsconfig for sdks
  • @luxfi/tsupp-config: tsup for sdks
  • @luxfi/eslint-config: eslint config for sdks
  • @luxfi/github-actions: github actions for sdks

Example Apps

These are apps published to the web

  • teleport-demo: This is a demo of the Lux Teleport cross-chain messaging system.

Each package and app is 100% TypeScript.

Please check out the examples folder for more info.

Useful commands

  • pnpm build - Build all packages
  • pnpm dev - Develop all packages
  • pnpm lint - Lint all packages
  • pnpm changeset - Generate a changeset. See in #versioning-and-publishing-packages

LuxNet - The Lux Network JavaScript Library

Overview

LuxNet is a JavaScript Library for interfacing with the Lux Network. It is built using TypeScript and intended to support both browser and Node.js. The LuxNet library allows you to issue commands to the Lux node APIs.

Using LuxNet, developers can:

  • Retrieve balances on addresses
  • Get UTXOs for addresses
  • Build and sign transactions
  • Issue signed transactions to the X-Chain, P-Chain, and C-Chain
  • Perform cross-chain swaps between the X, P and C chains
  • Add Validators and Delegators
  • Create Subnets and Blockchains

Requirements

LuxNet requires Node.js LTS version 20.11.1 or higher to compile.

Installation

Using the NPM Package

Add LuxNet to your project via npm or yarn.

For installing via npm:

npm install --save luxnet

For installing via yarn:

yarn add luxnet

Importing Essentials

import { avm /** X-chain */, pvm /** P-chain */, evm /** C-chain */, utils, secp256k1 } from "luxnet"

// example calls
const exportTx = avm.newExportTx(...) // constructs a new export tx from X
const addValidatorTx = pvm.newAddPermissionlessValidatorTx(...) // constructs a new add validator tx on P
const importTx = evm.newImportTx(...) // constructs a new import tx to C

const publicKeyBytes = utils.hexToBuffer(publicKeyHex)
const signature = secp256k1.signHash(bytes, privateKeyBytes)

Use LuxNet in Projects

The LuxNet library can be imported into your existing project as follows:

import { avm, pvm, evm } from 'luxnet';

Versioning and Publishing packages

Package publishing has been configured using Changesets. Please review their documentation to familiarize yourself with the workflow.

This repo has an automated npm releases setup in a GitHub Action using the Changesets bot.

Contributing

If you're interested in contributing, please read the contributing docs before submitting a pull request.