PlutusData

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 15 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COST_MODELSV1 = map[serialization.CustomBytes]cbor.Marshaler{
	{Value: "00"}: PLUTUSV1COSTMODEL,
}
View Source
var COST_MODELSV2 = map[int]cbor.Marshaler{1: PLUTUSV2COSTMODEL}
View Source
var PLUTUSV1COSTMODEL = CM{}/* 166 elements not displayed */
View Source
var PLUTUSV2COSTMODEL = CostView{}/* 175 elements not displayed */
View Source
var PLUTUSV3COSTMODEL = CostModelArray(
	[]int32{
		100788,
		420,
		1,
		1,
		1000,
		173,
		0,
		1,
		1000,
		59957,
		4,
		1,
		11183,
		32,
		201305,
		8356,
		4,
		16000,
		100,
		16000,
		100,
		16000,
		100,
		16000,
		100,
		16000,
		100,
		16000,
		100,
		100,
		100,
		16000,
		100,
		94375,
		32,
		132994,
		32,
		61462,
		4,
		72010,
		178,
		0,
		1,
		22151,
		32,
		91189,
		769,
		4,
		2,
		85848,
		123203,
		7305,
		-900,
		1716,
		549,
		57,
		85848,
		0,
		1,
		1,
		1000,
		42921,
		4,
		2,
		24548,
		29498,
		38,
		1,
		898148,
		27279,
		1,
		51775,
		558,
		1,
		39184,
		1000,
		60594,
		1,
		141895,
		32,
		83150,
		32,
		15299,
		32,
		76049,
		1,
		13169,
		4,
		22100,
		10,
		28999,
		74,
		1,
		28999,
		74,
		1,
		43285,
		552,
		1,
		44749,
		541,
		1,
		33852,
		32,
		68246,
		32,
		72362,
		32,
		7243,
		32,
		7391,
		32,
		11546,
		32,
		85848,
		123203,
		7305,
		-900,
		1716,
		549,
		57,
		85848,
		0,
		1,
		90434,
		519,
		0,
		1,
		74433,
		32,
		85848,
		123203,
		7305,
		-900,
		1716,
		549,
		57,
		85848,
		0,
		1,
		1,
		85848,
		123203,
		7305,
		-900,
		1716,
		549,
		57,
		85848,
		0,
		1,
		955506,
		213312,
		0,
		2,
		270652,
		22588,
		4,
		1457325,
		64566,
		4,
		20467,
		1,
		4,
		0,
		141992,
		32,
		100788,
		420,
		1,
		1,
		81663,
		32,
		59498,
		32,
		20142,
		32,
		24588,
		32,
		20744,
		32,
		25933,
		32,
		24623,
		32,
		43053543,
		10,
		53384111,
		14333,
		10,
		43574283,
		26308,
		10,
		16000,
		100,
		16000,
		100,
		962335,
		18,
		2780678,
		6,
		442008,
		1,
		52538055,
		3756,
		18,
		267929,
		18,
		76433006,
		8868,
		18,
		52948122,
		18,
		1995836,
		36,
		3227919,
		12,
		901022,
		1,
		166917843,
		4307,
		36,
		284546,
		36,
		158221314,
		26549,
		36,
		74698472,
		36,
		333849714,
		1,
		254006273,
		72,
		2174038,
		72,
		2261318,
		64571,
		4,
		207616,
		8310,
		4,
		1293828,
		28716,
		63,
		0,
		1,
		1006041,
		43623,
		251,
		0,
		1,
		100181,
		726,
		719,
		0,
		1,
		100181,
		726,
		719,
		0,
		1,
		100181,
		726,
		719,
		0,
		1,
		107878,
		680,
		0,
		1,
		95336,
		1,
		281145,
		18848,
		0,
		1,
		180194,
		159,
		1,
		1,
		158519,
		8942,
		0,
		1,
		159378,
		8813,
		0,
		1,
		107490,
		3298,
		1,
		106057,
		655,
		1,
		1964219,
		24520,
		3,
	},
)

Functions

func HashDatum

func HashDatum(d cbor.Marshaler) (serialization.DatumHash, error)

*

HashDatum computes the hash of a CBOR marshaler using the Blake2b algorithm.

Params:
	d (cbor.Marshaler): The CBOR marshaler to be hashed

Returns:
	serialization.DatumHash: The hash of the CBOR marshaler.
	error: An error if the hash Datum fails.

func PlutusDataHash

func PlutusDataHash(pd *PlutusData) (serialization.DatumHash, error)

*

	PlutusDataHash computes the hash of a PlutusData structure using the Blake2b algorithm.

 	Params:

	   	pd (*PlutusData): A pointer to the PlutusData structure to be hashed.

	Returns:
  		serialization.DatumHash: The hash of the PlutusData.
		error: An error if the PlutusDataHash fails.

func PlutusScriptHash

func PlutusScriptHash(script ScriptHashable) serialization.ScriptHash

*

