docs(sdk): generate the Go SDK reference from godoc

40 package pages under sdk/go/packages, generated by luxfi/sdk
tools/docgen straight from source comments; the curated Go SDK landing
and guides (transactions, rpc) stay on top. SDK half of docs.lux.network,
generated from code.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-08-22 21:50:17 -07:00
co-authored by Hanzo Dev
parent 89053b72f4
commit cb65d84a99
43 changed files with 6583 additions and 98 deletions
+1 -1
View File
@@ -1 +1 @@
{"pages":["transactions","wallet","rpc"]}
{"pages": ["index", "---Guides---", "transactions", "rpc", "---Package reference---", "packages"]}
@@ -0,0 +1,93 @@
---
title: admin
description: Package admin
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/admin"
```
## Types
### Client
```go
func NewClient(uri string) *Client
```
```go
func (c *Client) Alias(ctx context.Context, endpoint, alias string, options ...rpc.Option) error
```
```go
func (c *Client) AliasChain(ctx context.Context, chain, alias string, options ...rpc.Option) error
```
```go
func (c *Client) DBGet(ctx context.Context, key []byte, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetChainAliases(ctx context.Context, chain string, options ...rpc.Option) ([]string, error)
```
```go
func (c *Client) GetConfig(ctx context.Context, options ...rpc.Option) (interface{}, error)
```
```go
func (c *Client) GetLoggerLevel(
ctx context.Context,
loggerName string,
options ...rpc.Option,
) (map[string]apiadmin.LogAndDisplayLevels, error)
```
```go
func (c *Client) ListVMs(ctx context.Context, options ...rpc.Option) (map[string]apiadmin.VMInfo, error)
```
```go
func (c *Client) Load(ctx context.Context, path string, options ...rpc.Option) error
```
```go
func (c *Client) LoadVMs(ctx context.Context, options ...rpc.Option) (map[ids.ID][]string, map[ids.ID]string, error)
```
```go
func (c *Client) LockProfile(ctx context.Context, options ...rpc.Option) error
```
```go
func (c *Client) MemoryProfile(ctx context.Context, options ...rpc.Option) error
```
```go
func (c *Client) SetLoggerLevel(
ctx context.Context,
loggerName,
logLevel,
displayLevel string,
options ...rpc.Option,
) (map[string]apiadmin.LogAndDisplayLevels, error)
```
```go
func (c *Client) Snapshot(ctx context.Context, path string, since uint64, options ...rpc.Option) (uint64, error)
```
```go
func (c *Client) Stacktrace(ctx context.Context, options ...rpc.Option) error
```
```go
func (c *Client) StartCPUProfiler(ctx context.Context, options ...rpc.Option) error
```
```go
func (c *Client) StopCPUProfiler(ctx context.Context, options ...rpc.Option) error
```
@@ -0,0 +1,580 @@
---
title: aichain
description: dial.go wires the LIVE EVM transport (luxfi/evm/ethclient) into the SDK.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/aichain"
```
dial.go wires the LIVE EVM transport (luxfi/evm/ethclient) into the SDK.
It is behind the `livedial` build tag because luxfi/evm is a heavy node-side
module: with GOWORK=off (the SDK's CI lane) its published version drags in a
luxfi/upgrade pin that does not resolve standalone — the same reason the lux
workspace force-replaces luxfi/upgrade in go.work. The CORE SDK (encoders,
receipt/proof codecs, the Client over the EVMBackend interface, all tests)
therefore compiles and tests with NO luxfi/evm dependency, so default
`GOWORK=off go test ./...` stays green. Build/import this file only inside the
lux workspace (where evm resolves) or with `-tags livedial`:
c, err := aichain.Dial("https://api.lux.network/v1/bc/C/rpc", privKeyHex)
Everywhere else, construct the Client directly from any EVMBackend
(aichain.NewClient) — luxfi/evm/ethclient.Client satisfies that interface, so
callers already holding a node client pass it straight through with no tag.
Package aichain is the developer-facing client SDK for the Lux A-Chain
(Beluga) "Thinking Chains" architecture: on-chain LLM inference and
embeddings settled by quorum.
It wraps the three on-chain entry points:
- the AI bridge precompile (LP-5301) at 0x0300…0004 — Tier-2 large-model
inference, submitted as a committed C-Chain intent and later settled by an
A-Chain quorum receipt (Pattern A submit + Pattern B verify);
- the deterministic in-consensus inference precompile (LP-0303) at
0x0300…0003 — Tier-1 small models run identically by every validator,
answered inside one EVM call;
- the model registry precompile at 0x0300…0002 — governance adoption of the
model the chain treats as canonical.
wire.go pins the SHARED CROSS-CHAIN WIRE SPEC byte-for-byte. The encoders here
MUST produce exactly the preimages the on-chain side hashes/decodes
(chains/aivm/quorum_wire.go ComputeIntentID, chains/aivm/receipts.go
AInferenceReceipt.Encode, and the LP-5301 aivmbridge calldata layout) or an
intent submitted via this SDK will not re-derive to the same intent_id on
A-Chain, and a receipt minted there will not verify against the SDK's
recomputed hash. wire_test.go freezes golden vectors so any drift fails the
build; the optional `crossmodule` build tag cross-checks against the live
chains/aivm encoders.
keccak256 is luxfi/crypto.Keccak256 — the canonical keccak in the Lux stack,
the same primitive the geth-side precompile and the A-Chain settlement engine
use — so a digest computed here equals one computed on either chain
bit-for-bit.
## Functions
### ComputeIntentID
```go
func ComputeIntentID(
cChainID, aChainID, cTxHash common.Hash,
callIndex uint32,
caller common.Address,
modelSpecHash, promptHash common.Hash,
n, threshold uint16,
fee *big.Int,
) common.Hash
```
ComputeIntentID derives the cross-chain intent id from the COMMITTED C-Chain
intent fields, exactly the preimage chains/aivm/quorum_wire.go ComputeIntentID
hashes:
keccak256( DomainIntent ||
c_chain_id(32) || a_chain_id(32) || c_tx_hash(32) || u32be(call_index) ||
caller(20) || model_spec_hash(32) || prompt_hash(32) ||
u16be(N) || u16be(threshold) || u256be(fee,32) )
Every field is fixed-width in this precise order. The A-Chain importer
recomputes this from the delivered fields and rejects the intent unless it
equals the id the C side committed, so any altered field yields a different id.
Note: the submitInferenceIntent CALLER does not pick the intent id — the
precompile derives it from the landed tx hash and call index. The SDK exposes
this so a client that already knows (cTxHash, callIndex) — e.g. after the tx
lands — can reproduce the id locally and correlate the eventual receipt.
### ComputeReceiptId
```go
func ComputeReceiptId(modelID, promptHash, outputHash, paymentHash common.Hash, payer, operator common.Address) common.Hash
```
ComputeReceiptId reproduces the on-chain ProofOfThoughtRegistry.computeReceiptId
for a paid thought:
keccak256( abi.encode(modelId, promptHash, outputHash, paymentHash, payer, operator) )
abi.encode of (bytes32,bytes32,bytes32,bytes32,address,address) is six 32-byte
words (the two addresses left-padded to 32 bytes). This is the deterministic id
under which the receipt is registered on-chain; the SDK computes it so a paid
inference can be located/verified on-chain without a round-trip.
### DecodeGenerateResult
```go
func DecodeGenerateResult(ret []byte) ([]uint32, error)
```
DecodeGenerateResult decodes the inference precompile return: a tight
big-endian uint32 array (prompt+generated tokens). Errors on a non-multiple-of-4
length.
### DecodeSubmitInferenceIntentResult
```go
func DecodeSubmitInferenceIntentResult(ret []byte) (common.Hash, error)
```
DecodeSubmitInferenceIntentResult decodes the aivmbridge Pattern-A return: a
single bytes32 intentID.
### EncodeGenerate
```go
func EncodeGenerate(nNew uint32, promptTokens []uint32) []byte
```
EncodeGenerate builds calldata for the deterministic in-consensus inference
precompile (LP-0303). The frame is tight (NOT Solidity-ABI): the 4-byte
selector, then u32be(nNew), then each prompt token as u32be. This matches
precompile/inference/module.go Run exactly (input[4:8] = nNew, input[8:] =
big-endian uint32 tokens).
### EncodeGetApproved
```go
func EncodeGetApproved(name common.Hash) []byte
```
EncodeGetApproved builds calldata for getApproved(bytes32 name) ->
(uint256 version, bytes32 weightHash).
### EncodeRegisterModel
```go
func EncodeRegisterModel(spec ModelSpec) []byte
```
EncodeRegisterModel builds calldata for the registry's
adopt(bytes32 name, uint256 version, bytes32 weightHash) op. The name is the
spec's canonical id (ModelSpec.RegistryName == Hash), version is the spec
version, and weightHash is the spec's weight commitment. Layout after the
selector: name(32) | version(32, uint256) | weightHash(32).
### EncodeSubmitInferenceIntent
```go
func EncodeSubmitInferenceIntent(modelSpecHash, promptHash common.Hash, n, threshold uint16, fee *big.Int, routing common.Hash) []byte
```
EncodeSubmitInferenceIntent builds calldata for the aivmbridge Pattern-A op
(LP-5301). After the 4-byte selector, a fixed 6-word frame:
[0:32] modelSpecHash (bytes32)
[32:64] promptHash (bytes32)
[64:96] n (uint16, right-aligned; high 30 bytes zero)
[96:128] threshold (uint16, right-aligned; high 30 bytes zero)
[128:160] fee (uint256)
[160:192] routing (bytes32, opaque transport hint)
The precompile rejects a short OR oversized frame and dirty high bytes; this
encoder always emits the exact 196-byte (4+192) well-formed frame.
### EncodeVerifyInferenceReceipt
```go
func EncodeVerifyInferenceReceipt(receipt, proof []byte) ([]byte, error)
```
EncodeVerifyInferenceReceipt builds calldata for the aivmbridge Pattern-B op
(LP-5301). After the 4-byte selector, a tight length-prefixed frame:
[0:2] u16be receiptLen
[2:4] u16be proofLen
[4:4+rl] receipt bytes (canonical 355-byte AInferenceReceipt encoding)
[..] proof bytes (ReceiptRoot|Index|pathLen|path*32)
`receipt` must be a canonical 355-byte encoding (InferenceReceipt.Encode) and
`proof` the LP-5301 proof frame (MerkleProof.EncodeProof). Both are emitted
verbatim; the precompile re-decodes them with the same exact-length discipline.
### PromptHash
```go
func PromptHash(prompt []byte) common.Hash
```
PromptHash is the canonical commitment to a prompt/input: keccak256 of the raw
prompt bytes. The chain treats promptHash as opaque (equality only), so any
stable hash the requester and provider agree on works; this SDK standardises
on keccak of the UTF-8/binary prompt so the same prompt always yields the same
commitment.
### VerifyReceiptInclusion
```go
func VerifyReceiptInclusion(receiptHash common.Hash, proof MerkleProof, root common.Hash) bool
```
VerifyReceiptInclusion checks that receiptHash is included under root at the
proof's Index, re-applying the leaf hash and folding with the siblings,
choosing left/right by the index bit at each level — exactly inverting the
chains/aivm merkleProof/merkleRoot construction. Returns true iff the
recomputed root equals root.
## Types
### ApprovedModel
ApprovedModel is the decoded getApproved return: the adopted version and weight
commitment for a model name (weight == zero means none adopted).
```go
func DecodeGetApprovedResult(ret []byte) (ApprovedModel, error)
```
### BudgetGuard
BudgetGuard enforces a BudgetPolicy across many GenerateWithBudget calls on one
Client, holding the rolling hourly spend. Construct with NewBudgetGuard; it is
safe for concurrent use. The guard is SEPARATE from the Client so the same
client can serve different budgets (one and only one spend ledger per policy).
```go
func NewBudgetGuard(policy BudgetPolicy, now func() time.Time) *BudgetGuard
```
### BudgetPolicy
BudgetPolicy is a CLIENT-SIDE spend guard checked BEFORE any payment is made.
It caps the per-request amount and the rolling per-hour spend, optionally
restricts which models may be paid for, and can require that a PoT receipt be
produced. It is advisory (the client's own discipline), independent of and
complementary to the on-chain escrow.
### Client
Client is the high-level A-Chain (Beluga) inference client over an EVM
JSON-RPC endpoint. It signs and sends txs to the AI precompiles and reads
results.
- Tier-1 (GenerateDeterministic): the deterministic in-consensus inference
precompile (0x0300…0003) answers INSIDE one EVM call — synchronous, no
quorum, small models. Use it via an eth_call (no tx, no gas spent) or a tx
if you want the call recorded.
- Tier-2 (SubmitInferenceIntent / WaitReceipt / Infer): a large model on the
A-Chain settled by an M-of-N quorum — ASYNCHRONOUS. Submit returns an
intent id; the result arrives later as a committed A-Chain receipt the
bridge can verify.
```go
func Dial(rpcURL, privKeyHex string, opts ...Option) (*Client, error)
```
```go
func NewClient(backend EVMBackend, privKeyHex string, opts ...Option) (*Client, error)
```
```go
func (c *Client) From() common.Address
```
```go
func (c *Client) GenerateDeterministic(ctx context.Context, nNew uint32, promptTokens []uint32) ([]uint32, error)
```
```go
func (c *Client) GenerateWithBudget(
ctx context.Context,
model ModelSpec,
prompt []byte,
n, threshold uint16,
reqs PaymentRequirements,
guard *BudgetGuard,
facilitator Facilitator,
signer *ecdsa.PrivateKey,
) (PaidResult, error)
```
```go
func (c *Client) GetModel(ctx context.Context, name common.Hash) (ApprovedModel, error)
```
```go
func (c *Client) GetReceipt(ctx context.Context, intentID common.Hash) (receipt InferenceReceipt, proof MerkleProof, found bool, err error)
```
```go
func (c *Client) Infer(ctx context.Context, model ModelSpec, prompt []byte, n, threshold uint16, fee *big.Int) (InferResult, error)
```
```go
func (c *Client) InferPaid(
ctx context.Context,
model ModelSpec,
prompt []byte,
n, threshold uint16,
reqs PaymentRequirements,
facilitator Facilitator,
signer *ecdsa.PrivateKey,
) (PaidResult, error)
```
```go
func (c *Client) RegisterModel(ctx context.Context, spec ModelSpec) (common.Hash, error)
```
```go
func (c *Client) SubmitInferenceIntent(ctx context.Context, opts SubmitOptions) (intentID common.Hash, txHash common.Hash, err error)
```
```go
func (c *Client) VerifyPaidReceipt(_ context.Context, pot PoTReceipt, settlement SettlementReceipt) (bool, error)
```
```go
func (c *Client) WaitReceipt(ctx context.Context, intentID common.Hash) (InferenceReceipt, error)
```
### EVMBackend
EVMBackend is the SUBSET of luxfi/evm/ethclient.Client this SDK needs: enough
to read chain id / nonce / fees, send a tx, poll a receipt, and make an
eth_call. luxfi/evm/ethclient.Client satisfies it directly (see DialClient),
and a test can supply a mock without a live chain. Keeping the surface minimal
is the decoupling: the SDK depends on these eight methods, not on the whole
node client.
### Facilitator
Facilitator is the x402 verify+settle service. A real implementation calls the
facilitator HTTP endpoint (or settles on-chain itself); MockFacilitator settles
deterministically in-process for tests. Verify is the cheap pre-check (valid
signature, well-formed, binds the requirements, not expired); Settle performs
the transfer and returns the SettlementReceipt carrying the paymentHash.
### InferResult
InferResult is the outcome of a one-call Tier-2 Infer.
### InferenceReceipt
InferenceReceipt is the cross-chain settlement receipt produced by the A-Chain
when a Tier-2 inference task settles. Its canonical encoding is PINNED
byte-for-byte (Encode / ReceiptEncodedLen = 355) and identical to
chains/aivm/receipts.go AInferenceReceipt; its hash is
keccak(DomainReceipt || Encode()), the leaf the receipt_root commits to.
FeePaid is a non-negative *big.Int (nil == zero on the wire). Field order here
is presentation; the WIRE order is fixed by Encode and MUST NOT be reordered.
```go
func DecodeReceipt(b []byte) (InferenceReceipt, error)
```
```go
func (r InferenceReceipt) Completed() bool
```
```go
func (r InferenceReceipt) Encode() []byte
```
```go
func (r InferenceReceipt) Hash() common.Hash
```
### MerkleProof
MerkleProof is an inclusion proof that a receipt_hash leaf is committed under a
ReceiptRoot: the sibling hashes from leaf to root plus the leaf Index (which
fixes left/right at each level). It mirrors chains/aivm MerkleProof and the
LP-5301 proofBytes frame exactly so a proof exported by the A-Chain
(Engine.ExportReceipt) verifies here and vice-versa.
```go
func DecodeProof(b []byte) (MerkleProof, error)
```
```go
func (p MerkleProof) EncodeProof() ([]byte, error)
```
```go
func (p MerkleProof) Verify(r InferenceReceipt) bool
```
### MockFacilitator
MockFacilitator is an in-process Facilitator for tests + local dev. It runs the
real verification (signature recovery, binding, expiry) so tests exercise the
genuine path, then "settles" by returning a deterministic receipt (no chain).
Now is injectable for deterministic expiry tests (zero == time.Now).
```go
func (m *MockFacilitator) Settle(payload PaymentPayload, reqs PaymentRequirements) (SettlementReceipt, error)
```
```go
func (m *MockFacilitator) Verify(payload PaymentPayload, reqs PaymentRequirements) error
```
### ModelSpec
ModelSpec is the SDK's canonical description of a model the chain can serve.
On-chain (chains/aivm, modelregistry) a model is referred to ONLY by its
32-byte weight-commitment hash (an opaque equality key); ModelSpec is the
human-facing identity that hashes DOWN to that key, so a requester naming a
model and a provider advertising one derive the IDENTICAL modelSpecHash from
the IDENTICAL fields.
Fields:
- Name: model identity, e.g. "zenlm/zen-omni" (free-form, UTF-8).
- Version: monotonically increasing version the registry adopts.
- WeightCommit: the 32-byte commitment to the exact weights (a content
hash of the weight file / a Merkle root over shards). This is the
load-bearing field — it pins WHICH weights are canonical. If you already
have the on-chain commitment, set it directly; Name/Version then only
decorate it.
- Quantization: the inference format that makes the result deterministic,
e.g. "int8", "bf16-kat". Different quantizations of the same weights are
different specs (they produce different canonical outputs).
```go
func (m ModelSpec) Hash() common.Hash
```
```go
func (m ModelSpec) RegistryName() common.Hash
```
### Option
Option configures a Client.
```go
func WithChainID(id *big.Int) Option
```
```go
func WithPolling(interval, timeout time.Duration) Option
```
```go
func WithReceiptStore(s ReceiptStore) Option
```
### PaidResult
PaidResult is the outcome of an InferPaid call: the inference result joined to
its x402 settlement and the PoT record that binds them on-chain.
### PaymentPayload
PaymentPayload is the signed authorization the client sends in the X-PAYMENT
header. It is an EIP-3009-shaped transferWithAuthorization payload: a signature
over (from, to, value, validAfter, validBefore, nonce) bound to (token, chain
id) via the EIP-712 domain. The facilitator recovers `from` from the signature
and settles the transfer.
```go
func BuildPaymentPayload(signer *ecdsa.PrivateKey, reqs PaymentRequirements) (PaymentPayload, error)
```
```go
func (p PaymentPayload) PaymentHash() common.Hash
```
```go
func (p PaymentPayload) RecoverPayer() (common.Address, error)
```
### PaymentRequirements
PaymentRequirements is what a resource server returns in its HTTP 402 response:
what it costs, in what token, on what network, to whom, and until when. The
client turns this into a signed PaymentPayload.
### PoTReceipt
PoTReceipt is the SDK's view of a Proof-of-Thought record: the join of a paid
x402 settlement (PaymentHash), a model output (OutputHash), and the producing
proof (QuorumProof), keyed by the on-chain ReceiptId. It is what a caller
registers via ProofOfThoughtRegistry.register and what VerifyPaidReceipt checks
against a SettlementReceipt.
```go
func (r PoTReceipt) ReceiptID() common.Hash
```
### ReceiptStore
ReceiptStore reads committed A-Chain receipts for the high-level WaitReceipt /
GetReceipt convenience. It is intentionally SEPARATE from EVMBackend (the
settlement read path is not the EVM tx path): an implementation may poll the
A-Chain RPC directly, or watch the aivmbridge receipt-root checkpoint and the
A->C export. ReceiptByIntent returns the committed receipt + its inclusion
proof for an intent id, or (false) if not yet settled.
The SDK ships no live ReceiptStore (it depends on the node-local A-Chain RPC
shape, out of scope here); callers wire their own, and tests use a fake. This
keeps the SDK decoupled from any single A-Chain transport while still offering
the one-call Infer convenience.
### SettlementReceipt
SettlementReceipt is what the facilitator returns after Verify+Settle — the
X-PAYMENT-RESPONSE the resource server echoes. PaymentHash is the EIP-712 digest
of the authorization (the x402&lt;->PoT join key); TxHash is the on-chain
settlement tx (zero for an off-chain/escrowed settlement).
### SubmitOptions
SubmitOptions parametrise a Tier-2 inference intent.
### VerifyResult
VerifyResult is the decoded aivmbridge Pattern-B return:
(bytes32 intentID, bytes32 canonicalOutputHash, uint8 status) packed as 3
words (96 bytes).
```go
func DecodeVerifyInferenceReceiptResult(ret []byte) (VerifyResult, error)
```
### X402Scheme
X402Scheme is the x402 payment scheme. `exact` is a fixed per-request charge;
`upto` caps a charge that the facilitator may settle for less (e.g. metered by
actual tokens). The signed authorization is identical; the scheme tells the
facilitator how to interpret MaxAmount vs the settled amount.
@@ -0,0 +1,491 @@
---
title: application
description: Package application provides application context and configuration management.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/application"
```
Package application provides application context and configuration management.
## Types
### Downloader
Downloader is a generic interface for performing highly testable downloads. All methods here involve
external http requests. To write tests using these functions, provide a mocked version of this
interface to your application object.
```go
func NewDownloader() Downloader
```
### LastActions
### Lux
```go
func New() *Lux
```
```go
func (app *Lux) AddDefaultBlockchainRPCsToSidecar(
blockchainName string,
network models.Network,
nodeURIs []string,
) (bool, error)
```
```go
func (app *Lux) BlockchainConfigExists(blockchainName string) bool
```
```go
func (app *Lux) CaptureYesNo(prompt string) (bool, error)
```
```go
func (app *Lux) ChainConfigExists(chainName string) bool
```
```go
func (app *Lux) ChainConfigFileExists(chainName string) bool
```
```go
func (app *Lux) ClustersConfigExists() bool
```
```go
func (app *Lux) ConfigFileExists() bool
```
```go
func (app *Lux) CopyGenesisFile(inputFilename string, chainName string) error
```
```go
func (app *Lux) CopyKeyFile(inputFilename string, keyName string) error
```
```go
func (app *Lux) CopyVMBinary(inputFilename string, chainName string) error
```
```go
func (app *Lux) CreateElasticChainConfig(chainName string, es *models.ElasticChainConfig) error
```
```go
func (app *Lux) CreateSidecar(sc *models.Sidecar) error
```
```go
func (app *Lux) GenesisExists(chainName string) bool
```
```go
func (app *Lux) GetAnsibleInventoryDirPath(clusterName string) string
```
```go
func (app *Lux) GetBaseDir() string
```
```go
func (app *Lux) GetBasePath() string
```
```go
func (app *Lux) GetBlockchainNamesOnNetwork(network models.Network, onlySOV bool) ([]string, error)
```
```go
func (app *Lux) GetChainConfigDir() string
```
```go
func (app *Lux) GetChainConfigPath(chainName string) string
```
```go
func (app *Lux) GetChainDir() string
```
```go
func (app *Lux) GetChainsDir() string
```
```go
func (app *Lux) GetClusterConfig(clusterName string) (map[string]interface{}, error)
```
```go
func (app *Lux) GetClusterNetwork(clusterName string) (models.Network, error)
```
```go
func (app *Lux) GetConfigPath() string
```
```go
func (app *Lux) GetCurrentPluginsDir() string
```
```go
func (app *Lux) GetCustomVMDir() string
```
```go
func (app *Lux) GetCustomVMPath(chainName string) string
```
```go
func (app *Lux) GetDevDir() string
```
```go
func (app *Lux) GetDownloader() Downloader
```
```go
func (app *Lux) GetEVMBinDir() string
```
```go
func (app *Lux) GetElasticChainConfigPath(chainName string) string
```
```go
func (app *Lux) GetGenesisPath(chainName string) string
```
```go
func (app *Lux) GetKey(keyName string) (string, error)
```
```go
func (app *Lux) GetKeyDir() string
```
```go
func (app *Lux) GetKeyPath(keyName string) string
```
```go
func (app *Lux) GetLPMBaseDir() string
```
```go
func (app *Lux) GetLPMLog() string
```
```go
func (app *Lux) GetLPMPluginDir() string
```
```go
func (app *Lux) GetLPMVMPath(vmid string) string
```
```go
func (app *Lux) GetLocalClusterDir(clusterName string) string
```
```go
func (app *Lux) GetLocalClustersDir() string
```
```go
func (app *Lux) GetLocalRelayerConfigPath() string
```
```go
func (app *Lux) GetLocalRelayerLogPath(network models.Network) string
```
```go
func (app *Lux) GetLocalRelayerRunPath(network models.Network) string
```
```go
func (app *Lux) GetLocalRelayerStorageDir(network models.Network) string
```
```go
func (app *Lux) GetLogDir() string
```
```go
func (app *Lux) GetLuxBinDir() string
```
```go
func (*Lux) GetLuxCompatibilityURL() string
```
```go
func (app *Lux) GetLuxdChainConfigPath(chainName string) string
```
```go
func (app *Lux) GetLuxdNodeConfigPath(chainName string) string
```
```go
func (app *Lux) GetLuxgoBinDir() string
```
```go
func (app *Lux) GetMonitoringInventoryDir(clusterName string) string
```
```go
func (app *Lux) GetNetDir() string
```
```go
func (app *Lux) GetNetworkFromSidecarNetworkName(name string) (models.Network, error)
```
```go
func (app *Lux) GetNetworkPluginsDir(networkType string) string
```
```go
func (app *Lux) GetNodesDir() string
```
```go
func (app *Lux) GetPerNodeBlockchainConfig(chainName string) map[string]interface{}
```
```go
func (app *Lux) GetPluginsDir() string
```
```go
func (app *Lux) GetReposDir() string
```
```go
func (app *Lux) GetRunDir() string
```
```go
func (app *Lux) GetRunFile() string
```
```go
func (app *Lux) GetSidecarNames() ([]string, error)
```
```go
func (app *Lux) GetSidecarPath(chainName string) string
```
```go
func (app *Lux) GetSnapshotPath(snapshotName string) string
```
```go
func (app *Lux) GetSnapshotsDir() string
```
```go
func (*Lux) GetTmpPluginDir() string
```
```go
func (app *Lux) GetTokenName(chainName string) string
```
```go
func (app *Lux) GetUpgradeBytesFilePath(chainName string) string
```
```go
func (app *Lux) GetUpgradeBytesFilepath(chainName string) string
```
```go
func (app *Lux) GetVersion() string
```
```go
func (app *Lux) IsLocalNetworkRunning() bool
```
```go
func (app *Lux) IsPathProtected(path string) bool
```
```go
func (app *Lux) KeyExists(keyName string) bool
```
```go
func (app *Lux) ListClusterNames() ([]string, error)
```
```go
func (app *Lux) LoadClusterNodeConfig(clusterName string, nodeID string) (map[string]interface{}, error)
```
```go
func (app *Lux) LoadClustersConfig() (map[string]interface{}, error)
```
```go
func (app *Lux) LoadConfig() (types.Config, error)
```
```go
func (app *Lux) LoadElasticChainConfig(chainName string) (models.ElasticChainConfig, error)
```
```go
func (app *Lux) LoadEvmGenesis(chainName string) (core.Genesis, error)
```
```go
func (app *Lux) LoadRawChainConfig(chainName string) ([]byte, error)
```
```go
func (app *Lux) LoadRawGenesis(chainName string) ([]byte, error)
```
```go
func (app *Lux) LoadRawLuxdChainConfig(chainName string) ([]byte, error)
```
```go
func (app *Lux) LoadRawNetworkUpgrades(chainName string) ([]byte, error)
```
```go
func (app *Lux) LoadSidecar(chainName string) (models.Sidecar, error)
```
```go
func (app *Lux) LuxdChainConfigExists(chainName string) bool
```
```go
func (app *Lux) LuxdNodeConfigExists(chainName string) bool
```
```go
func (app *Lux) NetworkUpgradeExists(chainName string) bool
```
```go
func (app *Lux) ProtectedDirectories() []string
```
```go
func (app *Lux) ReadLastActionsFile() (*LastActions, error)
```
```go
func (app *Lux) ReadLockUpgradeFile(chainName string) ([]byte, error)
```
```go
func (app *Lux) ReadUpgradeFile(chainName string) ([]byte, error)
```
```go
func (app *Lux) ResetPluginsDir() error
```
```go
func (app *Lux) SafeRemoveAll(path string) error
```
```go
func (app *Lux) Setup(baseDir string, log luxlog.Logger, conf *config.Config, prompt Prompter, downloader Downloader)
```
```go
func (app *Lux) SidecarExists(chainName string) bool
```
```go
func (app *Lux) UpdateSidecar(sc *models.Sidecar) error
```
```go
func (app *Lux) UpdateSidecarElasticChain(
sc *models.Sidecar,
network models.Network,
chainID ids.ID,
assetID ids.ID,
pchainTXID ids.ID,
tokenName string,
tokenSymbol string,
) error
```
```go
func (app *Lux) UpdateSidecarElasticChainPartialTx(
sc *models.Sidecar,
network models.Network,
txName string,
txID ids.ID,
) error
```
```go
func (app *Lux) UpdateSidecarNetworks(
sc *models.Sidecar,
network models.Network,
chainID ids.ID,
blockchainID ids.ID,
) error
```
```go
func (app *Lux) UpdateSidecarPermissionlessValidator(
sc *models.Sidecar,
network models.Network,
nodeID string,
txID ids.ID,
) error
```
```go
func (app *Lux) WriteConfigFile(data []byte) error
```
```go
func (app *Lux) WriteGenesisFile(chainName string, genesisBytes []byte) error
```
```go
func (app *Lux) WriteLastActionsFile(acts *LastActions)
```
```go
func (app *Lux) WriteLockUpgradeFile(chainName string, bytes []byte) error
```
```go
func (app *Lux) WriteSidecarFile(sc *models.Sidecar) error
```
```go
func (app *Lux) WriteUpgradeFile(chainName string, bytes []byte) error
```
### Prompter
Prompter is an alias for the prompts.Prompter interface
@@ -0,0 +1,183 @@
---
title: blockchain
description: Package blockchain provides blockchain configuration and genesis utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/blockchain"
```
Package blockchain provides blockchain configuration and genesis utilities.
## Types
### Blockchain
Blockchain represents a Lux blockchain
### BlockchainStatus
BlockchainStatus defines the status of a blockchain
### BlockchainType
BlockchainType defines the type of blockchain
### Builder
Builder handles blockchain creation and deployment
```go
func NewBuilder(logger log.Logger) *Builder
```
```go
func (b *Builder) CreateBlockchain(ctx context.Context, params *CreateParams) (*Blockchain, error)
```
```go
func (b *Builder) Deploy(ctx context.Context, blockchain *Blockchain, network *network.Network) error
```
```go
func (b *Builder) GenerateGenesis(params *GenesisParams) ([]byte, error)
```
```go
func (b *Builder) GetBlockchain(blockchainID string) (*Blockchain, error)
```
```go
func (b *Builder) ListBlockchains() []*Blockchain
```
```go
func (b *Builder) ValidateConfig(config []byte) error
```
### CreateParams
CreateParams defines parameters for creating a blockchain
### GenesisAccount
GenesisAccount defines an account in genesis
### GenesisParams
GenesisParams defines parameters for genesis generation
### GenesisValidator
GenesisValidator defines a validator in the genesis
Uses simplified fields for genesis configuration
### L1Params
L1Params defines parameters for L1 creation
### L2Config
L2Config defines L2-specific configuration
### L2Params
L2Params defines parameters for L2 creation
### L3Config
L3Config defines L3-specific configuration
### L3Params
L3Params defines parameters for L3 creation
### Metrics
Metrics tracks blockchain performance metrics
```go
func NewMetrics() *Metrics
```
```go
func (m *Metrics) GetSnapshot() map[string]interface{}
```
```go
func (m *Metrics) RecordBlock(blockTime time.Time)
```
```go
func (m *Metrics) RecordTransaction(success bool)
```
```go
func (m *Metrics) UpdateNetwork(peers int, latency time.Duration)
```
```go
func (m *Metrics) UpdateResources(cpu float64, memory, disk uint64)
```
```go
func (m *Metrics) UpdateTPS(tps float64)
```
### Net
Net represents a blockchain network with validator management capabilities
As above, so below - unified across all network layers (primary, L1, L2, L3)
```go
func (s *Net) InitializeProofOfAuthority(
log interface{},
network interface{},
privateKey string,
aggregatorLogger interface{},
validatorManagerAddress string,
v2_0_0 bool,
signatureAggregatorEndpoint string,
) error
```
```go
func (s *Net) InitializeProofOfStake(
log interface{},
network interface{},
privateKey string,
aggregatorLogger interface{},
posParams interface{},
managerAddress string,
signatureAggregatorEndpoint string,
) error
```
### VMType
VMType defines the virtual machine type
### Validator
Validator is an alias for backward compatibility
@@ -0,0 +1,41 @@
---
title: chain
description: Package chain provides blockchain transaction and block types.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/chain"
```
Package chain provides blockchain transaction and block types.
## Types
### Action
Action represents an action within a transaction
### Block
Block represents a blockchain block
### Output
Output represents a transaction output
### Result
Result represents the result of transaction execution
### Transaction
Transaction represents a blockchain transaction
@@ -0,0 +1,206 @@
---
title: chainconfig
description: Package chainconfig provides chain configuration utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/chainconfig"
```
Package chainconfig provides chain configuration utilities.
## Functions
### CreateAirdropGenesis
```go
func CreateAirdropGenesis(
chainConfig *params.ChainConfig,
airdropAddresses []common.Address,
airdropAmount *big.Int,
) *core.Genesis
```
CreateAirdropGenesis creates a genesis with airdrop allocations
### CreateDevGenesis
```go
func CreateDevGenesis(chainID *big.Int) *core.Genesis
```
CreateDevGenesis creates a genesis suitable for development
### DefaultChainConfig
```go
func DefaultChainConfig() *params.ChainConfig
```
DefaultChainConfig returns the default EVM chain configuration
### DefaultGenesis
```go
func DefaultGenesis() *core.Genesis
```
DefaultGenesis creates a default genesis configuration
### GetPresetChainConfig
```go
func GetPresetChainConfig(preset string, chainID *big.Int) *params.ChainConfig
```
GetPresetChainConfig returns a preset chain configuration by name
### LocalChainConfig
```go
func LocalChainConfig(chainID *big.Int) *params.ChainConfig
```
LocalChainConfig returns a chain configuration suitable for local development
### MainnetChainConfig
```go
func MainnetChainConfig(chainID *big.Int) *params.ChainConfig
```
MainnetChainConfig returns a chain configuration suitable for mainnet
### ParseGenesis
```go
func ParseGenesis(data []byte) (*core.Genesis, error)
```
ParseGenesis parses genesis from JSON bytes
### TestnetChainConfig
```go
func TestnetChainConfig(chainID *big.Int) *params.ChainConfig
```
TestnetChainConfig returns a chain configuration suitable for testnet
### ValidateGenesis
```go
func ValidateGenesis(genesis *core.Genesis) error
```
ValidateGenesis validates a genesis configuration
## Types
### ChainConfigBuilder
ChainConfigBuilder helps construct EVM chain configurations
```go
func NewChainConfigBuilder() *ChainConfigBuilder
```
```go
func (b *ChainConfigBuilder) Build() *params.ChainConfig
```
```go
func (b *ChainConfigBuilder) GetAllowFeeRecipients() bool
```
```go
func (b *ChainConfigBuilder) GetFeeConfig() interface{}
```
```go
func (b *ChainConfigBuilder) GetNetworkUpgrades() map[string]interface{}
```
```go
func (b *ChainConfigBuilder) GetPrecompiles() map[string]interface{}
```
```go
func (b *ChainConfigBuilder) WithAllowFeeRecipients(allow bool) *ChainConfigBuilder
```
```go
func (b *ChainConfigBuilder) WithChainID(chainID *big.Int) *ChainConfigBuilder
```
```go
func (b *ChainConfigBuilder) WithFeeConfig(feeConfig interface{}) *ChainConfigBuilder
```
```go
func (b *ChainConfigBuilder) WithNetworkUpgrade(name string, timestamp *big.Int) *ChainConfigBuilder
```
```go
func (b *ChainConfigBuilder) WithPrecompile(address common.Address, config interface{}) *ChainConfigBuilder
```
### GenesisBuilder
GenesisBuilder helps construct EVM genesis configurations
```go
func NewGenesisBuilder() *GenesisBuilder
```
```go
func (b *GenesisBuilder) Build() *core.Genesis
```
```go
func (b *GenesisBuilder) ToJSON() ([]byte, error)
```
```go
func (b *GenesisBuilder) WithAllocation(address common.Address, balance *big.Int) *GenesisBuilder
```
```go
func (b *GenesisBuilder) WithAllocations(allocations map[common.Address]*big.Int) *GenesisBuilder
```
```go
func (b *GenesisBuilder) WithChainConfig(config *params.ChainConfig) *GenesisBuilder
```
```go
func (b *GenesisBuilder) WithContract(address common.Address, balance *big.Int, code []byte, storage map[common.Hash]common.Hash) *GenesisBuilder
```
```go
func (b *GenesisBuilder) WithExtraData(extraData []byte) *GenesisBuilder
```
```go
func (b *GenesisBuilder) WithGasLimit(gasLimit uint64) *GenesisBuilder
```
```go
func (b *GenesisBuilder) WithTimestamp(timestamp uint64) *GenesisBuilder
```
@@ -0,0 +1,38 @@
---
title: config
description: Package config provides SDK configuration structures and utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/config"
```
Package config provides SDK configuration structures and utilities.
## Types
### Config
Config represents the SDK configuration
```go
func Default() *Config
```
### NetworkConfig
NetworkConfig represents network configuration
```go
func DefaultNetworkConfig() *NetworkConfig
```
```go
func (nc *NetworkConfig) ChainID() *big.Int
```
@@ -0,0 +1,122 @@
---
title: configspec
description: Package configspec provides the embedded luxd configuration specification.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/configspec"
```
Package configspec provides the embedded luxd configuration specification.
Deprecated: Use github.com/luxfi/config/spec instead. This package will be
removed in a future release. The canonical location for configspec is now
github.com/luxfi/config/spec.
This is a snapshot of the node's configuration spec for use by SDK consumers
without requiring a dependency on the node package.
The spec.json file is generated from the node using:
go run github.com/luxfi/node/cmd/config dump-spec --format=json > spec.json
To regenerate, run:
go generate ./...
## Functions
### AllKeys
```go
func AllKeys() []string
```
AllKeys returns all known configuration keys.
### KnownKey
```go
func KnownKey(key string) bool
```
KnownKey checks if a key is a valid configuration flag.
### NodeVersion
```go
func NodeVersion() string
```
NodeVersion returns the node version this spec was generated from.
### Version
```go
func Version() string
```
Version returns the spec version.
## Types
### Category
Category groups related configuration flags.
### ConfigSpec
ConfigSpec is the complete specification of all luxd configuration flags.
```go
func MustSpec() *ConfigSpec
```
```go
func Spec() (*ConfigSpec, error)
```
```go
func (s *ConfigSpec) AllKeys() []string
```
```go
func (s *ConfigSpec) DeprecatedFlags() []FlagSpec
```
```go
func (s *ConfigSpec) FlagsByCategory(cat Category) []FlagSpec
```
```go
func (s *ConfigSpec) GetFlag(key string) *FlagSpec
```
```go
func (s *ConfigSpec) KnownKey(key string) bool
```
### Constraints
Constraints defines validation rules for a flag.
### FlagSpec
FlagSpec describes a single configuration flag.
### FlagType
FlagType represents the type of a configuration flag.
@@ -0,0 +1,31 @@
---
title: connectclient
description: Package connectclient
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/connect"
```
## Types
### SetRouteHeaderInterceptor
SetRouteHeaderInterceptor sets the api routing header for connect-rpc
requests
```go
func (s SetRouteHeaderInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc
```
```go
func (SetRouteHeaderInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc
```
```go
func (s SetRouteHeaderInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc
```
@@ -0,0 +1,15 @@
---
title: constants
description: Package constants provides SDK-specific constants.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/constants"
```
Package constants provides SDK-specific constants.
Many constants are re-exported from github.com/luxfi/constants for convenience.
@@ -0,0 +1,432 @@
---
title: contract
description: Package contract provides smart contract interaction utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/contract"
```
Package contract provides smart contract interaction utilities.
## Functions
### CallToMethod
```go
func CallToMethod(
rpcURL string,
contractAddress crypto.Address,
methodSpec string,
params ...interface{},
) ([]interface{}, error)
```
### ContractAddressIsInGenesisData
```go
func ContractAddressIsInGenesisData(
genesisData []byte,
contractAddress crypto.Address,
) (bool, error)
```
### DebugTraceCall
```go
func DebugTraceCall(
rpcURL string,
from crypto.Address,
privateKey string,
contractAddress crypto.Address,
payment *big.Int,
methodSpec string,
params ...interface{},
) (map[string]interface{}, error)
```
### DeployContract
```go
func DeployContract(
rpcURL string,
privateKey string,
binBytes []byte,
methodSpec string,
params ...interface{},
) (crypto.Address, error)
```
### DeployERC20
```go
func DeployERC20(
rpcURL string,
privateKey string,
symbol string,
funded crypto.Address,
supply *big.Int,
) (crypto.Address, error)
```
### GetBlockchainAirdropKeyInfo
```go
func GetBlockchainAirdropKeyInfo(
app *application.Lux,
network models.Network,
blockchainName string,
genesisData []byte,
) (string, string, string, error)
```
GetBlockchainAirdropKeyInfo looks for known private keys inside a given genesis,
giving preference to the ones expected to be default.
It searches for:
1) default CLI allocation key for blockchains
2) ewoq
3) all other stored keys managed by CLI
Returns address + private key when found.
### GetBlockchainDesc
```go
func GetBlockchainDesc(
chainSpec ChainSpec,
) (string, error)
```
### GetBlockchainEndpoints
```go
func GetBlockchainEndpoints(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
promptForRPCEndpoint bool,
promptForWSEndpoint bool,
) (string, string, error)
```
### GetBlockchainGenesis
```go
func GetBlockchainGenesis(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) ([]byte, error)
```
GetBlockchainGenesis gets the deployed blockchain genesis.
### GetBlockchainID
```go
func GetBlockchainID(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) (ids.ID, error)
```
### GetBlockchainIDFromAlias
```go
func GetBlockchainIDFromAlias(endpoint string, alias string) (ids.ID, error)
```
GetBlockchainIDFromAlias retrieves a blockchain ID from its alias using the info API.
### GetBlockchainTx
```go
func GetBlockchainTx(endpoint string, blockchainID ids.ID) (*txs.CreateChainTx, error)
```
GetBlockchainTx retrieves a blockchain CreateChainTx from the network.
### GetCChainWarpInfo
```go
func GetCChainWarpInfo(
app *application.Lux,
network models.Network,
) (string, string, error)
```
### GetContractOwner
```go
func GetContractOwner(
rpcURL string,
contractAddress crypto.Address,
) (crypto.Address, error)
```
GetContractOwner gets owner for https://docs.openzeppelin.com/contracts/2.x/api/ownership#Ownable-owner contracts
### GetDefaultBlockchainAirdropKeyInfo
```go
func GetDefaultBlockchainAirdropKeyInfo(
app *application.Lux,
blockchainName string,
) (string, string, string, error)
```
GetDefaultBlockchainAirdropKeyInfo returns information for the blockchain default allocation key.
If found, returns key name, address, private key.
### GetEVMChainGenesisNativeMinterAdmin
```go
func GetEVMChainGenesisNativeMinterAdmin(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) (bool, bool, string, string, string, error)
```
### GetEVMChainGenesisNativeMinterManager
```go
func GetEVMChainGenesisNativeMinterManager(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) (bool, bool, string, string, string, error)
```
### GetEVMChainGenesisSupply
```go
func GetEVMChainGenesisSupply(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) (*big.Int, error)
```
### GetEVMChainPrefundedKey
```go
func GetEVMChainPrefundedKey(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) (string, string, error)
```
GetEVMChainPrefundedKey gets the deployed blockchain genesis, and then looks for known
private keys inside it.
Returns address + private key when found.
### GetNetworkID
```go
func GetNetworkID(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
) (ids.ID, error)
```
### GetSmartContractCallResult
```go
func GetSmartContractCallResult[T any](methodName string, out []interface{}) (T, error)
```
### GetWarpInfo
```go
func GetWarpInfo(
app *application.Lux,
network models.Network,
chainSpec ChainSpec,
promptForRegistry bool,
promptForMessenger bool,
defaultToLatestReleasedMessenger bool,
) (string, string, error)
```
### ParseSpec
```go
func ParseSpec(
esp string,
indexedFields []int,
constructor bool,
event bool,
paid bool,
view bool,
params ...interface{},
) (string, string, error)
```
### PromptChain
```go
func PromptChain(
app *application.Lux,
network models.Network,
prompt string,
blockchainNameToAvoid string,
chainSpec *ChainSpec,
) (bool, error)
```
### SearchForManagedKey
```go
func SearchForManagedKey(
app *application.Lux,
network models.Network,
address string,
includeEwoq bool,
) (bool, string, string, string, error)
```
### TransferOwnership
```go
func TransferOwnership(
rpcURL string,
contractAddress crypto.Address,
ownerPrivateKey string,
newOwner crypto.Address,
) error
```
### TxToMethod
```go
func TxToMethod(
rpcURL string,
generateRawTxOnly bool,
from crypto.Address,
privateKey string,
contractAddress crypto.Address,
payment *big.Int,
description string,
errorSignatureToError map[string]error,
methodSpec string,
params ...interface{},
) (*types.Transaction, *types.Receipt, error)
```
TxToMethod gets method name and types from [methodsSpec], then calls it
at the smart contract [contractAddress] with the given [params].
Also sends [payment] tokens to it.
### TxToMethodWithWarpMessage
```go
func TxToMethodWithWarpMessage(
rpcURL string,
generateRawTxOnly bool,
from crypto.Address,
privateKey string,
contractAddress crypto.Address,
warpMessage *luxWarp.Envelope,
payment *big.Int,
description string,
errorSignatureToError map[string]error,
methodSpec string,
params ...interface{},
) (*types.Transaction, *types.Receipt, error)
```
TxToMethodWithWarpMessage gets method name and types from [methodsSpec], then calls it
at the smart contract [contractAddress] with the given [params].
Sends [warpMessage] on the same call, whose signature is
going to be verified previously to pass it to the method.
Also sends [payment] tokens to it.
### UnpackLog
```go
func UnpackLog(
eventSpec string,
indexedFields []int,
log types.Log,
event interface{},
) error
```
## Types
### ChainSpec
```go
func (cs *ChainSpec) AddToCmd(
cmd *cobra.Command,
goalFmt string,
)
```
```go
func (cs *ChainSpec) CheckMutuallyExclusiveFields() error
```
```go
func (cs *ChainSpec) Defined() bool
```
```go
func (cs *ChainSpec) SetEnabled(
blockchainNameFlagEnabled bool,
cChainFlagEnabled bool,
pChainFlagEnabled bool,
xChainFlagEnabled bool,
blockchainIDFlagEnabled bool,
)
```
```go
func (cs *ChainSpec) SetFlagNames(
blockchainNameFlagName string,
cChainFlagName string,
pChainFlagName string,
xChainFlagName string,
blockchainIDFlagName string,
)
```
### PrivateKeyFlags
```go
func (pkf *PrivateKeyFlags) AddToCmd(
cmd *cobra.Command,
goal string,
)
```
```go
func (pkf *PrivateKeyFlags) GetPrivateKey(
app *application.Lux,
genesisPrivateKey string,
) (string, error)
```
```go
func (pkf *PrivateKeyFlags) SetFlagNames(
privateKeyFlagName string,
keyFlagName string,
genesisKeyFlagName string,
)
```
@@ -0,0 +1,78 @@
---
title: crypto
description: Package crypto provides functionality for interacting with Ed25519 public and private keys.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/crypto"
```
Package crypto provides functionality for interacting with Ed25519
public and private keys. Package crypto uses the "crypto/ed25519"
package from Go's standard library for the underlying cryptography.
## Functions
### Address
```go
func Address(hrp string, p PublicKey) string
```
Address returns a Bech32 address from hrp and p.
This function uses node's FormatBech32 function.
Returns empty string if formatting fails.
### Verify
```go
func Verify(msg []byte, p PublicKey, s Signature) bool
```
Verify returns whether s is a valid signature of msg by p.
## Types
### PrivateKey
```go
func GeneratePrivateKey() (PrivateKey, error)
```
```go
func HexToKey(key string) (PrivateKey, error)
```
```go
func LoadKey(filename string) (PrivateKey, error)
```
```go
func (p PrivateKey) PublicKey() PublicKey
```
```go
func (p PrivateKey) Save(filename string) error
```
```go
func (p PrivateKey) ToHex() string
```
### PublicKey
```go
func ParseAddress(hrp, saddr string) (PublicKey, error)
```
### Signature
```go
func Sign(msg []byte, pk PrivateKey) Signature
```
@@ -0,0 +1,357 @@
---
title: evm
description: Package evm provides EVM chain interaction and transaction utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/evm"
```
Package evm provides EVM chain interaction and transaction utilities.
## Functions
### CalculateEvmFeeInLux
```go
func CalculateEvmFeeInLux(gasUsed uint64, gasPrice *big.Int) float64
```
### ConvertToNanoLux
```go
func ConvertToNanoLux(balance *big.Int) *big.Int
```
ConvertToNanoLux converts a balance in Lux to NanoLux.
It adds 0.5 to the balance before dividing by 1e9 to round
it to the nearest whole number.
### ExtractWarpMessageFromLogs
```go
func ExtractWarpMessageFromLogs(
logs []*types.Log,
) (*warp.Message, error)
```
ExtractWarpMessageFromLogs gets first unsigned warp message contained in [logs].
### ExtractWarpMessageFromReceipt
```go
func ExtractWarpMessageFromReceipt(
receipt *types.Receipt,
) (*warp.Message, error)
```
ExtractWarpMessageFromReceipt gets first unsigned warp message contained in [receipt].
### GetClientWithoutScheme
```go
func GetClientWithoutScheme(rpcURL string) (ethclient.Client, string, error)
```
GetClientWithoutScheme tries to connect an ethclient to a rpc url without scheme,
by trying out different possible schemes: ws, wss, https, http
### GetErrorFromTrace
```go
func GetErrorFromTrace(
trace map[string]interface{},
functionSignatureToError map[string]error,
) (error, error)
```
GetErrorFromTrace returns golang error associated with [trace] by using [functionSignatureToError]
to map function signatures to evm function selectors in [trace], and then to golang errors.
First returned error is the mapped error, second error is for errors obtained
executing this function.
### GetEventFromLogs
```go
func GetEventFromLogs[T any](logs []*types.Log, parser func(log types.Log) (T, error)) (T, error)
```
GetEventFromLogs returns the first log in 'logs' that is successfully parsed by 'parser'.
### GetFunctionSelector
```go
func GetFunctionSelector(functionSignature string) string
```
GetFunctionSelector returns evm function selector code for the given function signature.
EVM maps function and error signatures into codes that are then used in traces.
### GetTxTrace
```go
func GetTxTrace(rpcURL string, txID string) (map[string]interface{}, error)
```
GetTxTrace returns a trace for the given [txID] on [rpcURL].
Supports [repeatsOnFailure] failures.
### GetWarpMessagesFromLogs
```go
func GetWarpMessagesFromLogs(
logs []*types.Log,
) []*warp.Message
```
GetWarpMessagesFromLogs gets all unsigned warp messages contained in [logs].
### HasScheme
```go
func HasScheme(rpcURL string) (bool, error)
```
### HexToAddress
```go
func HexToAddress(s string) common.Address
```
HexToAddress converts hex string to common.Address (geth type)
### PrivateKeyToAddress
```go
func PrivateKeyToAddress(privateKey string) (crypto.Address, error)
```
PrivateKeyToAddress returns the public address associated with [privateKey].
### TransactionError
```go
func TransactionError(tx *types.Transaction, err error, msg string, args ...interface{}) error
```
TransactionError transforms a tx operation error into an error that contains:
- the [err] itself
- the [tx] hash (or information on the tx not being submitted)
- another descriptive [msg], together with formatted [args]
### TxDump
```go
func TxDump(description string, tx *types.Transaction) (string, error)
```
TxDump dumps a [tx] hexa description, for it to be separately issued using external tools.
## Types
### Client
Client wraps over ethclient for calls used by SDK. Features:
- finds out url scheme in case it is missing, to connect to ws/wss/http/https
- repeats to try to recover from failures, generating its own context for each call
- logs rpc url in case of failure
- receives addresses and private keys as strings
```go
func GetClient(rpcURL string) (Client, error)
```
```go
func (client Client) BlockByNumber(n *big.Int) (*types.Block, error)
```
```go
func (client Client) BlockNumber() (uint64, error)
```
```go
func (client Client) CalculateTxParams(
address string,
) (*big.Int, *big.Int, uint64, error)
```
```go
func (client Client) ChainConfig() (*evmParams.ChainConfigWithUpgradesJSON, error)
```
```go
func (client Client) Close()
```
```go
func (client Client) ContractAlreadyDeployed(
contractAddress string,
) (bool, error)
```
```go
func (client Client) CreateDummyBlocks(
numBlocks int,
privKeyStr string,
) error
```
```go
func (client Client) EstimateBaseFee() (*big.Int, error)
```
```go
func (client Client) EstimateGasLimit(
msg ethereum.CallMsg,
) (uint64, error)
```
```go
func (client Client) FilterLogs(query ethereum.FilterQuery) ([]types.Log, error)
```
```go
func (client Client) FundAddress(
sourceAddressPrivateKeyStr string,
targetAddressStr string,
amount *big.Int,
) (*types.Receipt, error)
```
```go
func (client Client) GetAddressBalance(
addressStr string,
) (*big.Int, error)
```
```go
func (client Client) GetChainID() (*big.Int, error)
```
```go
func (client Client) GetContractBytecode(
contractAddressStr string,
) ([]byte, error)
```
```go
func (client Client) GetPrivateKeyBalance(
privateKey string,
) (*big.Int, error)
```
```go
func (client Client) GetTxOptsWithSigner(
prefundedPrivateKeyStr string,
) (*bind.TransactOpts, error)
```
```go
func (client Client) IssueTx(
txStr string,
) error
```
```go
func (client Client) NonceAt(
addressStr string,
) (uint64, error)
```
```go
func (client Client) SendTransaction(
tx *types.Transaction,
) error
```
```go
func (client Client) SetupProposerVM(
privKey string,
) error
```
```go
func (client Client) SuggestGasTipCap() (*big.Int, error)
```
```go
func (client Client) TransactWithWarpMessage(
from crypto.Address,
privateKeyStr string,
warpMessage *warp.Envelope,
contract crypto.Address,
callData []byte,
value *big.Int,
generateRawTxOnly bool,
) (*types.Transaction, error)
```
```go
func (client Client) TransactionReceipt(hash common.Hash) (*types.Receipt, error)
```
```go
func (client Client) WaitForEVMBootstrapped(timeout time.Duration) error
```
```go
func (client Client) WaitForNewBlock(
prevBlockNumber uint64,
totalDuration time.Duration,
) error
```
```go
func (client Client) WaitForTransaction(
tx *types.Transaction,
) (*types.Receipt, bool, error)
```
### RawClient
RawClient wraps over rpc.Client for calls used by SDK. Used to make evm calls not available in ethclient:
- debug trace call
- debug trace transaction
Features:
- finds out url scheme in case it is missing, to connect to ws/wss/http/https
- repeats to try to recover from failures, generating its own context for each call
- logs rpc url in case of failure
```go
func GetRawClient(rpcURL string) (RawClient, error)
```
```go
func (client RawClient) Close()
```
```go
func (client RawClient) DebugTraceCall(
data map[string]string,
) (map[string]interface{}, error)
```
```go
func (client RawClient) DebugTraceTransaction(
txID string,
) (map[string]interface{}, error)
```
@@ -0,0 +1,198 @@
---
title: exchangevm
description: Package exchangevm
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/exchangevm"
```
## Functions
### AwaitTxAccepted
```go
func AwaitTxAccepted(
c *Client,
ctx context.Context,
txID ids.ID,
freq time.Duration,
options ...rpc.Option,
) error
```
AwaitTxAccepted waits for a transaction to be accepted
## Types
### AssetDefinition
AssetDefinition defines an asset in genesis
### Balance
Balance represents an asset balance
### BuildGenesisArgs
BuildGenesisArgs are arguments for BuildGenesis
### BuildGenesisReply
BuildGenesisReply is the reply from BuildGenesis
### Client
Client for interacting with the Exchange VM (X-Chain)
```go
func NewClient(uri, chain string) *Client
```
```go
func (c *Client) GetAllBalances(
ctx context.Context,
addr ids.ShortID,
includePartial bool,
options ...rpc.Option,
) ([]Balance, error)
```
```go
func (c *Client) GetAssetDescription(ctx context.Context, assetID string, options ...rpc.Option) (*GetAssetDescriptionReply, error)
```
```go
func (c *Client) GetAtomicUTXOs(
ctx context.Context,
addrs []ids.ShortID,
sourceChain string,
limit uint32,
startAddress ids.ShortID,
startUTXOID ids.ID,
options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)
```
```go
func (c *Client) GetBalance(
ctx context.Context,
addr ids.ShortID,
assetID string,
includePartial bool,
options ...rpc.Option,
) (*GetBalanceReply, error)
```
```go
func (c *Client) GetBlock(ctx context.Context, blkID ids.ID, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetBlockByHeight(ctx context.Context, height uint64, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetHeight(ctx context.Context, options ...rpc.Option) (uint64, error)
```
```go
func (c *Client) GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetTxFee(ctx context.Context, options ...rpc.Option) (uint64, uint64, error)
```
```go
func (c *Client) GetTxStatus(ctx context.Context, txID ids.ID, options ...rpc.Option) (choices.Status, error)
```
```go
func (c *Client) GetUTXOs(
ctx context.Context,
addrs []ids.ShortID,
limit uint32,
startAddress ids.ShortID,
startUTXOID ids.ID,
options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)
```
```go
func (c *Client) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error)
```
### GetAllBalancesArgs
GetAllBalancesArgs are arguments for GetAllBalances
### GetAllBalancesReply
GetAllBalancesReply is the reply from GetAllBalances
### GetAssetDescriptionArgs
GetAssetDescriptionArgs are arguments for GetAssetDescription
### GetAssetDescriptionReply
GetAssetDescriptionReply is the reply from GetAssetDescription
### GetBalanceArgs
GetBalanceArgs are arguments for GetBalance
### GetBalanceReply
GetBalanceReply is the reply from GetBalance
### GetTxFeeReply
GetTxFeeReply is the response from a GetTxFee call
### GetTxStatusReply
GetTxStatusReply is the response from a GetTxStatus call
### StaticClient
StaticClient for interacting with the XVM static api
```go
func NewStaticClient(uri string) StaticClient
```
### WalletClient
WalletClient for interacting with exchangevm managed wallet.
Deprecated: Transactions should be issued using the
`luxfi/node/wallet/chain/x.Wallet` utility.
```go
func NewWalletClient(uri, chain string) *WalletClient
```
```go
func (c *WalletClient) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error)
```
@@ -0,0 +1,72 @@
---
title: fees
description: Package fees provides fee calculation and configuration utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/fees"
```
Package fees provides fee calculation and configuration utilities.
## Functions
### GetFeeConfigForThroughput
```go
func GetFeeConfigForThroughput(throughput string) commontype.FeeConfig
```
GetFeeConfigForThroughput returns a fee configuration for the specified throughput level
## Types
### FeeConfigBuilder
FeeConfigBuilder helps construct custom fee configurations
```go
func NewFeeConfigBuilder() *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) Build() commontype.FeeConfig
```
```go
func (b *FeeConfigBuilder) WithBaseFeeChangeDenominator(denominator *big.Int) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithBlockGasCostStep(blockGasCostStep *big.Int) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithGasLimit(gasLimit *big.Int) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithMaxBlockGasCost(maxBlockGasCost *big.Int) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithMinBaseFee(minBaseFee *big.Int) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithMinBlockGasCost(minBlockGasCost *big.Int) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithTargetBlockRate(targetBlockRate uint64) *FeeConfigBuilder
```
```go
func (b *FeeConfigBuilder) WithTargetGas(targetGas *big.Int) *FeeConfigBuilder
```
@@ -0,0 +1,22 @@
---
title: flags
description: Package flags provides command-line flag utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/flags"
```
Package flags provides command-line flag utilities.
## Functions
### EnsureMutuallyExclusive
```go
func EnsureMutuallyExclusive(flags []bool) bool
```
@@ -0,0 +1,63 @@
---
title: health
description: Package health
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/health"
```
## Functions
### AwaitAlive
```go
func AwaitAlive(ctx context.Context, c *Client, freq time.Duration, tags []string, options ...rpc.Option) (bool, error)
```
AwaitAlive polls the node every [freq] until the node reports liveness.
Only returns an error if [ctx] returns an error.
### AwaitHealthy
```go
func AwaitHealthy(ctx context.Context, c *Client, freq time.Duration, tags []string, options ...rpc.Option) (bool, error)
```
AwaitHealthy polls the node every [freq] until the node reports healthy.
Only returns an error if [ctx] returns an error.
### AwaitReady
```go
func AwaitReady(ctx context.Context, c *Client, freq time.Duration, tags []string, options ...rpc.Option) (bool, error)
```
AwaitReady polls the node every [freq] until the node reports ready.
Only returns an error if [ctx] returns an error.
## Types
### Client
```go
func NewClient(uri string) *Client
```
```go
func (c *Client) Health(ctx context.Context, tags []string, options ...rpc.Option) (*apihealth.APIReply, error)
```
```go
func (c *Client) Liveness(ctx context.Context, tags []string, options ...rpc.Option) (*apihealth.APIReply, error)
```
```go
func (c *Client) Readiness(ctx context.Context, tags []string, options ...rpc.Option) (*apihealth.APIReply, error)
```
@@ -0,0 +1,62 @@
---
title: heap
description: Package heap provides heap data structure implementations.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/heap"
```
Package heap provides heap data structure implementations.
## Types
### Entry
### Heap
Heap is used to track objects of [I] by [Val].
This data structure does not perform any synchronization and is not
safe to use concurrently without external locking.
```go
func New[I any, V cmp.Ordered](items int, isMinHeap bool) *Heap[I, V]
```
```go
func (h *Heap[I, V]) First() *Entry[I, V]
```
```go
func (h *Heap[I, V]) Get(id ids.ID) (*Entry[I, V], bool)
```
```go
func (h *Heap[I, V]) Has(id ids.ID) bool
```
```go
func (h *Heap[I, V]) Items() []*Entry[I, V]
```
```go
func (h *Heap[I, V]) Len() int
```
```go
func (h *Heap[I, V]) Pop() *Entry[I, V]
```
```go
func (h *Heap[I, V]) Push(e *Entry[I, V])
```
```go
func (h *Heap[I, V]) Remove(index int) *Entry[I, V]
```
@@ -0,0 +1,69 @@
---
title: indexer
description: Package indexer
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/indexer"
```
## Types
### Client
```go
func NewClient(uri string) *Client
```
```go
func (c *Client) GetContainerByID(ctx context.Context, id ids.ID, options ...rpc.Option) (Container, uint64, error)
```
```go
func (c *Client) GetContainerByIndex(ctx context.Context, index uint64, options ...rpc.Option) (Container, error)
```
```go
func (c *Client) GetContainerRange(ctx context.Context, startIndex uint64, numToFetch int, options ...rpc.Option) ([]Container, error)
```
```go
func (c *Client) GetIndex(ctx context.Context, id ids.ID, options ...rpc.Option) (uint64, error)
```
```go
func (c *Client) GetLastAccepted(ctx context.Context, options ...rpc.Option) (Container, uint64, error)
```
```go
func (c *Client) IsAccepted(ctx context.Context, id ids.ID, options ...rpc.Option) (bool, error)
```
### Container
Container is something that gets accepted
(a block, transaction or vertex).
### FormattedContainer
### GetContainerByIDArgs
### GetContainerByIndexArgs
### GetContainerRangeArgs
### GetContainerRangeResponse
### GetIndexArgs
### GetIndexResponse
### GetLastAcceptedArgs
### IsAcceptedArgs
### IsAcceptedResponse
@@ -0,0 +1,77 @@
---
title: info
description: Package info
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/info"
```
## Functions
### AwaitBootstrapped
```go
func AwaitBootstrapped(ctx context.Context, c *Client, chainID string, freq time.Duration, options ...rpc.Option) (bool, error)
```
AwaitBootstrapped polls the node every [freq] to check if [chainID] has
finished bootstrapping. Returns true once [chainID] reports that it has
finished bootstrapping.
Only returns an error if [ctx] returns an error.
## Types
### Client
```go
func NewClient(uri string) *Client
```
```go
func (c *Client) GetBlockchainID(ctx context.Context, alias string, options ...rpc.Option) (ids.ID, error)
```
```go
func (c *Client) GetNetworkID(ctx context.Context, options ...rpc.Option) (uint32, error)
```
```go
func (c *Client) GetNetworkName(ctx context.Context, options ...rpc.Option) (string, error)
```
```go
func (c *Client) GetNodeID(ctx context.Context, options ...rpc.Option) (ids.NodeID, *apiinfo.ProofOfPossession, error)
```
```go
func (c *Client) GetNodeIP(ctx context.Context, options ...rpc.Option) (netip.AddrPort, error)
```
```go
func (c *Client) GetNodeVersion(ctx context.Context, options ...rpc.Option) (*apiinfo.GetNodeVersionReply, error)
```
```go
func (c *Client) GetVMs(ctx context.Context, options ...rpc.Option) (map[ids.ID][]string, error)
```
```go
func (c *Client) IsBootstrapped(ctx context.Context, chainID string, options ...rpc.Option) (bool, error)
```
```go
func (c *Client) Peers(ctx context.Context, nodeIDs []ids.NodeID, options ...rpc.Option) ([]apiinfo.Peer, error)
```
```go
func (c *Client) Upgrades(ctx context.Context, options ...rpc.Option) (*upgrade.Config, error)
```
```go
func (c *Client) Uptime(ctx context.Context, options ...rpc.Option) (*apiinfo.UptimeResponse, error)
```
@@ -0,0 +1,160 @@
---
title: key
description: Package key provides cryptographic key generation and management.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/key"
```
Package key provides cryptographic key generation and management.
## Functions
### DeriveKey
```go
func DeriveKey(mnemonic []string, index uint32) (crypto.PrivateKey, error)
```
DeriveKey derives a key from a mnemonic at the given index
### ExportKey
```go
func ExportKey(key *Key, format string, writer io.Writer) error
```
ExportKey exports a key in various formats
### GenerateMnemonic
```go
func GenerateMnemonic(bitSize int) ([]string, error)
```
GenerateMnemonic generates a mnemonic phrase
## Types
### Key
Key represents a cryptographic key with metadata
```go
func LoadSoft(networkID uint32, keyPath string) (*Key, error)
```
```go
func (k *Key) C() string
```
```go
func (k *Key) PrivKeyHex() string
```
### Keychain
Keychain manages a collection of private keys for signing
```go
func NewKeychain() *Keychain
```
```go
func (kc *Keychain) Add(privateKey crypto.PrivateKey) error
```
```go
func (kc *Keychain) Addresses() []ids.ShortID
```
```go
func (kc *Keychain) Get(address ids.ShortID) (crypto.PrivateKey, error)
```
```go
func (kc *Keychain) Sign(message []byte, address ids.ShortID) (crypto.Signature, error)
```
### Manager
Manager handles key generation, storage, and retrieval
```go
func NewManager(keyDir string) (*Manager, error)
```
```go
func (m *Manager) Delete(keyID ids.ID) error
```
```go
func (m *Manager) DeleteKey(keyID ids.ID) error
```
```go
func (m *Manager) ExportKey(keyID ids.ID) (string, error)
```
```go
func (m *Manager) GenerateBLS() (*Key, *bls.SecretKey, error)
```
```go
func (m *Manager) GenerateEd25519() (*Key, error)
```
```go
func (m *Manager) GenerateKey(keyType string) (*Key, error)
```
```go
func (m *Manager) Get(keyID ids.ID) (*Key, error)
```
```go
func (m *Manager) GetByAddress(address ids.ShortID) (*Key, error)
```
```go
func (m *Manager) GetKey(keyID ids.ID) (*Key, error)
```
```go
func (m *Manager) ImportKey(privateKey crypto.PrivateKey, keyType string) (*Key, error)
```
```go
func (m *Manager) ImportPrivateKey(privateKey crypto.PrivateKey) (*Key, error)
```
```go
func (m *Manager) List() []*Key
```
```go
func (m *Manager) ListKeys() []*Key
```
```go
func (m *Manager) Save(keyID ids.ID) error
```
```go
func (m *Manager) SaveAll() error
```
```go
func (m *Manager) SaveKey(key *Key) error
```
@@ -0,0 +1,58 @@
---
title: keychain
description: Package keychain provides key management and keychain utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/keychain"
```
Package keychain provides key management and keychain utilities.
## Types
### Keychain
```go
func NewKeychain(
network network.Network,
keyPath string,
ledgerInfo *LedgerParams,
) (*Keychain, error)
```
```go
func (kc *Keychain) AddLedgerAddresses(addresses []string) error
```
```go
func (kc *Keychain) AddLedgerFunds(amount uint64) error
```
```go
func (kc *Keychain) AddLedgerIndices(indices []uint32) error
```
```go
func (kc *Keychain) LedgerEnabled() bool
```
### Ledger
Ledger is part of the output of NewKeyChain if a new keychain is to be created using Ledger
### LedgerParams
LedgerParams is an input to NewKeyChain if a new keychain is to be created using Ledger
To view Ledger addresses and their balances, you can use Lux CLI and use the command
lux key list --ledger [0,1,2,3,4]
The example command above will list the first five addresses in your Ledger
To transfer funds between addresses in Ledger, refer to https://docs.lux.network/tooling/cli-transfer-funds/how-to-transfer-funds
@@ -0,0 +1,136 @@
---
title: keys
description: Package keys provides key derivation and management utilities for LUX.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/keys"
```
Package keys provides key derivation and management utilities for LUX.
## Functions
### DeriveKeyFromMnemonic
```go
func DeriveKeyFromMnemonic(mnemonic string, accountIndex uint32) ([]byte, error)
```
DeriveKeyFromMnemonic derives a private key from a BIP-39 mnemonic using BIP-44 path.
Default path: m/44'/9000'/0'/0/0 (P/X-Chain)
### DeriveKeyFromSeed
```go
func DeriveKeyFromSeed(seed []byte, accountIndex uint32) ([]byte, error)
```
DeriveKeyFromSeed derives a private key from a BIP-39 seed using BIP-44 path.
Path: m/44'/9000'/0'/0/&#123;accountIndex} (P/X-Chain)
### GenerateNodeID
```go
func GenerateNodeID() (ids.NodeID, []byte, []byte, error)
```
GenerateNodeID creates a new random NodeID (for non-deterministic use cases)
### LoadKey
```go
func LoadKey(keyPath string) ([]byte, error)
```
LoadKey loads a key from file, environment, or returns an error.
Priority: 1) keyPath if non-empty, 2) PRIVATE_KEY env, 3) MNEMONIC env
### LoadKeyFromEnv
```go
func LoadKeyFromEnv() ([]byte, error)
```
LoadKeyFromEnv loads a key from environment variables.
Priority: 1) PRIVATE_KEY (hex), 2) MNEMONIC (24 words)
### LoadKeyFromFile
```go
func LoadKeyFromFile(path string) ([]byte, error)
```
LoadKeyFromFile reads a hex-encoded private key from a file.
### MustNewKeychain
```go
func MustNewKeychain(keyBytes []byte) *secp256k1fx.Keychain
```
MustNewKeychain creates a secp256k1fx.Keychain from raw key bytes, panics on error.
### NewKeychain
```go
func NewKeychain(keyBytes []byte) (*secp256k1fx.Keychain, error)
```
NewKeychain creates a secp256k1fx.Keychain from raw key bytes.
### ToPrivateKey
```go
func ToPrivateKey(keyBytes []byte) (*secp256k1.PrivateKey, error)
```
ToPrivateKey converts raw key bytes to a secp256k1 private key.
### ValidatorBundlesToCAddresses
```go
func ValidatorBundlesToCAddresses(bundles []ValidatorBundle) []common.Address
```
ValidatorBundlesToCAddresses extracts C-chain addresses from bundles
### ValidatorBundlesToNodeIDs
```go
func ValidatorBundlesToNodeIDs(bundles []ValidatorBundle) []ids.NodeID
```
ValidatorBundlesToNodeIDs extracts NodeIDs from a slice of bundles
## Types
### ValidatorBundle
ValidatorBundle contains all cryptographic materials for a validator node.
This is a pure data structure with no key management logic - the CLI handles
storage, environment reads, and interactive selection.
```go
func DeriveValidatorBundle(mnemonic string, index uint32, hrp string) (ValidatorBundle, error)
```
```go
func DeriveValidatorBundles(mnemonic string, n int, hrp string) ([]ValidatorBundle, error)
```
@@ -0,0 +1,66 @@
---
title: ledger
description: Package ledger provides hardware wallet integration via Ledger devices.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/ledger"
```
Package ledger provides hardware wallet integration via Ledger devices.
## Types
### LedgerDevice
```go
func New() (*LedgerDevice, error)
```
```go
func (dev *LedgerDevice) Address(hrp string, index uint32) (ids.ShortID, error)
```
```go
func (dev *LedgerDevice) Addresses(indices []uint32) ([]ids.ShortID, error)
```
```go
func (dev *LedgerDevice) Close() error
```
```go
func (dev *LedgerDevice) Disconnect() error
```
```go
func (dev *LedgerDevice) FindAddresses(addresses []string, maxIndex uint32) (map[string]uint32, error)
```
```go
func (dev *LedgerDevice) FindFunds(
network network.Network,
amount uint64,
maxIndex uint32,
) ([]uint32, error)
```
```go
func (dev *LedgerDevice) GetAddresses(indices []uint32, hrp string, chainID string) ([]string, error)
```
```go
func (dev *LedgerDevice) Sign(hash []byte, indices []uint32) ([][]byte, error)
```
```go
func (dev *LedgerDevice) SignHash(hash []byte, indices []uint32) ([][]byte, error)
```
```go
func (dev *LedgerDevice) Version() (v *version.Semantic, err error)
```
@@ -0,0 +1,77 @@
---
title: lpm
description: Package lpm provides Lux Plugin Manager client wrapper for CLI integration.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/lpm"
```
Package lpm provides Lux Plugin Manager client wrapper for CLI integration.
## Types
### Chain
### Client
Client wraps the LPM functionality for CLI use
```go
func NewClient(lpmDir string, pluginDir string, adminAPIEndpoint string) (*Client, error)
```
```go
func (c *Client) AddRepository(alias string, url string, branch string) error
```
```go
func (c *Client) AddVM(vm *VMUpload) error
```
```go
func (c *Client) GetVM(alias string, version string) (*VMUpload, error)
```
```go
func (c *Client) Install(alias string) error
```
```go
func (c *Client) JoinChain(alias string) error
```
```go
func (c *Client) ListRepositories() error
```
```go
func (c *Client) Uninstall(alias string) error
```
```go
func (c *Client) Update() error
```
```go
func (c *Client) Upgrade(alias string) error
```
### Config
```go
func DefaultConfig() *Config
```
### Credential
### Metadata
### VM
### VMUpload
@@ -0,0 +1 @@
{"pages":["admin","aichain","application","blockchain","chain","chainconfig","config","configspec","connect","constants","contract","crypto","evm","exchangevm","fees","flags","health","heap","indexer","info","key","keychain","keys","ledger","lpm","models","multisig","netrunner","network","platformvm","profiles","prompts","publicarchive","types","ux","validator","validatormanager","vm","wallet","warp"]}
@@ -0,0 +1,485 @@
---
title: models
description: Package models provides data structures and types used throughout the SDK.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/models"
```
Package models provides data structures and types used throughout the SDK.
Copyright (C) 2022, Lux Partners Limited All rights reserved.
See the file LICENSE for licensing terms.
Copyright (C) 2022, Lux Partners Limited All rights reserved.
See the file LICENSE for licensing terms.
## Functions
### GetRPCEndpoint
```go
func GetRPCEndpoint(baseEndpoint string, blockchainID string) string
```
GetRPCEndpoint returns the RPC endpoint for a given base endpoint and blockchain ID
### GetWSEndpoint
```go
func GetWSEndpoint(baseEndpoint string, blockchainID string) string
```
GetWSEndpoint returns the WebSocket endpoint for a given base endpoint and blockchain ID
### HostAnsibleIDToCloudID
```go
func HostAnsibleIDToCloudID(hostAnsibleID string) (string, string, error)
```
HostAnsibleIDToCloudID converts a host Ansible ID to a cloud ID.
### HostCloudIDToAnsibleID
```go
func HostCloudIDToAnsibleID(cloudService string, hostCloudID string) (string, error)
```
### NewHostConnection
```go
func NewHostConnection(h *Host, port uint) (*goph.Client, error)
```
## Types
### BaseMigration
BaseMigration represents a base chain migration
### BridgeRoute
BridgeRoute represents a cross-chain route
### CLIDependencyMap
CLIDependencyMap represents CLI dependency versions
### ChainValidator
ChainValidator is a backward compatibility alias for Validator.
### CloudConfig
```go
func (ccm *CloudConfig) GetAPIInstanceIDsForRegion(region string) []string
```
```go
func (ccm *CloudConfig) GetAllAPIInstanceIDs() []string
```
```go
func (ccm *CloudConfig) GetAllInstanceIDs() []string
```
```go
func (ccm *CloudConfig) GetInstanceIDsForRegion(region string) []string
```
```go
func (ccm *CloudConfig) GetRegions() []string
```
### ClusterConfig
```go
func (cc *ClusterConfig) GetAPIHosts(hosts []*Host) []*Host
```
```go
func (cc *ClusterConfig) GetCloudIDs() []string
```
```go
func (cc *ClusterConfig) GetHostRoles(nodeConf NodeConfig) []string
```
```go
func (cc *ClusterConfig) GetValidatorHosts(hosts []*Host) []*Host
```
```go
func (cc *ClusterConfig) IsAPIHost(hostCloudID string) bool
```
```go
func (cc *ClusterConfig) IsLuxdHost(hostCloudID string) bool
```
### ClustersConfig
### ClustersConfigV0
### ElasticChain
### ElasticChainConfig
### ElasticNet
ElasticNet is an alias for ElasticChain (deprecated)
### ElasticNetConfig
ElasticNetConfig is an alias for backward compatibility (deprecated)
### ExportCluster
### ExportNode
### Exportable
### ExtraNetworkData
### GCPConfig
### GenesisParams
GenesisParams represents network genesis parameters
### GovernanceProposal
GovernanceProposal for base migrations and upgrades
### Host
```go
func (h *Host) Command(script string, env []string, timeout time.Duration) ([]byte, error)
```
```go
func (h *Host) Connect(port uint) error
```
```go
func (h *Host) Connected() bool
```
```go
func (h *Host) CreateTempDir() (string, error)
```
```go
func (h *Host) CreateTempFile() (string, error)
```
```go
func (h *Host) Disconnect() error
```
```go
func (h *Host) Download(remoteFile string, localFile string, timeout time.Duration) error
```
```go
func (h *Host) ExpandHome(path string) string
```
```go
func (h *Host) FileExists(path string) (bool, error)
```
```go
func (h *Host) Forward(httpRequest string, timeout time.Duration) ([]byte, error)
```
```go
func (h *Host) GetAnsibleInventoryRecord() string
```
```go
func (h *Host) GetCloudID() string
```
```go
func (h *Host) IsSystemD() bool
```
```go
func (h *Host) MkdirAll(remoteDir string, timeout time.Duration) error
```
```go
func (h *Host) ReadFileBytes(remoteFile string, timeout time.Duration) ([]byte, error)
```
```go
func (h *Host) Remove(path string, recursive bool) error
```
```go
func (h *Host) StreamSSHCommand(command string, env []string, timeout time.Duration) error
```
```go
func (h *Host) UntimedForward(httpRequest string) ([]byte, error)
```
```go
func (h *Host) UntimedMkdirAll(remoteDir string) error
```
```go
func (h *Host) Upload(localFile string, remoteFile string, timeout time.Duration) error
```
```go
func (h *Host) UploadBytes(data []byte, remoteFile string, timeout time.Duration) error
```
```go
func (h *Host) WaitForPort(port uint, timeout time.Duration) error
```
```go
func (h *Host) WaitForSSHShell(timeout time.Duration) error
```
### L2Config
L2Config represents a based rollup configuration
### L3Config
L3Config for nested rollups
### LuxCompatiblity
### LuxdCompatiblity
LuxdCompatiblity is an alias for backward compatibility
### MigrationTx
MigrationTx represents a chain to L1 migration transaction
### MultisigTxInfo
### Network
```go
func ConvertClusterToNetwork(network Network) Network
```
```go
func GetNetworkFromSidecarNetworkName(name string) Network
```
```go
func NetworkFromNetworkID(networkID uint32) Network
```
```go
func NetworkFromString(s string) Network
```
```go
func NewDevnetNetwork() Network
```
```go
func NewLocalNetwork() Network
```
```go
func NewMainnetNetwork() Network
```
```go
func NewNetworkFromCluster(network Network, clusterName string) Network
```
```go
func NewTestnetNetwork() Network
```
```go
func (s Network) BlockchainEndpoint(blockchainID string) string
```
```go
func (s Network) BootstrappingContext() (context.Context, func())
```
```go
func (s Network) CChainEndpoint() string
```
```go
func (s Network) CChainWSEndpoint() string
```
```go
func (s Network) ClusterName() string
```
```go
func (s Network) Endpoint() string
```
```go
func (s Network) Equals(other Network) bool
```
```go
func (s Network) GenesisParams() *GenesisParams
```
```go
func (s Network) HandlePublicNetworkSimulation() bool
```
```go
func (s Network) ID() uint32
```
```go
func (s Network) Kind() Network
```
```go
func (s Network) Name() string
```
```go
func (s Network) NetworkID() (uint32, error)
```
```go
func (s Network) NetworkIDFlagValue() string
```
```go
func (s Network) SDKNetwork() interface{}
```
```go
func (s Network) String() string
```
```go
func (s Network) WSEndpoints() []string
```
### NetworkData
### NetworkVersions
NetworkVersions represents versions for a network
### NodeConfig
### NodeResult
### NodeResults
```go
func (nr *NodeResults) AddResult(nodeID string, value interface{}, err error)
```
```go
func (nr *NodeResults) GetErrorHostMap() map[string]error
```
```go
func (nr *NodeResults) GetErrorHosts() []string
```
```go
func (nr *NodeResults) GetNodeList() []string
```
```go
func (nr *NodeResults) GetResultMap() map[string]interface{}
```
```go
func (nr *NodeResults) GetResults() []NodeResult
```
```go
func (nr *NodeResults) HasErrors() bool
```
```go
func (nr *NodeResults) HasIDWithError(id string) bool
```
```go
func (nr *NodeResults) Len() int
```
### PermissionlessValidators
### PreconfirmConfig
PreconfirmConfig represents pre-confirmation settings
### RegionConfig
### Sidecar
```go
func (sc Sidecar) GetVMID() (string, error)
```
```go
func (sc *Sidecar) NetworkDataIsEmpty() bool
```
### TokenInfo
### VMCompatibility
### VMType
```go
func VMTypeFromString(s string) VMType
```
```go
func (v VMType) Org() string
```
```go
func (v VMType) RepoName() string
```
### Validator
Validator represents a validator on any network layer (primary, L1, L2, L3)
As above, so below - validators are unified across all network layers
@@ -0,0 +1,88 @@
---
title: multisig
description: Package multisig provides multi-signature transaction support.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/multisig"
```
Package multisig provides multi-signature transaction support.
## Functions
### GetOwners
```go
func GetOwners(network network.LegacyNetwork, chainID ids.ID) ([]ids.ShortID, uint32, error)
```
## Types
### Multisig
```go
func New(pChainTx *txs.Tx) *Multisig
```
```go
func (ms *Multisig) FromBytes(txBytes []byte) error
```
```go
func (ms *Multisig) GetAuthSigners() ([]ids.ShortID, error)
```
```go
func (ms *Multisig) GetChainID() (ids.ID, error)
```
```go
func (ms *Multisig) GetNetOwners() ([]ids.ShortID, uint32, error)
```
```go
func (ms *Multisig) GetNetwork() (network.LegacyNetwork, error)
```
```go
func (ms *Multisig) GetNetworkID() (uint32, error)
```
```go
func (ms *Multisig) GetRemainingAuthSigners() ([]ids.ShortID, []ids.ShortID, error)
```
```go
func (*Multisig) GetSpendSigners() ([]ids.ShortID, error)
```
```go
func (ms *Multisig) GetTxKind() (TxKind, error)
```
```go
func (ms *Multisig) GetWrappedPChainTx() (*txs.Tx, error)
```
```go
func (ms *Multisig) IsReadyToCommit() (bool, error)
```
```go
func (ms *Multisig) String() string
```
```go
func (ms *Multisig) ToBytes() ([]byte, error)
```
```go
func (ms *Multisig) Undefined() bool
```
### TxKind
@@ -0,0 +1,79 @@
---
title: netrunner
description: Package netrunner provides integration with the Lux netrunner tool for managing test networks and blockchain deployments.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/netrunner"
```
Package netrunner provides integration with the Lux netrunner tool
for managing test networks and blockchain deployments.
## Types
### Client
Client wraps the netrunner client with additional functionality
```go
func NewClient(config *Config, logger log.Logger) (*Client, error)
```
```go
func (c *Client) AddNode(ctx context.Context, name string, execPath string, opts ...client.OpOption) (*rpcpb.AddNodeResponse, error)
```
```go
func (c *Client) Close() error
```
```go
func (c *Client) CreateChains(ctx context.Context, specs []*rpcpb.BlockchainSpec) (*rpcpb.CreateBlockchainsResponse, error)
```
```go
func (c *Client) Health(ctx context.Context) (*rpcpb.HealthResponse, error)
```
```go
func (c *Client) RemoveNode(ctx context.Context, name string) error
```
```go
func (c *Client) RestartNode(ctx context.Context, name string, opts ...client.OpOption) error
```
```go
func (c *Client) Start(ctx context.Context, execPath string, opts ...client.OpOption) (*rpcpb.StartResponse, error)
```
```go
func (c *Client) Status(ctx context.Context) (*rpcpb.StatusResponse, error)
```
```go
func (c *Client) Stop(ctx context.Context) error
```
```go
func (c *Client) URIs(ctx context.Context) ([]string, error)
```
```go
func (c *Client) WaitForHealthy(ctx context.Context, timeout time.Duration) error
```
### Config
Config holds configuration for the netrunner client
```go
func DefaultConfig() *Config
```
@@ -0,0 +1,129 @@
---
title: network
description: Package network provides network configuration and management utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/network"
```
Package network provides network configuration and management utilities.
## Types
### ChainConfig
ChainConfig defines configuration for a chain
### LegacyNetwork
LegacyNetwork represents a network configuration with endpoint
This is for compatibility with existing code
```go
func GetNetworkByName(name string) (LegacyNetwork, error)
```
```go
func NetworkFromNetworkID(networkID uint32) LegacyNetwork
```
### Network
Network represents a managed Lux network
### NetworkKind
NetworkKind represents the kind of network
```go
func (k NetworkKind) String() string
```
### NetworkManager
NetworkManager handles all network operations using netrunner
```go
func NewNetworkManager(config *config.NetworkConfig, logger log.Logger) (*NetworkManager, error)
```
```go
func (nm *NetworkManager) AddNode(ctx context.Context, networkID string, nodeParams *NodeParams) (*Node, error)
```
```go
func (nm *NetworkManager) CreateNetwork(ctx context.Context, params *NetworkParams) (*Network, error)
```
```go
func (nm *NetworkManager) DeleteNetwork(ctx context.Context, networkID string) error
```
```go
func (nm *NetworkManager) GetNetwork(networkID string) (*Network, error)
```
```go
func (nm *NetworkManager) GetNodeStatus(ctx context.Context, networkID, nodeID string) (*NodeStatus, error)
```
```go
func (nm *NetworkManager) ListNetworks() []*Network
```
```go
func (nm *NetworkManager) RemoveNode(ctx context.Context, networkID, nodeID string) error
```
```go
func (nm *NetworkManager) StartNetwork(ctx context.Context, networkID string) error
```
```go
func (nm *NetworkManager) StopNetwork(ctx context.Context, networkID string) error
```
### NetworkParams
NetworkParams defines parameters for creating a network
### NetworkStatus
NetworkStatus defines the status of a network
### NetworkType
NetworkType defines the type of network
### Node
Node represents a node in the network
### NodeParams
NodeParams defines parameters for adding a node
### NodeStatus
NodeStatus defines the status of a node
### NodeType
NodeType defines the type of node
@@ -0,0 +1,514 @@
---
title: platformvm
description: Package platformvm
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/platformvm"
```
## Functions
### AwaitTxAccepted
```go
func AwaitTxAccepted(
c *Client,
ctx context.Context,
txID ids.ID,
freq time.Duration,
options ...rpc.Option,
) error
```
### GetDeactivationOwners
```go
func GetDeactivationOwners(
c *Client,
ctx context.Context,
validationIDs ...ids.ID,
) (map[ids.ID]fx.Owner, error)
```
GetDeactivationOwners returns a map of validation ID to deactivation owners
### GetNetOwners
```go
func GetNetOwners(
c *Client,
ctx context.Context,
chainIDs ...ids.ID,
) (map[ids.ID]fx.Owner, error)
```
GetNetOwners returns a map of chain ID to current chain's owner
### GetOwners
```go
func GetOwners(
c *Client,
ctx context.Context,
chainIDs []ids.ID,
validationIDs []ids.ID,
) (map[ids.ID]fx.Owner, error)
```
GetOwners returns the union of GetNetOwners and GetDeactivationOwners.
## Types
### APIBlockchain
APIBlockchain represents a blockchain in the API response.
NetID is the ID of the network that validates this blockchain.
### APINet
APINet represents a net in the API
### Client
```go
func NewClient(uri string) *Client
```
```go
func NewClientWithNetworkID(uri string, networkID uint32) *Client
```
```go
func (c *Client) GetAtomicUTXOs(
ctx context.Context,
addrs []ids.ShortID,
sourceChain string,
limit uint32,
startAddress ids.ShortID,
startUTXOID ids.ID,
options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)
```
```go
func (c *Client) GetBalance(ctx context.Context, addrs []ids.ShortID, options ...rpc.Option) (*GetBalanceResponse, error)
```
```go
func (c *Client) GetBlock(ctx context.Context, blockID ids.ID, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetBlockByHeight(ctx context.Context, height uint64, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetBlockchainStatus(ctx context.Context, blockchainID string, options ...rpc.Option) (status.BlockchainStatus, error)
```
```go
func (c *Client) GetBlockchains(ctx context.Context, options ...rpc.Option) ([]APIBlockchain, error)
```
```go
func (c *Client) GetCurrentSupply(ctx context.Context, chainID ids.ID, options ...rpc.Option) (uint64, uint64, error)
```
```go
func (c *Client) GetCurrentValidators(
ctx context.Context,
chainID ids.ID,
nodeIDs []ids.NodeID,
options ...rpc.Option,
) ([]ClientPermissionlessValidator, error)
```
```go
func (c *Client) GetFeeConfig(ctx context.Context, options ...rpc.Option) (*gas.Config, error)
```
```go
func (c *Client) GetFeeState(ctx context.Context, options ...rpc.Option) (
gas.State,
gas.Price,
time.Time,
error,
)
```
```go
func (c *Client) GetHeight(ctx context.Context, options ...rpc.Option) (uint64, error)
```
```go
func (c *Client) GetL1Validator(
ctx context.Context,
validationID ids.ID,
options ...rpc.Option,
) (L1Validator, uint64, error)
```
```go
func (c *Client) GetMinStake(ctx context.Context, chainID ids.ID, options ...rpc.Option) (uint64, uint64, error)
```
```go
func (c *Client) GetNet(ctx context.Context, chainID ids.ID, options ...rpc.Option) (GetNetClientResponse, error)
```
```go
func (c *Client) GetNets(ctx context.Context, ids []ids.ID, options ...rpc.Option) ([]ClientNet, error)
```
```go
func (c *Client) GetProposedHeight(ctx context.Context, options ...rpc.Option) (uint64, error)
```
```go
func (c *Client) GetRewardUTXOs(ctx context.Context, args *api.GetTxArgs, options ...rpc.Option) ([][]byte, error)
```
```go
func (c *Client) GetStake(
ctx context.Context,
addrs []ids.ShortID,
validatorsOnly bool,
options ...rpc.Option,
) (map[ids.ID]uint64, [][]byte, error)
```
```go
func (c *Client) GetStakingAssetID(ctx context.Context, chainID ids.ID, options ...rpc.Option) (ids.ID, error)
```
```go
func (c *Client) GetTimestamp(ctx context.Context, options ...rpc.Option) (time.Time, error)
```
```go
func (c *Client) GetTotalStake(ctx context.Context, chainID ids.ID, options ...rpc.Option) (uint64, error)
```
```go
func (c *Client) GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option) ([]byte, error)
```
```go
func (c *Client) GetTxStatus(ctx context.Context, txID ids.ID, options ...rpc.Option) (*GetTxStatusResponse, error)
```
```go
func (c *Client) GetUTXOs(
ctx context.Context,
addrs []ids.ShortID,
limit uint32,
startAddress ids.ShortID,
startUTXOID ids.ID,
options ...rpc.Option,
) ([][]byte, ids.ShortID, ids.ID, error)
```
```go
func (c *Client) GetValidatorFeeConfig(ctx context.Context, options ...rpc.Option) (*fee.Config, error)
```
```go
func (c *Client) GetValidatorFeeState(ctx context.Context, options ...rpc.Option) (
gas.Gas,
gas.Price,
time.Time,
error,
)
```
```go
func (c *Client) GetValidatorsAt(
ctx context.Context,
chainID ids.ID,
height platformapi.Height,
options ...rpc.Option,
) (map[ids.NodeID]*validators.GetValidatorOutput, error)
```
```go
func (c *Client) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error)
```
```go
func (c *Client) SampleValidators(ctx context.Context, chainID ids.ID, sampleSize uint16, options ...rpc.Option) ([]ids.NodeID, error)
```
```go
func (c *Client) SetNetworkID(networkID uint32)
```
```go
func (c *Client) ValidatedBy(ctx context.Context, blockchainID ids.ID, options ...rpc.Option) (ids.ID, error)
```
```go
func (c *Client) Validates(ctx context.Context, chainID ids.ID, options ...rpc.Option) ([]ids.ID, error)
```
### ClientDelegator
ClientDelegator is the repr. of a delegator sent over client
### ClientL1Validator
### ClientNet
ClientNet is a representation of a net used in client methods
### ClientOwner
ClientOwner is the repr. of a reward owner sent over client
### ClientPermissionlessValidator
ClientPermissionlessValidator is the repr. of a permissionless validator sent
over client
### ClientStaker
ClientStaker is the representation of a staker sent via client.
### GetBalanceRequest
GetBalanceRequest is the request for GetBalance
### GetBalanceResponse
GetBalanceResponse is the response from GetBalance
### GetBlockchainStatusArgs
GetBlockchainStatusArgs is the request for GetBlockchainStatus
### GetBlockchainStatusReply
GetBlockchainStatusReply is the response from GetBlockchainStatus
### GetBlockchainsReply
GetBlockchainsReply is the response from GetBlockchains
### GetBlockchainsResponse
GetBlockchainsResponse is the response from GetBlockchains
### GetCurrentSupplyArgs
GetCurrentSupplyArgs is the request for GetCurrentSupply
### GetCurrentSupplyReply
GetCurrentSupplyReply is the response from GetCurrentSupply
### GetCurrentValidatorsArgs
GetCurrentValidatorsArgs is the request for GetCurrentValidators
### GetCurrentValidatorsReply
GetCurrentValidatorsReply is the response from GetCurrentValidators
### GetFeeConfigReply
GetFeeConfigReply is the response from GetFeeConfig
### GetFeeStateReply
GetFeeStateReply is the response from GetFeeState
### GetL1ValidatorArgs
GetL1ValidatorArgs is the request for GetL1Validator
### GetL1ValidatorReply
GetL1ValidatorReply is the response from GetL1Validator
### GetMinStakeArgs
GetMinStakeArgs is the request for GetMinStake
### GetMinStakeReply
GetMinStakeReply is the response from GetMinStake
### GetNetArgs
GetNetArgs is the request for GetNet
### GetNetClientResponse
GetNetClientResponse is the response from calling GetNet on the client
### GetNetResponse
GetNetResponse is the response from GetNet
### GetNetsArgs
GetNetsArgs is the request for GetNets
### GetNetsResponse
GetNetsResponse is the response from GetNets
### GetRewardUTXOsReply
GetRewardUTXOsReply is the response from GetRewardUTXOs
### GetStakeArgs
GetStakeArgs is the request for GetStake
### GetStakeReply
GetStakeReply is the response from GetStake
### GetStakingAssetIDArgs
GetStakingAssetIDArgs is the request for GetStakingAssetID
### GetStakingAssetIDResponse
GetStakingAssetIDResponse is the response from GetStakingAssetID
### GetTimestampReply
GetTimestampReply is the response from GetTimestamp
### GetTotalStakeArgs
GetTotalStakeArgs is the request for GetTotalStake
### GetTotalStakeReply
GetTotalStakeReply is the response from GetTotalStake
### GetTxStatusArgs
GetTxStatusArgs is the request for GetTxStatus
### GetTxStatusResponse
GetTxStatusResponse is the response from GetTxStatus
### GetValidatorFeeStateReply
GetValidatorFeeStateReply is the response from GetValidatorFeeState
### GetValidatorsAtArgs
GetValidatorsAtArgs is the request for GetValidatorsAt
### GetValidatorsAtReply
GetValidatorsAtReply is the response from GetValidatorsAt
### L1Validator
L1Validator is the response from calling GetL1Validator on the API client.
### L1ValidatorOwner
L1ValidatorOwner represents an owner in an L1 validator response
### SampleValidatorsArgs
SampleValidatorsArgs is the request for SampleValidators
### SampleValidatorsReply
SampleValidatorsReply is the response from SampleValidators
### Uint16
Uint16 is a uint16 that marshals as a JSON string for compatibility with
the historical luxd JSON-RPC numeric wire (every numeric over the wire is
a string). luxfi/api/types ships Uint64/Uint32/Float64 but not Uint16;
this is a local 1:1 mirror sitting at the same external boundary.
```go
func (u Uint16) MarshalJSON() ([]byte, error)
```
```go
func (u *Uint16) UnmarshalJSON(b []byte) error
```
### ValidatedByArgs
ValidatedByArgs is the request for ValidatedBy
### ValidatedByResponse
ValidatedByResponse is the response from ValidatedBy
### ValidatesArgs
ValidatesArgs is the request for Validates
### ValidatesResponse
ValidatesResponse is the response from Validates
@@ -0,0 +1,110 @@
---
title: profiles
description: Package profiles provides embedded network tuning profiles for the Lux SDK.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/profiles"
```
Package profiles provides embedded network tuning profiles for the Lux SDK.
These profiles configure consensus, health, and network parameters for different
deployment scenarios (mainnet, testnet, devnet, dev mode).
Available profiles:
- standard: Conservative mainnet settings for production-safe operation
- fast: Balanced testnet settings for development
- turbo: Aggressive 3-node local network with 2/3 quorum
- ultra: Maximum aggression for single-node dev mode with K=1 consensus
## Functions
### DefaultProfileForNetwork
```go
func DefaultProfileForNetwork(networkName string) string
```
DefaultProfileForNetwork returns the default profile name for a network type.
For local development, all networks use turbo for ultra-fast consensus.
### GetProfileMap
```go
func GetProfileMap(name string) (map[string]interface{}, error)
```
GetProfileMap loads a profile and returns it as map[string]interface&#123;}.
Useful for direct JSON manipulation.
### IsByzantineSafe
```go
func IsByzantineSafe(sampleSize, quorumSize int) bool
```
IsByzantineSafe reports whether a sample/quorum pair satisfies the consensus
engine's Byzantine-safety invariant. Use it to validate any consensus config.
### ListProfiles
```go
func ListProfiles() []string
```
ListProfiles returns names of all available profiles, sorted alphabetically.
### ValidateProfile
```go
func ValidateProfile(data map[string]interface{}) error
```
ValidateProfile checks that a profile has required fields.
## Types
### ConsensusConfig
ConsensusConfig holds consensus tuning parameters.
```go
func Consensus(n int) ConsensusConfig
```
### HealthConfig
HealthConfig holds health check tuning parameters.
### NetworkConfig
NetworkConfig holds network tuning parameters.
### Profile
Profile represents a network tuning profile.
```go
func GetProfile(name string) (*Profile, error)
```
```go
func MustGetProfile(name string) *Profile
```
```go
func (p *Profile) ToNodeConfig() map[string]interface{}
```
@@ -0,0 +1,186 @@
---
title: prompts
description: Package prompts provides interactive user prompts for CLI applications.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/prompts"
```
Package prompts provides interactive user prompts for CLI applications.
## Functions
### CaptureKeyAddress
```go
func CaptureKeyAddress(
prompt Prompter,
goal string,
keyDir string,
getKey func(string) (string, error),
network models.Network,
addressFormat string,
) (string, error)
```
CaptureKeyAddress prompts the user to select a key address
### CaptureListDecision
```go
func CaptureListDecision[T comparable](
prompter Prompter,
prompt string,
capture func(prompt string) (T, error),
capturePrompt string,
label string,
info string,
) ([]T, bool, error)
```
CaptureListDecision runs a for loop and continuously asks the
user for a specific input (currently only `CapturePChainAddress`
and `CaptureAddress` is supported) until the user cancels or
chooses `Done`. It does also offer an optional `info` to print
(if provided) and a preview. Items can also be removed.
### CheckChainAuthKeys
```go
func CheckChainAuthKeys(chainAuthKeys []string, controlKeys []string, threshold uint32) error
```
CheckChainAuthKeys checks chain authorization criteria:
- [chainAuthKeys] satisfy chain's [threshold]
- [chainAuthKeys] is a subset of chain's [controlKeys]
### ConvertToAddress
```go
func ConvertToAddress(addr string) (crypto.Address, error)
```
ConvertToAddress converts a string to a crypto.Address
### GetChainAuthKeys
```go
func GetChainAuthKeys(prompt Prompter, controlKeys []string, threshold uint32) ([]string, error)
```
GetChainAuthKeys gets chain authorization keys from the user, as a subset of the chain's [controlKeys]
with a len equal to the chain's [threshold].
### GetKeyOrLedger
```go
func GetKeyOrLedger(prompter Prompter, goal string, keyDir string, includeEwoq bool) (bool, string, error)
```
GetKeyOrLedger prompts user to choose between key or ledger
### GetTestnetKeyOrLedger
```go
func GetTestnetKeyOrLedger(prompt Prompter, goal string, keyDir string) (bool, string, error)
```
### PromptAddress
```go
func PromptAddress(prompter Prompter, prompt string) (string, error)
```
PromptAddress prompts the user for an address
### PromptChain
```go
func PromptChain(
prompt Prompter,
message string,
blockchainNames []string,
pChainEnabled bool,
xChainEnabled bool,
cChainEnabled bool,
blockchainNameToAvoid string,
blockchainIDEnabled bool,
) (bool, bool, bool, bool, string, string, error)
```
PromptChain prompts the user to select a chain
### PromptPrivateKey
```go
func PromptPrivateKey(prompter Prompter, prompt string) (string, error)
```
PromptPrivateKey prompts the user for a private key
### ValidateAddress
```go
func ValidateAddress(addr string) error
```
ValidateAddress validates an Ethereum address
### ValidateHexa
```go
func ValidateHexa(input string) error
```
ValidateHexa validates hexadecimal string format
### ValidatePositiveInt
```go
func ValidatePositiveInt(val int) error
```
ValidatePositiveInt validates that an integer is positive
### ValidateURLFormat
```go
func ValidateURLFormat(input string) error
```
## Types
### Comparator
```go
func (comparator *Comparator) Validate(val uint64) error
```
### Prompter
```go
func NewPrompter() Prompter
```
@@ -0,0 +1,56 @@
---
title: publicarchive
description: Package publicarchive
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/publicarchive"
```
## Types
### Downloader
```go
func NewDownloader(
net *network.Network,
logger luxlog.Logger,
) (Downloader, error)
```
```go
func (d Downloader) CleanUp()
```
```go
func (d Downloader) Download() error
```
```go
func (d Downloader) GetBytesComplete() int64
```
```go
func (d Downloader) GetDownloadSize() int64
```
```go
func (d Downloader) GetFilePath() (string, error)
```
```go
func (d Downloader) IsComplete() bool
```
```go
func (d Downloader) IsEmpty() bool
```
```go
func (d Downloader) UnpackTo(targetDir string) error
```
### Getter
@@ -0,0 +1,36 @@
---
title: types
description: Package types provides common type definitions used across the SDK.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/types"
```
Package types provides common type definitions used across the SDK.
## Types
### Config
Config represents the CLI configuration
### ConfigLoader
ConfigLoader provides methods for loading configuration
### ConfigWriter
ConfigWriter provides methods for writing configuration
### PrompterInterface
PrompterInterface provides methods for user interaction
@@ -0,0 +1,134 @@
---
title: ux
description: Package ux provides user experience utilities for CLI output formatting.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/ux"
```
Package ux provides user experience utilities for CLI output formatting.
## Functions
### ConvertToStringWithThousandSeparator
```go
func ConvertToStringWithThousandSeparator(input uint64) string
```
### DefaultTable
```go
func DefaultTable(title string, headers []string) *tablewriter.Table
```
DefaultTable creates a default table with the given title and headers
### ExtraStepExecuted
```go
func ExtraStepExecuted(bar *progressbar.ProgressBar) error
```
### FormatDuration
```go
func FormatDuration(d time.Duration) string
```
FormatDuration returns a user friendly string for a duration
### NewUserLog
```go
func NewUserLog(log luxlog.Logger, userwriter io.Writer)
```
### PrintTableEndpoints
```go
func PrintTableEndpoints(clusterInfo *rpcpb.ClusterInfo)
```
PrintTableEndpoints prints the endpoints coming from the healthy call
### PrintWait
```go
func PrintWait(cancel chan struct{})
```
PrintWait does some dot printing to entertain the user
### SpinComplete
```go
func SpinComplete(s *ysmrr.Spinner)
```
### SpinFailWithError
```go
func SpinFailWithError(s *ysmrr.Spinner, txt string, err error)
```
### TimedProgressBar
```go
func TimedProgressBar(
duration time.Duration,
title string,
extraSteps int,
) (*progressbar.ProgressBar, error)
```
## Types
### UserLog
```go
func (ul *UserLog) Error(msg string, args ...interface{})
```
```go
func (ul *UserLog) GreenCheckmarkToUser(msg string, args ...interface{})
```
```go
func (ul *UserLog) Info(msg string, args ...interface{})
```
```go
func (ul *UserLog) PrintLineSeparator(msg ...string)
```
```go
func (ul *UserLog) PrintToUser(msg string, args ...interface{})
```
```go
func (ul *UserLog) RedXToUser(msg string, args ...interface{})
```
### UserSpinner
```go
func NewUserSpinner() *UserSpinner
```
```go
func (us *UserSpinner) SpinToUser(msg string, args ...interface{}) *ysmrr.Spinner
```
```go
func (us *UserSpinner) Stop()
```
@@ -0,0 +1,84 @@
---
title: validator
description: Package validator provides validator management and configuration utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/validator"
```
Package validator provides validator management and configuration utilities.
## Functions
### GetRemainingValidationTime
```go
func GetRemainingValidationTime(networkEndpoint string, nodeID ids.NodeID, chainID ids.ID, startTime time.Time) (time.Duration, error)
```
GetRemainingValidationTime returns the time remaining for [nodeID] on [chainID].
### GetTotalWeight
```go
func GetTotalWeight(network models.Network, chainID ids.ID) (uint64, error)
```
### GetValidationID
```go
func GetValidationID(
rpcURL string,
managerAddress crypto.Address,
nodeID ids.NodeID,
) (ids.ID, error)
```
GetValidationID returns the validation ID for the Node ID, as registered at the validator manager.
Will return ids.Empty in case it is not registered.
### GetValidatorBalance
```go
func GetValidatorBalance(net models.Network, validationID ids.ID) (uint64, error)
```
### GetValidatorInfo
```go
func GetValidatorInfo(net models.Network, validationID ids.ID) (platformvm.ClientPermissionlessValidator, error)
```
### IsValidator
```go
func IsValidator(network models.Network, chainID ids.ID, nodeID ids.NodeID) (bool, error)
```
## Types
### CurrentValidatorInfo
CurrentValidatorInfo enables querying validation IDs from P-Chain.
```go
func GetCurrentValidators(network models.Network, chainID ids.ID) ([]CurrentValidatorInfo, error)
```
### ValidatorKind
```go
func GetValidatorKind(
network models.Network,
chainID ids.ID,
nodeID ids.NodeID,
) (ValidatorKind, error)
```
@@ -0,0 +1,739 @@
---
title: validatormanager
description: Package validatormanager provides L1 validator lifecycle management.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/validatormanager"
```
Package validatormanager provides L1 validator lifecycle management.
## Functions
### AddPoAValidatorManagerV1_0_0ContractToAllocations
```go
func AddPoAValidatorManagerV1_0_0ContractToAllocations(
allocs types.GenesisAlloc,
)
```
### AddRewardCalculatorV2_0_0ToAllocations
```go
func AddRewardCalculatorV2_0_0ToAllocations(
allocs types.GenesisAlloc,
rewardBasisPoints uint64,
)
```
### AddSpecializationTransparentProxyContractToAllocations
```go
func AddSpecializationTransparentProxyContractToAllocations(
allocs types.GenesisAlloc,
proxyManager string,
)
```
### AddValidatorManagerV2_0_0ContractToAllocations
```go
func AddValidatorManagerV2_0_0ContractToAllocations(
allocs types.GenesisAlloc,
)
```
### AddValidatorMessagesV2_0_0ContractToAllocations
```go
func AddValidatorMessagesV2_0_0ContractToAllocations(
allocs types.GenesisAlloc,
)
```
### AddValidatorTransparentProxyContractToAllocations
```go
func AddValidatorTransparentProxyContractToAllocations(
allocs types.GenesisAlloc,
proxyManager string,
)
```
### CompleteValidatorRegistration
```go
func CompleteValidatorRegistration(
rpcURL string,
managerAddress crypto.Address,
generateRawTxOnly bool,
ownerAddress crypto.Address,
privateKey string,
l1ValidatorRegistrationSignedMessage *warp.Envelope,
) (*types.Transaction, *types.Receipt, error)
```
CompleteValidatorRegistration is the last step of flow for adding a new validator.
### CompleteValidatorRemoval
```go
func CompleteValidatorRemoval(
rpcURL string,
managerAddress crypto.Address,
generateRawTxOnly bool,
ownerAddress crypto.Address,
privateKey string,
chainValidatorRegistrationSignedMessage *warp.Envelope,
useACP99 bool,
) (*types.Transaction, *types.Receipt, error)
```
### CompleteValidatorWeightChange
```go
func CompleteValidatorWeightChange(
rpcURL string,
managerAddress crypto.Address,
generateRawTxOnly bool,
ownerAddress crypto.Address,
privateKey string,
pchainL1ValidatorRegistrationSignedMessage *warp.Envelope,
) (*types.Transaction, *types.Receipt, error)
```
### DeployAndRegisterPoSValidatorManagerV1_0_0Contract
```go
func DeployAndRegisterPoSValidatorManagerV1_0_0Contract(
rpcURL string,
privateKey string,
proxyOwnerPrivateKey string,
) (luxcrypto.Address, error)
```
### DeployAndRegisterPoSValidatorManagerV2_0_0Contract
```go
func DeployAndRegisterPoSValidatorManagerV2_0_0Contract(
rpcURL string,
privateKey string,
proxyOwnerPrivateKey string,
) (luxcrypto.Address, error)
```
### DeployAndRegisterValidatorManagerV2_0_0Contract
```go
func DeployAndRegisterValidatorManagerV2_0_0Contract(
rpcURL string,
privateKey string,
proxyOwnerPrivateKey string,
) (luxcrypto.Address, error)
```
### DeployPoSValidatorManagerV1_0_0Contract
```go
func DeployPoSValidatorManagerV1_0_0Contract(
rpcURL string,
privateKey string,
) (luxcrypto.Address, error)
```
### DeployPoSValidatorManagerV2_0_0Contract
```go
func DeployPoSValidatorManagerV2_0_0Contract(
rpcURL string,
privateKey string,
) (luxcrypto.Address, error)
```
### DeployValidatorManagerV2_0_0Contract
```go
func DeployValidatorManagerV2_0_0Contract(
rpcURL string,
privateKey string,
) (luxcrypto.Address, error)
```
### FinishValidatorRegistration
```go
func FinishValidatorRegistration(
ctx context.Context,
app *application.Lux,
network models.Network,
rpcURL string,
chainSpec contract.ChainSpec,
generateRawTxOnly bool,
ownerAddressStr string,
privateKey string,
validationID ids.ID,
aggregatorLogger luxlog.Logger,
validatorManagerAddressStr string,
signatureAggregatorEndpoint string,
) (*types.Transaction, error)
```
### FinishValidatorRemoval
```go
func FinishValidatorRemoval(
ctx context.Context,
app *application.Lux,
network models.Network,
rpcURL string,
chainSpec contract.ChainSpec,
generateRawTxOnly bool,
ownerAddressStr string,
privateKey string,
validationID ids.ID,
aggregatorLogger luxlog.Logger,
validatorManagerAddressStr string,
useACP99 bool,
signatureAggregatorEndpoint string,
) (*types.Transaction, error)
```
### FinishValidatorWeightChange
```go
func FinishValidatorWeightChange(
ctx context.Context,
app *application.Lux,
network models.Network,
rpcURL string,
chainSpec contract.ChainSpec,
generateRawTxOnly bool,
ownerAddressStr string,
privateKey string,
validationID ids.ID,
aggregatorLogger luxlog.Logger,
validatorManagerAddressStr string,
l1ValidatorRegistrationSignedMessage *warp.Envelope,
weight uint64,
signatureAggregatorEndpoint string,
) (*types.Transaction, error)
```
### GetL1ValidatorUptimeSeconds
```go
func GetL1ValidatorUptimeSeconds(rpcURL string, nodeID ids.NodeID) (uint64, error)
```
GetL1ValidatorUptimeSeconds returns the uptime of the L1 validator
### GetL1ValidatorWeightMessage
```go
func GetL1ValidatorWeightMessage(
network models.Network,
aggregatorLogger luxlog.Logger,
unsignedMessage *warp.Message,
chainID ids.ID,
blockchainID ids.ID,
managerAddress crypto.Address,
validationID ids.ID,
nonce uint64,
weight uint64,
signatureAggregatorEndpoint string,
) (*warp.Envelope, error)
```
### GetL1ValidatorWeightMessageFromTx
```go
func GetL1ValidatorWeightMessageFromTx(
rpcURL string,
validationID ids.ID,
weight uint64,
txHash string,
) (*warp.Message, error)
```
### GetPChainChainToL1ConversionUnsignedMessage
```go
func GetPChainChainToL1ConversionUnsignedMessage(
net models.Network,
chainID ids.ID,
managerBlockchainID ids.ID,
managerAddress crypto.Address,
convertChainValidators []*txs.ConvertNetworkToL1Validator,
) (*warp.Message, error)
```
### GetPChainL1ValidatorRegistrationMessage
```go
func GetPChainL1ValidatorRegistrationMessage(
ctx context.Context,
network models.Network,
rpcURL string,
aggregatorLogger luxlog.Logger,
aggregatorQuorumPercentage uint64,
chainID ids.ID,
validationID ids.ID,
registered bool,
signatureAggregatorEndpoint string,
) (*warp.Envelope, error)
```
### GetPChainL1ValidatorWeightMessage
```go
func GetPChainL1ValidatorWeightMessage(
network models.Network,
aggregatorLogger luxlog.Logger,
aggregatorQuorumPercentage uint64,
chainID ids.ID,
l1SignedMessage *warp.Envelope,
validationID ids.ID,
nonce uint64,
weight uint64,
signatureAggregatorEndpoint string,
) (*warp.Envelope, error)
```
### GetRegisterL1ValidatorMessage
```go
func GetRegisterL1ValidatorMessage(
ctx context.Context,
rpcURL string,
network models.Network,
aggregatorLogger luxlog.Logger,
aggregatorQuorumPercentage uint64,
chainID ids.ID,
blockchainID ids.ID,
managerAddress crypto.Address,
nodeID ids.NodeID,
blsPublicKey [48]byte,
expiry uint64,
balanceOwners warpMessage.PChainOwner,
disableOwners warpMessage.PChainOwner,
weight uint64,
alreadyInitialized bool,
initiateTxHash string,
registerChainValidatorUnsignedMessage *warp.Message,
signatureAggregatorEndpoint string,
) (*warp.Envelope, ids.ID, error)
```
### GetRegisterL1ValidatorMessageFromTx
```go
func GetRegisterL1ValidatorMessageFromTx(
rpcURL string,
validationID ids.ID,
txHash string,
) (*warp.Message, error)
```
### GetRegistrationJustification
```go
func GetRegistrationJustification(
ctx context.Context,
rpcURL string,
validationID ids.ID,
chainID ids.ID,
) ([]byte, error)
```
### GetSpecializedValidatorProxyImplementation
```go
func GetSpecializedValidatorProxyImplementation(
rpcURL string,
) (crypto.Address, error)
```
### GetUptimeProofMessage
```go
func GetUptimeProofMessage(
network models.Network,
aggregatorLogger luxlog.Logger,
aggregatorQuorumPercentage uint64,
chainID ids.ID,
blockchainID ids.ID,
validationID ids.ID,
uptime uint64,
signatureAggregatorEndpoint string,
) (*warp.Envelope, error)
```
### GetValidatorManagerType
```go
func GetValidatorManagerType(
rpcURL string,
managerAddress crypto.Address,
) validatormanagertypes.ValidatorManagementType
```
GetValidatorManagerType returns validatormanagertypes.ProofOfAuthority if validator manager is verified to be Proof of Authority
If validator manager is verified to be Proof of Stake, returns validatormanagertypes.ProofOfStake
In other cases, returns validatormanagertypes.UndefinedValidatorManagement
### GetValidatorNonce
```go
func GetValidatorNonce(
ctx context.Context,
rpcURL string,
validationID ids.ID,
) (uint64, error)
```
### GetValidatorProxyImplementation
```go
func GetValidatorProxyImplementation(
rpcURL string,
) (crypto.Address, error)
```
### InitValidatorRegistration
```go
func InitValidatorRegistration(
ctx context.Context,
app *application.Lux,
network models.Network,
rpcURL string,
chainSpec contract.ChainSpec,
generateRawTxOnly bool,
ownerAddressStr string,
ownerPrivateKey string,
nodeID ids.NodeID,
blsPublicKey []byte,
expiry uint64,
balanceOwners warpMessage.PChainOwner,
disableOwners warpMessage.PChainOwner,
weight uint64,
aggregatorLogger luxlog.Logger,
isPos bool,
delegationFee uint16,
stakeDuration time.Duration,
rewardRecipient crypto.Address,
validatorManagerAddressStr string,
useACP99 bool,
initiateTxHash string,
signatureAggregatorEndpoint string,
) (*warp.Envelope, ids.ID, *types.Transaction, error)
```
### InitValidatorRemoval
```go
func InitValidatorRemoval(
ctx context.Context,
app *application.Lux,
network models.Network,
rpcURL string,
chainSpec contract.ChainSpec,
generateRawTxOnly bool,
ownerAddressStr string,
ownerPrivateKey string,
nodeID ids.NodeID,
aggregatorLogger luxlog.Logger,
isPoS bool,
uptimeSec uint64,
force bool,
validatorManagerAddressStr string,
useACP99 bool,
initiateTxHash string,
signatureAggregatorEndpoint string,
) (*warp.Envelope, ids.ID, *types.Transaction, error)
```
### InitValidatorWeightChange
```go
func InitValidatorWeightChange(
ctx context.Context,
printFunc func(msg string, args ...interface{}),
app *application.Lux,
network models.Network,
rpcURL string,
chainSpec contract.ChainSpec,
generateRawTxOnly bool,
ownerAddressStr string,
ownerPrivateKey string,
nodeID ids.NodeID,
aggregatorLogger luxlog.Logger,
validatorManagerAddressStr string,
weight uint64,
initiateTxHash string,
signatureAggregatorEndpoint string,
) (*warp.Envelope, ids.ID, *types.Transaction, error)
```
### InitializeValidatorRegistrationPoA
```go
func InitializeValidatorRegistrationPoA(
rpcURL string,
managerAddress crypto.Address,
generateRawTxOnly bool,
managerOwnerAddress crypto.Address,
managerOwnerPrivateKey string,
nodeID ids.NodeID,
blsPublicKey []byte,
expiry uint64,
balanceOwners warpMessage.PChainOwner,
disableOwners warpMessage.PChainOwner,
weight uint64,
useACP99 bool,
) (*types.Transaction, *types.Receipt, error)
```
InitializeValidatorRegistrationPoA is step 1 of flow for adding a new validator.
### InitializeValidatorRegistrationPoSNative
```go
func InitializeValidatorRegistrationPoSNative(
rpcURL string,
managerAddress crypto.Address,
managerOwnerPrivateKey string,
nodeID ids.NodeID,
blsPublicKey []byte,
expiry uint64,
balanceOwners warpMessage.PChainOwner,
disableOwners warpMessage.PChainOwner,
delegationFeeBips uint16,
minStakeDuration time.Duration,
stakeAmount *big.Int,
rewardRecipient crypto.Address,
useACP99 bool,
) (*types.Transaction, *types.Receipt, error)
```
### InitializeValidatorRemoval
```go
func InitializeValidatorRemoval(
rpcURL string,
managerAddress crypto.Address,
generateRawTxOnly bool,
managerOwnerAddress crypto.Address,
privateKey string,
validationID ids.ID,
isPoS bool,
uptimeProofSignedMessage *warp.Envelope,
force bool,
useACP99 bool,
) (*types.Transaction, *types.Receipt, error)
```
### InitializeValidatorWeightChange
```go
func InitializeValidatorWeightChange(
rpcURL string,
managerAddress crypto.Address,
generateRawTxOnly bool,
managerOwnerAddress crypto.Address,
privateKey string,
validationID ids.ID,
weight uint64,
) (*types.Transaction, *types.Receipt, error)
```
### InitializeValidatorsSet
```go
func InitializeValidatorsSet(
rpcURL string,
managerAddress crypto.Address,
privateKey string,
chainID ids.ID,
managerBlockchainID ids.ID,
convertChainValidators []*txs.ConvertNetworkToL1Validator,
chainConversionSignedMessage *warp.Envelope,
) (*types.Transaction, *types.Receipt, error)
```
InitializeValidatorsSet calls poa manager validators set init method,
passing to it the p-chain signed [chainConversionSignedMessage]
to verify p-chain already processed the associated ConvertNetworkToL1Tx
### PoAValidatorManagerInitialize
```go
func PoAValidatorManagerInitialize(
rpcURL string,
managerAddress crypto.Address,
privateKey string,
chainID ids.ID,
ownerAddress crypto.Address,
useACP99 bool,
) (*types.Transaction, *types.Receipt, error)
```
PoAValidatorManagerInitialize initializes contract [managerAddress] at [rpcURL], to
manage validators on [chainID], with
owner given by [ownerAddress]
### PoSValidatorManagerInitialize
```go
func PoSValidatorManagerInitialize(
rpcURL string,
managerAddress crypto.Address,
specializedManagerAddress crypto.Address,
managerOwnerPrivateKey string,
privateKey string,
chainID [32]byte,
posParams PoSParams,
useACP99 bool,
) (*types.Transaction, *types.Receipt, error)
```
PoSValidatorManagerInitialize initializes contract [managerAddress] at [rpcURL], to
manage validators on [chainID] using PoS specific settings.
### PoSWeightToValue
```go
func PoSWeightToValue(
rpcURL string,
managerAddress crypto.Address,
weight uint64,
) (*big.Int, error)
```
### SearchForL1ValidatorWeightMessage
```go
func SearchForL1ValidatorWeightMessage(
ctx context.Context,
rpcURL string,
validationID ids.ID,
weight uint64,
) (*warp.Message, error)
```
### SearchForRegisterL1ValidatorMessage
```go
func SearchForRegisterL1ValidatorMessage(
ctx context.Context,
rpcURL string,
validationID ids.ID,
) (*warp.Message, error)
```
### SetupPoA
```go
func SetupPoA(
log luxlog.Logger,
chain blockchainSDK.Net,
network models.Network,
privateKey string,
aggregatorLogger luxlog.Logger,
validatorManagerAddressStr string,
v2_0_0 bool,
signatureAggregatorEndpoint string,
) error
```
SetupPoA sets up PoA manager after a successful execution of
ConvertNetworkToL1Tx on P-Chain.
Needs the list of validators for that tx,
[convertChainValidators], together with an evm [ownerAddress]
to set as the owner of the PoA manager.
### SetupPoS
```go
func SetupPoS(
log luxlog.Logger,
chain blockchainSDK.Net,
network models.Network,
privateKey string,
aggregatorLogger luxlog.Logger,
posParams PoSParams,
managerAddress string,
specializedManagerAddress string,
managerOwnerPrivateKey string,
v2_0_0 bool,
signatureAggregatorEndpoint string,
) error
```
SetupPoS sets up PoS manager after a successful execution of
ConvertNetworkToL1Tx on P-Chain.
Needs the list of validators for that tx,
[convertChainValidators], together with an evm [ownerAddress]
to set as the owner of the PoS manager.
### SetupSpecializationProxyImplementation
```go
func SetupSpecializationProxyImplementation(
rpcURL string,
proxyManagerPrivateKey string,
validatorManager crypto.Address,
) (*types.Transaction, *types.Receipt, error)
```
### SetupValidatorProxyImplementation
```go
func SetupValidatorProxyImplementation(
rpcURL string,
proxyManagerPrivateKey string,
validatorManager crypto.Address,
) (*types.Transaction, *types.Receipt, error)
```
### ValidatorProxyHasImplementationSet
```go
func ValidatorProxyHasImplementationSet(
rpcURL string,
) (bool, error)
```
## Types
### ACP99ValidatorManagerSettings
### NativeTokenValidatorManagerSettingsV1_0_0
### NativeTokenValidatorManagerSettingsV2_0_0
### PoSParams
```go
func (p PoSParams) Verify() error
```
### ValidatorManagerSettings
@@ -0,0 +1,21 @@
---
title: vm
description: Package vm provides virtual machine SDK functionality.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/vm"
```
Package vm provides virtual machine SDK functionality.
## Types
### VM
VM represents a virtual machine instance.
@@ -0,0 +1,144 @@
---
title: wallet
description: Package wallet provides multi-chain wallet implementation.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/wallet"
```
Package wallet provides multi-chain wallet implementation.
## Types
### PQWallet
PQWallet is the post-quantum native wallet facade. It stores
PQAccounts (ML-DSA-65) and RecoveryAccounts (SLH-DSA-SHAKE-192s) by
their canonical 48-byte AccountID, exposes Sign on accounts by ID,
and is safe for concurrent use across goroutines.
PQWallet is intentionally separate from the secp256k1 Wallet type in
this package: classical-compat keys live in a strictly disjoint
keyring so a chain that refuses WalletSchemeSecp256k1 cannot
accidentally see one. Callers that mix classical and PQ keys hold
both Wallet and PQWallet instances.
```go
func NewPQWallet() *PQWallet
```
```go
func (w *PQWallet) Account(id account.AccountID) (*account.PQAccount, bool)
```
```go
func (w *PQWallet) AccountIDs() []account.AccountID
```
```go
func (w *PQWallet) AddAccount(a *account.PQAccount) error
```
```go
func (w *PQWallet) AddRecovery(r *account.RecoveryAccount) error
```
```go
func (w *PQWallet) Recovery(id account.AccountID) (*account.RecoveryAccount, bool)
```
```go
func (w *PQWallet) RemoveAccount(id account.AccountID) bool
```
```go
func (w *PQWallet) SignTx(id account.AccountID, env account.TxAuthEnvelope) error
```
### TransferInput
TransferInput represents an input to a transfer transaction
### TransferOutput
TransferOutput represents an output from a transfer transaction
### TransferTx
TransferTx represents a transfer transaction
### UTXO
UTXO represents an unspent transaction output
### Wallet
Wallet manages keys and transactions for personal usage
```go
func New(networkID uint32, chainID ids.ID) *Wallet
```
```go
func (w *Wallet) AddUTXO(utxo *UTXO)
```
```go
func (w *Wallet) CreateTransferTx(
to ids.ShortID,
assetID ids.ID,
amount uint64,
memo []byte,
) (*TransferTx, error)
```
```go
func (w *Wallet) GenerateKey() (ids.ShortID, error)
```
```go
func (w *Wallet) GetAddress() (ids.ShortID, error)
```
```go
func (w *Wallet) GetAllAddresses() []ids.ShortID
```
```go
func (w *Wallet) GetBLSKey() (*bls.SecretKey, error)
```
```go
func (w *Wallet) GetBalance(assetID ids.ID) uint64
```
```go
func (w *Wallet) GetUTXOs(assetID ids.ID, amount uint64) ([]*UTXO, uint64, error)
```
```go
func (w *Wallet) ImportKey(privateKey crypto.PrivateKey) (ids.ShortID, error)
```
```go
func (w *Wallet) RemoveUTXO(utxoID ids.ID)
```
```go
func (w *Wallet) SetBLSKey(key *bls.SecretKey)
```
```go
func (w *Wallet) Sign(ctx context.Context, tx chain.Transaction) error
```
@@ -0,0 +1,49 @@
---
title: warp
description: Package warp provides warp message signing and aggregation utilities.
---
{/* Generated from godoc by tools/docgen — edit the Go source, not this file. */}
```go
import "github.com/luxfi/sdk/warp"
```
Package warp provides warp message signing and aggregation utilities.
## Functions
### SignMessage
```go
func SignMessage(logger luxlog.Logger, signatureAggregatorEndpoint string, message, justification, signingChainID string, quorumPercentage uint64) (*warp.Envelope, error)
```
SignMessage sends a request to the signature aggregator to sign a message.
It returns the signed warp message or an error if the operation fails.
## Types
### AggregateSignatureRequest
AggregateSignatureRequest defines the request structure for signature aggregation
### AggregateSignatureResponse
AggregateSignatureResponse defines the response structure for signature aggregation
### Client
Client interface for interacting with the IPCS endpoint
Deprecated: The IPCs API is deprecated. The Index API should be used instead.
```go
func NewClient(uri string) Client
```
-97
View File
@@ -1,97 +0,0 @@
---
title: Wallet
description: Multi-chain wallet operations with the Go SDK
---
The Go SDK wallet (`github.com/luxfi/sdk/wallet`) manages keys and transactions across all Lux chain types. It supports UTXO-based chains (X-Chain), the Platform chain (P-Chain), and EVM chains (C-Chain, chains).
## Create a Wallet
```go
package main
import (
"github.com/luxfi/ids"
"github.com/luxfi/sdk/wallet"
"github.com/luxfi/sdk/crypto"
)
func main() {
// Create wallet for mainnet C-Chain
w := wallet.New(1, ids.Empty) // networkID, chainID
// Import an existing private key
privKey, _ := crypto.GeneratePrivateKey()
addr, _ := w.ImportKey(privKey)
// Or generate a new key
addr, _ = w.GenerateKey()
}
```
## Check Balance
```go
// Get balance for a specific asset
balance := w.GetBalance(assetID)
fmt.Printf("Balance: %d\n", balance)
```
## Build and Sign Transfers
```go
// Create a transfer transaction
tx, err := w.CreateTransferTx(
recipientAddr, // ids.ShortID
assetID, // ids.ID
1000000, // amount in smallest unit
[]byte("memo"), // optional memo
)
if err != nil {
return fmt.Errorf("failed to create transfer: %w", err)
}
// Sign the transaction
err = w.Sign(ctx, tx)
```
## BLS Keys for Validators
Validator operations require a BLS key for consensus participation:
```go
import "github.com/luxfi/crypto/bls"
// Generate BLS key pair
blsKey, _ := bls.NewSecretKey()
w.SetBLSKey(blsKey)
// Retrieve BLS key for staking registration
key, _ := w.GetBLSKey()
```
## Key Types
| Type | Curve | Use Case |
|------|-------|----------|
| Ed25519 | Curve25519 | General signing, address derivation |
| BLS | BLS12-381 | Consensus signatures, aggregation |
| secp256k1 | secp256k1 | EVM transaction signing |
## UTXO Management
The wallet automatically selects UTXOs when building transactions:
```go
// Get available UTXOs for an asset
utxos, totalAmount, err := w.GetUTXOs(assetID, requiredAmount)
if err == wallet.ErrInsufficientFunds {
fmt.Println("Not enough funds")
}
```
## Related Pages
- [Key Derivation](/wallet/keys) -- BIP-44 HD derivation paths
- [Transactions](/sdk/go/transactions) -- Transaction building details
- [Ledger](/wallet/ledger) -- Hardware wallet integration