aureum

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

README

Aureum

Aureum is a GO library for building and evaluating Cardano Plutus scripts.

It leverages wasm to use the uplc crate.

For executing wasm, this makes use of wazero, the zero dependency WebAssembly runtime for Go developers.

Usage

See the example folder for more details.

You can get the latest version of aureum like this.

go get github.com/mgpai22/aureum@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTxFromBytes

func GetTxFromBytes(txBytes []byte) (*Transaction.Transaction, error)

func GetUtxosFromTx

func GetUtxosFromTx(ctx context.Context, txBytes []byte, chainContext base.ChainContext) ([]apolloUTxO.UTxO, error)

GetUtxosFromTx extracts UTxOs from transaction bytes using the provided chain context

func ParseUTxOsFromJSON

func ParseUTxOsFromJSON(jsonData []byte, inputs []TransactionInput.TransactionInput) ([]apolloUTxO.UTxO, error)

ParseUTxOsFromJSON parses UTxOs from a JSON file and returns Apollo UTxO objects

Types

type AssetJSON

type AssetJSON struct {
	Unit     string `json:"unit"`
	Quantity int64  `json:"quantity"`
}

type Budget

type Budget struct {
	Mem uint64 `cbor:"mem"`
	CPU uint64 `cbor:"cpu"`
}

type EvalError

type EvalError struct {
	ErrorType  string   `cbor:"error_type"`
	Budget     Budget   `cbor:"budget"`
	DebugTrace []string `cbor:"debug_trace"`
}

type EvaluationError

type EvaluationError struct {
	EvalError EvalError
}

func (*EvaluationError) Error

func (e *EvaluationError) Error() string

type Evaluator

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

func NewEvaluator

func NewEvaluator(ctx context.Context, config EvaluatorConfig) (*Evaluator, error)

func (*Evaluator) Close

func (e *Evaluator) Close(ctx context.Context)

Close terminates the WASM runtime and releases resources.

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(ctx context.Context, txBytes []byte, utxos []apolloUTxO.UTxO) ([][]byte, error)

Evaluate processes the transaction bytes and returns redeemers as bytes.

type EvaluatorConfig

type EvaluatorConfig struct {
	WasmFile     *string // Optional path to custom WASM file
	CostModels   []byte  // Serialized cost models
	MaxTxExSteps uint64  // Maximum transaction execution steps
	MaxTxExMem   uint64  // Maximum transaction execution memory
	ZeroTime     uint64  // Zero time parameter
	ZeroSlot     uint64  // Zero slot parameter
	SlotLength   uint64  // Slot length parameter
}

EvaluatorConfig holds configuration parameters for the Evaluator.

type OutputJSON

type OutputJSON struct {
	TxHash      string      `json:"tx_hash"`
	OutputIndex int         `json:"output_index"`
	Address     string      `json:"address"`
	Amount      []AssetJSON `json:"amount"`
	InlineDatum string      `json:"inline_datum"`
	DataHash    string      `json:"data_hash"`
}

type ScriptRef

type ScriptRef struct {
	ScriptType string `json:"script_type"`
	Script     string `json:"script"`
}

type UTxO

type UTxO struct {
	Address     string            `json:"address"`
	TxHash      string            `json:"tx_hash"`
	OutputIndex uint64            `json:"output_index"`
	DatumHash   *string           `json:"datum_hash,omitempty"`
	Datum       *string           `json:"datum,omitempty"`
	ScriptRef   *ScriptRef        `json:"script_ref,omitempty"`
	Assets      map[string]uint64 `json:"assets"`
}

type UTxOJSON

type UTxOJSON struct {
	Hash    string       `json:"hash"`
	Outputs []OutputJSON `json:"outputs"`
}

Directories

Path Synopsis
example
failure command
success command

Jump to

Keyboard shortcuts

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