deploy

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package deploy provides a clean, composable interface for deploying subnets and blockchains to any Lux network endpoint.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoEndpoint is returned when no endpoint is configured
	ErrNoEndpoint = errors.New("no endpoint configured")
	// ErrNoKeychain is returned when no keychain is configured
	ErrNoKeychain = errors.New("no keychain configured")
	// ErrInvalidThreshold is returned when threshold exceeds control key count
	ErrInvalidThreshold = errors.New("threshold cannot exceed number of control keys")
)
View Source
var (
	// SubnetEVMID is the VM ID for SubnetEVM/LuxEVM
	SubnetEVMID = ids.ID{'s', 'r', 'E', 'X', 'i', 'W', 'a', 'H', 'u', 'h', 'N', 'y', 'G', 'w', 'P', 'U', 'i', '4', '4', '4', 'T', 'u', '4', '7', 'Z', 'E', 'D', 'w', 'x', 'T', 'W', 'r'}

	// XSVMID is the example cross-subnet VM
	XSVMID ids.ID
)

Well-known VM IDs

View Source
var EWOQKeyBytes = []byte{
	0x56, 0x28, 0x9e, 0x99, 0xc9, 0x4b, 0x69, 0x12,
	0xbf, 0xc1, 0x2a, 0xdc, 0x09, 0x3c, 0x9b, 0x51,
	0x12, 0x4f, 0x0d, 0xc5, 0x4a, 0xc7, 0xa7, 0x66,
	0xb2, 0xbc, 0x5c, 0xcf, 0x55, 0x8d, 0x80, 0x27,
}

EWOQKeyBytes are the genesis key bytes used in local networks

Functions

func EWOQKeychain

func EWOQKeychain() *primary.KeychainAdapter

EWOQKeychain returns a keychain containing the EWOQ (genesis) key. This is useful for local development and testing.

func KeychainFromPrivateKey

func KeychainFromPrivateKey(key *secp256k1.PrivateKey) *primary.KeychainAdapter

KeychainFromPrivateKey creates a keychain adapter from a single private key. The returned adapter implements both wallet/keychain.Keychain and c.EthKeychain.

func KeychainFromPrivateKeyBytes

func KeychainFromPrivateKeyBytes(keyBytes []byte) (*primary.KeychainAdapter, error)

KeychainFromPrivateKeyBytes creates a keychain adapter from private key bytes.

func MustVMID

func MustVMID(chainName string) ids.ID

MustVMID is like VMID but panics on error. Useful for initialization of package-level variables.

func VMID

func VMID(chainName string) (ids.ID, error)

VMID computes the VM ID from a chain name using the same algorithm as netrunner. This ensures consistent VM IDs across the ecosystem.

Types

type DeploySubnetResult

type DeploySubnetResult struct {
	SubnetID     ids.ID
	BlockchainID ids.ID
}

DeploySubnetResult contains the result of a full subnet deployment

type Deployer

type Deployer struct {
	// contains filtered or unexported fields
}

Deployer provides a clean interface for deploying subnets and blockchains. It wraps the node wallet functionality with a simpler, more composable API.

func New

func New(opts ...Option) (*Deployer, error)

New creates a new Deployer with the given options

func (*Deployer) AddValidator

func (d *Deployer) AddValidator(
	ctx context.Context,
	subnetID ids.ID,
	nodeID ids.NodeID,
	weight uint64,
	startTime time.Time,
	endTime time.Time,
) (ids.ID, error)

AddValidator adds a validator to a subnet.

func (*Deployer) CreateBlockchain

func (d *Deployer) CreateBlockchain(
	ctx context.Context,
	subnetID ids.ID,
	genesis []byte,
	vmID ids.ID,
	name string,
) (ids.ID, error)

CreateBlockchain creates a new blockchain on the given subnet. Returns the blockchain ID on success.

func (*Deployer) CreateSubnet

func (d *Deployer) CreateSubnet(ctx context.Context, controlKeys []ids.ShortID, threshold uint32) (ids.ID, error)

CreateSubnet creates a new subnet with the given control keys and threshold. Returns the subnet ID on success.

func (*Deployer) DeploySubnet

func (d *Deployer) DeploySubnet(
	ctx context.Context,
	genesis []byte,
	vmID ids.ID,
	chainName string,
	controlKeys []ids.ShortID,
	threshold uint32,
) (*DeploySubnetResult, error)

DeploySubnet creates a subnet and blockchain in one operation. This is the most common deployment pattern.

func (*Deployer) Endpoint

func (d *Deployer) Endpoint() string

Endpoint returns the configured endpoint

func (*Deployer) RemoveValidator

func (d *Deployer) RemoveValidator(
	ctx context.Context,
	subnetID ids.ID,
	nodeID ids.NodeID,
) (ids.ID, error)

RemoveValidator removes a validator from a subnet.

type Option

type Option func(*Deployer)

Option configures a Deployer

func WithEndpoint

func WithEndpoint(uri string) Option

WithEndpoint sets the RPC endpoint URI

func WithKeychain

func WithKeychain(kc *primary.KeychainAdapter) Option

WithKeychain sets the keychain adapter for signing transactions. Use KeychainFromPrivateKey or EWOQKeychain to create one.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the operation timeout

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL