cardano-ledger-api-1.9.2.2: Public API for the cardano ledger codebase
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Api.Tx.Out

Description

This module is used for building and inspecting transaction outputs.

You'll find some examples below.

Let's start by defining the GHC extensions and imports.

>>> :set -XTypeApplications
>>> import Cardano.Ledger.Api.Era (Babbage)
>>> import Lens.Micro
>>> import Test.Cardano.Ledger.Babbage.Serialisation.Generators () -- Neded for doctests only
>>> import Test.QuickCheck -- Needed for doctests only

Here's an example on how to build a very basic Babbage era transaction output with a random address and value, and without any datum or reference script.

>>> :{
quickCheck $ \addr val ->
    let
        -- Defining a Babbage era transaction output with some random address and value.
        txOut = mkBasicTxOut @Babbage addr val
     in
        -- We verify that the transaction output contains our random address and value.
        txOut ^. addrTxOutL == addr && txOut ^. valueTxOutL == val
:}
+++ OK, passed 100 tests.
Synopsis

Documentation

class (Val (Value era), ToJSON (TxOut era), DecCBOR (Value era), DecCBOR (CompactForm (Value era)), EncCBOR (Value era), ToCBOR (TxOut era), FromCBOR (TxOut era), EncCBOR (TxOut era), DecCBOR (TxOut era), DecShareCBOR (TxOut era), Share (TxOut era) ~ Interns (Credential 'Staking (EraCrypto era)), NoThunks (TxOut era), NFData (TxOut era), Show (TxOut era), Eq (TxOut era), EraPParams era) ⇒ EraTxOut era Source #

Abstract interface into specific fields of a TxOut

Associated Types

type TxOut era = (r ∷ Type) | r → era Source #

The output of a UTxO for a particular era

mkBasicTxOutEraTxOut era ⇒ Addr (EraCrypto era) → Value era → TxOut era Source #

upgradeTxOutEraTxOut era ⇒ TxOut (PreviousEra era) → TxOut era Source #

Every era, except Shelley, must be able to upgrade a TxOut from a previous era.

Value

valueTxOutLEraTxOut era ⇒ Lens' (TxOut era) (Value era) Source #

isAdaOnlyTxOutFEraTxOut era ⇒ SimpleGetter (TxOut era) Bool Source #

This is a getter that implements an efficient way to check whether TxOut contains ADA only.

Address

addrTxOutLEraTxOut era ⇒ Lens' (TxOut era) (Addr (EraCrypto era)) Source #

Size

getMinCoinTxOutEraTxOut era ⇒ PParams era → TxOut era → Coin Source #

Same as getMinCoinSizedTxOut, except information about the size of TxOut will be computed by serializing the TxOut. If the size turns out to be not needed, then serialization will have no overhead, since it is computed lazily.

setMinCoinTxOutEraTxOut era ⇒ PParams era → TxOut era → TxOut era Source #

Same as setMinCoinSizedTxOut, except it doesn't require the size of the TxOut and will recompute it if needed. Initial amount is not important.

getMinCoinSizedTxOutEraTxOut era ⇒ PParams era → Sized (TxOut era) → Coin Source #

Produce the minimum lovelace that a given transaction output must contain. Information about the size of the TxOut is required in some eras. Use getMinCoinTxOut if you don't have the size readily available to you.

setMinCoinSizedTxOut ∷ ∀ era. EraTxOut era ⇒ PParams era → Sized (TxOut era) → Sized (TxOut era) Source #

This function will adjust the output's Coin value to the smallest amount allowed by the UTXO rule. Initial amount is not important.

ensureMinCoinTxOutEraTxOut era ⇒ PParams era → TxOut era → TxOut era Source #

Similar to setMinCoinTxOut it will guarantee that the minimum requirement for the output amount is satisified, however it makes it possible to set a higher amount than the minimaly required.

> ensureMinCoinTxOut pp (txOut & coinTxOutL .~ zero) == setMinCoinTxOut pp (txOut & coinTxOutL .~ zero)
> (ensureMinCoinTxOut pp txOut ^. coinTxOutL) >= (setMinCoinTxOut pp txOut ^. coinTxOutL)

ensureMinCoinSizedTxOut ∷ ∀ era. EraTxOut era ⇒ PParams era → Sized (TxOut era) → Sized (TxOut era) Source #

Similar to setMinCoinSizedTxOut it will guarantee that the minimum requirement for the output amount is satisified, however it makes it possible to set a higher amount than the minimaly required.

ensureMinCoinSizedTxOut relates to setMinCoinSizedTxOut in the same way that ensureMinCoinTxOut relates to setMinCoinTxOut.

Shelley, Allegra and Mary Era

Alonzo Era

class (AlonzoEraPParams era, EraTxOut era) ⇒ AlonzoEraTxOut era Source #

Minimal complete definition

dataHashTxOutL, datumTxOutF

Instances

Instances details
Crypto c ⇒ AlonzoEraTxOut (AlonzoEra c) 
Instance details

Defined in Cardano.Ledger.Alonzo.TxOut

Babbage Era

data Data era where Source #

Bundled Patterns

pattern DataEra era ⇒ DataData era 

Instances

Instances details
Memoized Data 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Associated Types

type RawType Data = (r ∷ TypeType) Source #

Methods

getMemoBytesData era → MemoBytes (RawType Data) era

wrapMemoBytesMemoBytes (RawType Data) era → Data era

Generic (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Associated Types

type Rep (Data era) ∷ TypeType Source #

Methods

fromData era → Rep (Data era) x Source #

toRep (Data era) x → Data era Source #

HashAlgorithm (HASH (EraCrypto era)) ⇒ Show (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

showsPrecIntData era → ShowS Source #

showData era → String Source #

showList ∷ [Data era] → ShowS Source #

Typeable era ⇒ ToCBOR (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

toCBORData era → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Data era) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Data era] → Size Source #

Era era ⇒ DecCBOR (Annotator (Data era)) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

decCBORDecoder s (Annotator (Data era)) Source #

dropCBORProxy (Annotator (Data era)) → Decoder s () Source #

labelProxy (Annotator (Data era)) → Text Source #

Typeable era ⇒ EncCBOR (Data era)

Encodes memoized bytes created upon construction.

Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

encCBORData era → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (Data era) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Data era] → Size Source #

SafeToHash (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

NFData (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

rnfData era → () Source #

Eq (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

(==)Data era → Data era → Bool Source #

(/=)Data era → Data era → Bool Source #

Typeable era ⇒ NoThunks (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

EraCrypto era ~ c ⇒ HashAnnotated (Data era) EraIndependentData c 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type RawType Data 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type Rep (Data era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type Rep (Data era) = D1 ('MetaData "Data" "Cardano.Ledger.Plutus.Data" "cardano-ledger-core-1.14.0.0-inplace" 'True) (C1 ('MetaCons "DataConstr" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MemoBytes PlutusData era))))

data Datum era Source #

Datum can be described by a either a data hash or binary data, but not both. It can also be neither one of them.

Constructors

NoDatum 
DatumHash !(DataHash (EraCrypto era)) 
Datum !(BinaryData era) 

Instances

Instances details
Era era ⇒ ToJSON (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Generic (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Associated Types

type Rep (Datum era) ∷ TypeType Source #

Methods

fromDatum era → Rep (Datum era) x Source #

toRep (Datum era) x → Datum era Source #

Show (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

showsPrecIntDatum era → ShowS Source #

showDatum era → String Source #

showList ∷ [Datum era] → ShowS Source #

Era era ⇒ DecCBOR (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

decCBORDecoder s (Datum era) Source #

dropCBORProxy (Datum era) → Decoder s () Source #

labelProxy (Datum era) → Text Source #

Era era ⇒ EncCBOR (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

encCBORDatum era → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (Datum era) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Datum era] → Size Source #

Eq (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

(==)Datum era → Datum era → Bool Source #

(/=)Datum era → Datum era → Bool Source #

Ord (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

Methods

compareDatum era → Datum era → Ordering Source #

(<)Datum era → Datum era → Bool Source #

(<=)Datum era → Datum era → Bool Source #

(>)Datum era → Datum era → Bool Source #

(>=)Datum era → Datum era → Bool Source #

maxDatum era → Datum era → Datum era Source #

minDatum era → Datum era → Datum era Source #

NoThunks (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type Rep (Datum era) 
Instance details

Defined in Cardano.Ledger.Plutus.Data

type Rep (Datum era) = D1 ('MetaData "Datum" "Cardano.Ledger.Plutus.Data" "cardano-ledger-core-1.14.0.0-inplace" 'False) (C1 ('MetaCons "NoDatum" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "DatumHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (DataHash (EraCrypto era)))) :+: C1 ('MetaCons "Datum" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 (BinaryData era)))))