Skip to main content

Crate pallas_primitives

Crate pallas_primitives 

Source
Expand description

Era-aware Cardano ledger types with their CBOR codecs.

This is the data layer that the rest of the Pallas ledger crates sit on: pallas-traverse gives you a multi-era read API over these types, pallas-validate applies ledger rules to them, and pallas-txbuilder builds new ones.

If you need raw, era-specific access to a Tx, Block, or PlutusData, you want this crate. If you’d rather work over many eras through one interface, reach for pallas-traverse.

§Usage

use pallas_codec::minicbor;
use pallas_primitives::conway;

let tx: conway::Tx = minicbor::decode(&cbor_bytes)?;

for input in tx.transaction_body.inputs.iter() {
    println!("{:?}#{}", input.transaction_id, input.index);
}

§Overview

§Feature flags

  • relaxed — relax some validation invariants applied during decoding; useful for round-tripping non-canonical historical artifacts.

§Usage as part of pallas

When depending on the umbrella pallas crate, this crate is re-exported as pallas::ledger::primitives.

Modules§

alonzo
Ledger primitives for the Alonzo era (smart contracts).
babbage
Ledger primitives for the Babbage era (reference inputs / inline datums).
byron
Ledger primitives for the Byron era. Ledger primitives and cbor codec for the Byron era
conway
Ledger primitives for the Conway era (governance).

Macros§

codec_by_datatype
Derive a minicbor Decode/Encode implementation for an enum by dispatching on the incoming CBOR datatype.

Structs§

BoundedBytes
Defined to encode PlutusData bytestring as it is done in the canonical plutus implementation
Bytes
Constr
ExUnitPrices
Per-unit prices used to convert ExUnits into fee lovelace.
ExUnits
Plutus script execution budget: memory and step units.
Hash
data that is a cryptographic Hash of BYTES long.
Int
KeepRaw
Decodes a struct while preserving original CBOR
NonEmptySet
Non-empty Set
NonZeroInt
Introduced in Conway negInt64 = -9223372036854775808 .. -1 posInt64 = 1 .. 9223372036854775807 nonZeroInt64 = negInt64 / posInt64 ; this is the same as the current int64 definition but without zero
Nonce
Praos nonce used as input to the leader-selection schedule.
PlutusScript
Raw bytes of a Plutus script of language version VERSION (1, 2, or 3).
PoolMetadata
Stake pool metadata reference: URL plus the hash of the pointed-to JSON.
PositiveCoin
Introduced in Conway positive_coin = 1 .. 18446744073709551615
RationalNumber
On-chain rational number, encoded as a CBOR tag-30 array of [num, den].
Set
Set
TransactionInput
Reference to a transaction output: (tx_hash, output_index).
VrfCert
VRF certificate: the output bytes followed by the proof bytes.

Enums§

BigInt
KeyValuePairs
Custom collection to ensure ordered pairs of values
MaybeIndefArray
A struct that maintains a reference to whether a cbor array was indef or not
Metadatum
Single metadata value of any supported CBOR shape.
NetworkId
The network this artifact targets (encoded as a small CBOR enum).
NonceVariant
Discriminator for Nonce: neutral (genesis) or hashed.
Nullable
PlutusData
Relay
Network endpoint declared by a stake pool’s relay.
StakeCredential
On-chain credential controlling a stake address: a script or a key hash.

Traits§

Fragment
ToCanonicalJson

Type Aliases§

AddrKeyhash
Hash of a Cardano address verification key (Blake2b-224).
AssetName
Token name within a multi-asset bundle (raw bytes, up to 32 long).
Coin
Quantity in lovelace.
CostModel
Plutus cost model: ordered list of per-primitive cost coefficients.
DatumHash
Hash of a Plutus datum (Blake2b-256).
DnsName
DNS name (A or SRV record) used in relay declarations.
Epoch
Epoch number on the Cardano chain.
Error
GenesisDelegateHash
Hash of a genesis delegate certificate.
Genesishash
Hash identifying a genesis configuration.
IPv4
IPv4 address bytes (4 bytes, big-endian).
IPv6
IPv6 address bytes (16 bytes, big-endian).
Metadata
Transaction metadata map, keyed by label.
MetadatumLabel
Top-level metadata label (CIP-10 / CIP-25 / etc.).
PolicyId
Hash of a minting policy (Blake2b-224).
PoolKeyhash
Hash of a stake pool’s cold key (Blake2b-224).
PoolMetadataHash
Hash of stake pool metadata (Blake2b-256).
Port
TCP/UDP port number.
PositiveInterval
Rational number guaranteed to be strictly positive.
ProtocolVersion
Protocol version: (major, minor).
RewardAccount
Reward-account bytes (network header byte plus stake-credential hash).
ScriptHash
Hash of a script (Blake2b-224).
TransactionIndex
Index of a transaction within its containing block.
UnitInterval
Rational number constrained to the closed interval [0, 1].
VrfKeyhash
Hash of a VRF verification key (Blake2b-256).