PlutusScriptHash computes the script hash of a ScriptHashable object.

Params:
	script (ScriptHashable): The ScriptHashable object to be hashed.

Returns:
	serialization.ScriptHash: The script hash of the ScriptHashable object.

func ToCbor

func ToCbor(x any) (string, error)

*

ToCbor converts the given interface to a hexadecimal-encoded CBOR string.

Params:
	x (interface{}): The input value to be encoded to CBOR to converted
					 to a hexadecimal string.

Returns:
	string: The hexadecimal-encoded CBOR representation of the input value.
	error: An error if the conversion fails.

Types

type CM

type CM map[string]int

func (CM) MarshalCBOR

func (cm CM) MarshalCBOR() ([]byte, error)

*

MarshalCBOR encodes the CM into a CBOR-encoded byte slice, in which
it serializes the map key alphabetically and encodes the respective values.

Returns:
	[]byte: The CBOR-encoded byte slice.
	error: An error if marshaling fails.

type CostModelArray added in v1.3.0

type CostModelArray []int32

func (CostModelArray) MarshalCBOR added in v1.3.0

func (cma CostModelArray) MarshalCBOR() ([]byte, error)

type CostModels

type CostModels map[serialization.CustomBytes]CM

type CostView

type CostView map[string]int

func (CostView) MarshalCBOR

func (cv CostView) MarshalCBOR() ([]byte, error)

*

MarshalCBOR encodes the CostView into a CBOR-encoded byte slice, in which
it serializes the map key alphabetically and encodes the respective values.

Returns:
	[]byte: The CBOR-encoded byte slice.
	error: An error if marshaling fails.

type Datum

type Datum struct {
	PlutusDataType PlutusType
	TagNr          uint64
	Value          any
}

func (*Datum) Clone

func (pd *Datum) Clone() Datum

*

Clone creates a deep copy of the Datum>

Returns:
	Datum: A deep copy of the Datum

func (Datum) MarshalCBOR

func (pd Datum) MarshalCBOR() ([]uint8, error)

*

MarshalCBOR encodes the Datum into a CBOR-encoded byte slice,

	it applies a CBOR tag, if TagNr is not 0, otherwise it marshals the Value

	Returns:
   		[]uint8: The CBOR-encoded byte slice.
   		error: An error if marshaling fails.

func (*Datum) ToPlutusData

func (pd *Datum) ToPlutusData() PlutusData

*

ToPlutusData converts a datum to PlutusData, encoding
the Datum into CBOR format and then decodes it into a
PlutusData.

Returns:
	PlutusData: The converted PlutusData.

func (*Datum) UnmarshalCBOR

func (pd *Datum) UnmarshalCBOR(value []uint8) error

*

UnmarshalCBOR decodes a CBOR-encoded byte slice into a Datum.

	It handles different Plutus data types and applies appropriate decoding logic.

	Returns:
   		error: An error if unmarshaling fails.

type DatumOption added in v1.0.5

type DatumOption struct {
	DatumType DatumType
	Hash      []byte
	Inline    *PlutusData
	// contains filtered or unexported fields
}

func DatumOptionHash added in v1.0.5

func DatumOptionHash(hash []byte) DatumOption

func DatumOptionInline added in v1.0.5

func DatumOptionInline(pd *PlutusData) DatumOption

func (DatumOption) MarshalCBOR added in v1.0.5

func (d DatumOption) MarshalCBOR() ([]byte, error)

func (*DatumOption) UnmarshalCBOR added in v1.0.5

func (d *DatumOption) UnmarshalCBOR(b []byte) error

type DatumType added in v1.0.5

type DatumType byte
const (
	DatumTypeHash   DatumType = 0
	DatumTypeInline DatumType = 1
)

type PlutusData

type PlutusData struct {
	PlutusDataType PlutusType
	TagNr          uint64
	Value          any
}

func (*PlutusData) Clone

func (pd *PlutusData) Clone() PlutusData

*

Clone creates a deep copy of a PlutusData object.

Returns:
	PlutusData: A cloned PlutusData object.

func (*PlutusData) Equal added in v1.0.3

func (pd *PlutusData) Equal(other PlutusData) bool

*

Equal check if two PlutusData values are equal
using their CBOR representations.

Params:
	other (PlutusData): The other PlutusData to compare to.

Returns:
	bool: True if the PlutusData are equal, false otherwise.

func (*PlutusData) MarshalCBOR

func (pd *PlutusData) MarshalCBOR() ([]uint8, error)

*

MarshalCBOR encodes the PlutusData into a CBOR byte slice.

Returns:
	[]uint8: The CBOR-encoded byte slice.
	error: An error, if any, during ecoding.

func (*PlutusData) String added in v1.0.12

func (pd *PlutusData) String() string

func (*PlutusData) ToDatum

func (pd *PlutusData) ToDatum() Datum

*

ToDatum converts a PlutusData to a Datum, in which
it encodes the PlutusData into CBOR format and later
into a Datum.

