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
byron,alonzo,babbage,conway— one module per era, each exposing the era’sBlock,Tx,TransactionInput,TransactionOutput,Value,Certificate,Metadata, witness sets, and so on.plutus_data— re-exportedPlutusData,BigInt, and helpers shared across eras.framework— common type aliases and codec primitives (AddrKeyhash,Coin,PolicyId,RationalNumber,StakeCredential,TransactionInput,ExUnits,PlutusScript, …).- Re-exports from
pallas-codec(Bytes,KeepRaw,KeyValuePairs,NonEmptySet,Set,Nullable, …) andpallas-crypto(Hash).
§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
minicborDecode/Encodeimplementation for an enum by dispatching on the incoming CBOR datatype.
Structs§
- Bounded
Bytes - Defined to encode PlutusData bytestring as it is done in the canonical plutus implementation
- Bytes
- Constr
- ExUnit
Prices - Per-unit prices used to convert
ExUnitsinto fee lovelace. - ExUnits
- Plutus script execution budget: memory and step units.
- Hash
- data that is a cryptographic
HashofBYTESlong. - Int
- KeepRaw
- Decodes a struct while preserving original CBOR
- NonEmpty
Set - Non-empty Set
- NonZero
Int - 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.
- Plutus
Script - Raw bytes of a Plutus script of language version
VERSION(1, 2, or 3). - Pool
Metadata - Stake pool metadata reference: URL plus the hash of the pointed-to JSON.
- Positive
Coin - Introduced in Conway positive_coin = 1 .. 18446744073709551615
- Rational
Number - On-chain rational number, encoded as a CBOR tag-30 array of
[num, den]. - Set
- Set
- Transaction
Input - Reference to a transaction output:
(tx_hash, output_index). - VrfCert
- VRF certificate: the output bytes followed by the proof bytes.
Enums§
- BigInt
- KeyValue
Pairs - Custom collection to ensure ordered pairs of values
- Maybe
Indef Array - A struct that maintains a reference to whether a cbor array was indef or not
- Metadatum
- Single metadata value of any supported CBOR shape.
- Network
Id - The network this artifact targets (encoded as a small CBOR enum).
- Nonce
Variant - Discriminator for
Nonce: neutral (genesis) or hashed. - Nullable
- Plutus
Data - Relay
- Network endpoint declared by a stake pool’s relay.
- Stake
Credential - On-chain credential controlling a stake address: a script or a key hash.
Traits§
Type Aliases§
- Addr
Keyhash - Hash of a Cardano address verification key (Blake2b-224).
- Asset
Name - Token name within a multi-asset bundle (raw bytes, up to 32 long).
- Coin
- Quantity in lovelace.
- Cost
Model - Plutus cost model: ordered list of per-primitive cost coefficients.
- Datum
Hash - 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
- Genesis
Delegate Hash - 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.
- Metadatum
Label - Top-level metadata label (CIP-10 / CIP-25 / etc.).
- Policy
Id - Hash of a minting policy (Blake2b-224).
- Pool
Keyhash - Hash of a stake pool’s cold key (Blake2b-224).
- Pool
Metadata Hash - Hash of stake pool metadata (Blake2b-256).
- Port
- TCP/UDP port number.
- Positive
Interval - Rational number guaranteed to be strictly positive.
- Protocol
Version - Protocol version:
(major, minor). - Reward
Account - Reward-account bytes (network header byte plus stake-credential hash).
- Script
Hash - Hash of a script (Blake2b-224).
- Transaction
Index - Index of a transaction within its containing block.
- Unit
Interval - Rational number constrained to the closed interval [0, 1].
- VrfKeyhash
- Hash of a VRF verification key (Blake2b-256).