plutusv4script

package
v0.92.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package plutusv4script builds PlutusV4 scripts that inspect the ScriptContext, shared by the era validation tests and the ledger tests that drive the same scripts through block application, replay and the mempool.

Index

Constants

View Source
const (
	DirectDepositsField   = 8
	BalanceIntervalsField = 9
	RequiredGuardsField   = 12
)

TxInfo field positions of the Dijkstra account maps.

Variables

This section is empty.

Functions

func ContextScript

func ContextScript(
	t testing.TB,
	cond func(ctx Term) Term,
) lcommon.PlutusV4Script

ContextScript builds a PlutusV4 script that succeeds only when cond, evaluated against the ScriptContext, is true.

func MapOrderScript

func MapOrderScript(
	t testing.TB,
	fieldIndex int,
) lcommon.PlutusV4Script

MapOrderScript succeeds only when the TxInfo map at fieldIndex lists a script credential (Constr 1) first and a key credential (Constr 0) second. The reference orders script entries before key entries, which is the reverse of the credential type numbers.

func MaybeScript

func MaybeScript(
	t testing.TB,
	sel func(ctx Term) Term,
	tag int64,
) lcommon.PlutusV4Script

MaybeScript succeeds when the Maybe selected by sel has the given constructor tag: 0 is Just, 1 is Nothing. It compares the tag rather than the whole value, because Just carries a field and so never equals a bare Constr 0.

func ScriptCredential

func ScriptCredential(s lcommon.Script) lcommon.Credential

ScriptCredential is the credential naming the script.

Types

type Term

type Term = syn.Term[syn.DeBruijn]

Term is a script term over de Bruijn indices.

func Apply

func Apply(fn builtin.DefaultFunction, args ...Term) Term

Apply applies a builtin to its arguments, forcing it as often as its polymorphism requires.

func BoolConstant

func BoolConstant(b bool) Term

BoolConstant is a boolean literal.

func ConstrFields

func ConstrFields(term Term) Term

ConstrFields returns the field list of a Constr. Only sum types, such as ScriptInfo and credentials, are still constructors in V4.

func Field

func Field(list Term, index int) Term

Field selects the index-th element of a list.

func GuardingTopTxInfo

func GuardingTopTxInfo(ctx Term) Term

GuardingTopTxInfo selects the TopTxInfo of a GuardingScript purpose.

func IntConstant

func IntConstant(n int64) Term

IntConstant is an integer literal.

func ListFields added in v0.83.1

func ListFields(term Term) Term

ListFields returns the fields of a single-constructor V4 type, which the context encodes as a Data list: ScriptContext, TxInfo and the other product types.

func TxInfoSubTxIx

func TxInfoSubTxIx(ctx Term) Term

TxInfoSubTxIx selects txInfoSubTxIx from the ScriptContext. The V4 selectors follow plutus-ledger-api 1.70.0.0, PlutusLedgerApi.V4.Contexts: ScriptContext and TxInfo use makeIsDataSchemaAsList; ScriptInfo retains indexed constructors.

Jump to

Keyboard shortcuts

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