Returns:
	Datum: The converted Datum.

func (*PlutusData) UnmarshalCBOR

func (pd *PlutusData) UnmarshalCBOR(value []uint8) error

*

	UnmarshalCBOR unmarshals CBOR-encoded data into a PlutusData object.

	Params:
   		value ([]uint8): The CBOR-encoded data to unmarshal.

 	Returns:
   		error: An error, if any, during unmarshaling.

func (*PlutusData) UnmarshalJSON added in v1.0.3

func (pd *PlutusData) UnmarshalJSON(value []byte) error

*

	UnmarshalJSON unmarshals JSON-encoded PlutusData into a PlutusData object.

	Params:
   		value ([]byte): The JSON-encoded data to unmarshal.

 	Returns:
   		error: An error, if any, during unmarshaling.

type PlutusDataKey added in v1.0.12

type PlutusDataKey struct {
	CborHexValue string
}

func (*PlutusDataKey) MarshalCBOR added in v1.0.12

func (pdk *PlutusDataKey) MarshalCBOR() ([]uint8, error)

func (*PlutusDataKey) String added in v1.0.12

func (pdk *PlutusDataKey) String() string

func (*PlutusDataKey) UnmarshalCBOR added in v1.0.12

func (pdk *PlutusDataKey) UnmarshalCBOR(value []uint8) error

type PlutusDefArray added in v1.0.3

type PlutusDefArray []PlutusData

func (PlutusDefArray) Len added in v1.0.3

func (pia PlutusDefArray) Len() int

*

Len returns the length of the PlutusDefArray.

Returns:
	int: The length of the PlutusDefArray.

type PlutusIndefArray

type PlutusIndefArray []PlutusData

func (*PlutusIndefArray) Clone

func (pia *PlutusIndefArray) Clone() PlutusIndefArray

*

Clone creates a deep copy of the PlutusIndefArray.

Returns:
	PlutusIndefArray: A deep copy of the PlutusIndefArray.

func (PlutusIndefArray) Len added in v1.0.3

func (pia PlutusIndefArray) Len() int

*

Len returns the length of the PlutusIndefArray.

Returns:
	int: The length of the PlutusIndefArray.

func (PlutusIndefArray) MarshalCBOR

func (pia PlutusIndefArray) MarshalCBOR() ([]uint8, error)

*

MarshalCBOR encodes the PlutusIndefArray into a CBOR-encoded byte

	slice, in which it serializes the elements in indefinite-length array format.

	Returns:
   		[]uint8: The CBOR-encoded byte slice.
   		error: An error if marshaling fails.

type PlutusList added in v1.0.3

type PlutusList interface {
	Len() int
}

type PlutusType

type PlutusType int
const (
	PlutusArray PlutusType = iota
	PlutusMap
	PlutusIntMap
	PlutusInt
	PlutusBigInt
	PlutusBytes
	PlutusShortArray
)

type PlutusV1Script

type PlutusV1Script []byte

func (PlutusV1Script) Hash

*

 	Hash computes the script hash for a PlutusV1Script.

 	Returns:
   		serialization.ScriptHash: The script hash of the PlutusV1Script.
		error: An error if the hashing fails.

func (*PlutusV1Script) ToAddress added in v1.0.3

func (ps *PlutusV1Script) ToAddress(stakingCredential []byte) Address.Address

*

	ToAddress converts a PlutusV1Script to an Address with an optional staking credential.

 	Params:

  		stakingCredential ([]byte): The staking credential to include in the address.

	Returns:
  		Address.Address: The generated address.

type PlutusV2Script

type PlutusV2Script []byte

func (PlutusV2Script) Hash

*

 	Hash computes the script hash for a PlutusV2Script.

 	Returns:
   		serialization.ScriptHash: The script hash of the PlutusV2Script.
		error: An error if the Hashing fails.

func (*PlutusV2Script) ToAddress added in v1.0.3

func (ps *PlutusV2Script) ToAddress(
	stakingCredential []byte,
	network constants.Network,
) Address.Address

*

	ToAddress converts a PlutusV2Script to an Address with an optional staking credential.

 	Params:

  		stakingCredential ([]byte): The staking credential to include in the address.

	Returns:
  		Address.Address: The generated address.

type PlutusV3Script added in v1.3.0

type PlutusV3Script []byte

func (PlutusV3Script) Hash added in v1.3.0

func (*PlutusV3Script) ToAddress added in v1.3.0

func (ps3 *PlutusV3Script) ToAddress(
	stakingCredential []byte,
	network constants.Network,
) Address.Address

type RawPlutusData

type RawPlutusData struct {
}

type ScriptHashable

type ScriptHashable interface {
	Hash() (serialization.ScriptHash, error)
}

type ScriptRef

type ScriptRef []byte

func (ScriptRef) Len added in v1.1.0

func (sr ScriptRef) Len() int

Jump to

Keyboard shortcuts

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