genesis

package
v1.27.20 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package genesis builds X-Chain (XVM) genesis bytes from a small, caller-supplied descriptor. It exists so callers (e.g. the node's primary-network genesis builder) do not have to import the xvm package directly to construct primary-asset genesis blobs — the asset shape lives here, in the same module tree as the codec that serializes it.

The package is intentionally narrow: it owns the AssetDescriptor + Holder + BuildBytes contract, and nothing else. Bech32 formatting, allocation sorting, memo composition, and the "is X-Chain opt-in for this network?" policy all stay in the caller — those are network-level concerns, not XVM concerns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetIDFromBytes

func AssetIDFromBytes(genesisBytes []byte) (ids.ID, error)

AssetIDFromBytes returns the runtime X-Chain native asset ID derived from the canonical XVM genesis bytes (the same blob BuildBytes produces). This is the value vm.initGenesis assigns to the first genesis CreateAssetTx — the ID under which the X-Chain's fee asset is indexed in state.

Callers (genesis/builder, config.getGenesisData) use this to derive the X-Chain native asset ID from genesis content rather than constants.UTXOAssetIDFor(networkID). On sovereign L1s the two values differ: the constant is network-id-keyed and identical across every L1 sharing a primary-network ID, while the genesis-derived ID captures the asset's actual on-chain identity (different per L1).

func BuildBytes

func BuildBytes(
	networkID uint32,
	asset AssetDescriptor,
	holders []Holder,
	memo []byte,
) ([]byte, error)

BuildBytes constructs the canonical XVM genesis bytes for a network whose primary asset is `asset`, with the supplied initial fixed-cap holders and an optional opaque memo. The asset is registered in the genesis under `asset.Symbol` (the same key callers use today).

The returned bytes are stable across calls with identical inputs because xvm.NewGenesis sorts both the asset set and each asset's states deterministically.

Types

type AssetDescriptor

type AssetDescriptor struct {
	Name         string `json:"name"`
	Symbol       string `json:"symbol"`
	Denomination byte   `json:"denomination"`
}

AssetDescriptor is the JSON-shaped primary-asset descriptor that callers carry on their network config (e.g. genesiscfg.XChainGenesis). The JSON tags mirror the existing on-disk xChainGenesis shard shape:

{"symbol":"LUX","name":"Lux","denomination":9}

type Holder

type Holder struct {
	Amount  uint64
	Address string
}

Holder is one (bech32-address, amount) initial fixed-cap holder. Address is the already-formatted bech32 string for the target network's HRP — this package does no HRP resolution.

Jump to

Keyboard shortcuts

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