Lux Docs

Cli API Reference

Programmatic CLI usage from Go

The CLI packages can be imported directly into Go programs for programmatic network and chain management.

Network Management

package main

import (
    "fmt"

    "github.com/luxfi/cli/pkg/application"
    "github.com/luxfi/cli/pkg/network"
)

func main() {
    app := application.New()

    // Start a 5-node testnet
    cfg := network.Config{
        NumNodes:    5,
        NetworkType: "testnet",
        PortBase:    9640,
    }
    net, err := network.Start(cfg)
    if err != nil {
        panic(err)
    }
    defer net.Stop()

    fmt.Println("Network started:", net.Endpoints())
}

Key Management

import "github.com/luxfi/cli/pkg/key"

// Generate a new key set
keySet, err := key.Generate("validator1")
if err != nil {
    return err
}
fmt.Println("Address:", keySet.CChainAddress())

// List existing keys
keys, err := key.List()
for _, k := range keys {
    fmt.Printf("  %s: %s\n", k.Name, k.Address)
}

Chain Management

import "github.com/luxfi/cli/pkg/chain"

// Create chain configuration
cfg := chain.CreateConfig{
    Name:       "mychain",
    EVMChainID: 12345,
    TokenName:  "MYT",
}
err := chain.Create(cfg)

// Deploy to running network
err = chain.Deploy("mychain", chain.DeployConfig{
    Network: "testnet",
})

Constants

ConstantValueDescription
DefaultNodeVersionv1.23.23Default luxd binary version
MainnetPort9630Mainnet HTTP base port
TestnetPort9640Testnet HTTP base port
DevnetPort9650Devnet HTTP base port
PackagePurpose
pkg/applicationCLI application context and configuration
pkg/networkNetwork lifecycle management
pkg/keyKey generation and storage
pkg/chainChain creation and deployment
pkg/constantsDefault versions, ports, paths

On this page