cardano-api
Safe HaskellNone
LanguageHaskell2010

Cardano.Api.Tx

Synopsis

Creating transactions using the old API

Both the old and new APIs support transaction creation. Transactions can be converted between formats, as they share the same underlying representation. cardano-api will be moving towards using the new API and deprecating the old way to ensure simplicity, closer alignment with the ledger, and easier maintenance.

In both the new and old APIs, to construct a transaction, you need to construct a TxBodyContent, and you will need at least a witness (for example, a ShelleyWitnessSigningKey), to sign the transaction. This process remains unchanged.

To learn how to create a transaction using the new API, refer to Cardano.Api.Experimental.Tx documentation.

The next examples use the following qualified modules:

import qualified Cardano.Api as Api                -- the general `cardano-api` exports (including the old API)
import qualified Cardano.Api.Script as Script      -- types related to scripts (Plutus and native)
import qualified Cardano.Api.Ledger as Ledger      -- cardano-ledger re-exports

Creating a TxBodyContent

To create a transaction, you first need to define the contents of its body. This section will show how to use the API to create a TxBodyContent for a simple transaction.

TxBodyContent datatype provides several fields because transactions can serve multiple purposes, but the function defaultTxBodyContent (exported from Cardano.Api) already provides a base TxBodyContent with all fields set to their default values that you can use as a starting point so as not to have to set all fields manually.

The defaultTxBodyContent takes, as the only parameter, the ShelleyBasedEra witness for the era you are working with. For example, if you are working with the ConwayEra, use shelleyBasedEra available in Cardano.Api, as follows:

let sbe :: Api.ShelleyBasedEra Api.ConwayEra = Api.shelleyBasedEra

This is what creating a simple TxBodyContent would look like.

First, choose a transaction output to spend (a UTXO). Specify which UTXO to spend by providing the transaction ID and the index of the output in that transaction that you want to spend.

To specify the transaction ID, you can use the deserialiseFromRawBytesHex function on the hexadecimal representation of the transaction hash. For example:

let (Right srcTxId) = Api.deserialiseFromRawBytesHex Api.AsTxId "be6efd42a3d7b9a00d09d77a5d41e55ceaf0bd093a8aa8a893ce70d9caafd978"

In real implementations, failure cases should be handled appropriately.

To specify the transaction index, use the TxIx constructor. For example:

let srcTxIx = Api.TxIx 0

Now, combine both to create a TxIn value and pair it with a witness requirement using BuildTxWith :

let txIn = ( Api.TxIn srcTxId srcTxIx
           , Api.BuildTxWith (Api.KeyWitness Api.KeyWitnessForSpending)
           )

Next, specify the address of the recipient of the transaction. If you have the bech32 representation, you can use the deserialiseAddress function to get the AddressInEra type. For example:

let (Just destAddress) = Api.deserialiseAddress (Api.AsAddressInEra eraAsType) "addr_test1vzpfxhjyjdlgk5c0xt8xw26avqxs52rtf69993j4tajehpcue4v2v"

Now, you can create a TxOut value. For simplicity, assume the output is a simple payment output of 10 ada, with no datum or reference script attached to it:

let txOut = Api.TxOut
              destAddress
              (Api.lovelaceToTxOutValue sbe 10_000_000)
              Api.TxOutDatumNone
              Script.ReferenceScriptNone

Note to set the transaction fee. For example, set it to 2 ada:

let txFee = Api.TxFeeExplicit sbe 2_000_000

Finally, you can create the TxBodyContent by using the defaultTxBodyContent function and putting everything together:

let txBodyContent = Api.defaultTxBodyContent sbe
                     & Api.setTxIns [txIn]
                     & Api.setTxOuts [txOut]
                     & Api.setTxFee txFee

The txBodyContent can now be used to create a transaction using the old or the new API.

Balancing a transaction

If you have a UTXO with exactly 12 ada, you could just construct the transaction as in the previous section directly, and it would be a valid transaction, but:

  • It is probably wasting ADA
  • There may not be exactly one UTXO of 12 ada
  • The transaciton may not be this simple.

For these reasons, it is recommended that you balance the transaction before proceeding with signing and submitting.

See how to balance a transaction in the Cardano.Api.Tx.Internal.Fee documentation.

Creating a ShelleyWitnessSigningKey

Signing a transaction requires a witness, for example, a ShelleyWitnessSigningKey.

Learn how to create a ShelleyWitnessSigningKey in the Cardano.Api.Tx.Internal.Sign documentation.

Creating a transaction using the old API

Now that you have a TxBodyContent and a ShelleyWitnessSigningKey, you can easily create a transaction using the old API. First, create a transaction body using the createTransactionBody function and the ShelleyBasedEra witness defined earlier.

Create the transaction body using the TransactionBodyContent created earlier:

let (Right txBody) = Api.createTransactionBody sbe txBodyContent

Then, sign the transaction using the signShelleyTransaction function and the witness:

let oldApiSignedTx :: Api.Tx Api.ConwayEra = Api.signShelleyTransaction sbe txBody [witness]

We now have a signed transaction. Learn how to submit it to the node by using the IPC protocol in the Cardano.Api.Network.IPC.Internal.

Inspecting transactions

To deconstruct an old-style TxBody into a TxBodyContent, you can also use the TxBody pattern. Note that this cannot be used for constructing. For that, use ShelleyTxBody or createTransactionBody, as in the example.

To extract the TxBody and the KeyWitnesses from an old-style Tx, use the functions getTxBody and getTxWitnesses respectively, from Cardano.Api.

Appendix: Getting Shelley-based era witness from the new API

If you are using the new API, you can also derive the ShelleyBasedEra of it from ConwayEra from Cardano.Api.Internal.Experimental using the convert function:

let era = Exp.ConwayEra
let sbe = Api.convert era

Transaction body

data TxBody era where Source #

Constructors

ShelleyTxBody 

Fields

Bundled Patterns

pattern TxBody :: TxBodyContent ViewTx era -> TxBody era

Deprecated: Use getTxBodyContent $ getTxBody instead

Instances

Instances details
Show (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Methods

showsPrec :: Int -> TxBody era -> ShowS Source #

show :: TxBody era -> String Source #

showList :: [TxBody era] -> ShowS Source #

HasTypeProxy era => HasTypeProxy (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Associated Types

data AsType (TxBody era) 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (TxBody era) = AsTxBody (AsType era)

Methods

proxyToAsType :: Proxy (TxBody era) -> AsType (TxBody era) Source #

IsShelleyBasedEra era => SerialiseAsCBOR (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

IsShelleyBasedEra era => HasTextEnvelope (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Eq (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Methods

(==) :: TxBody era -> TxBody era -> Bool Source #

(/=) :: TxBody era -> TxBody era -> Bool Source #

data AsType (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (TxBody era) = AsTxBody (AsType era)

createAndValidateTransactionBody :: ShelleyBasedEra era -> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era) Source #

Deprecated: Use createTransactionBody instead

data TxBodyContent build era Source #

Instances

Instances details
IsShelleyBasedEra era => Show (TxBodyContent build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

showsPrec :: Int -> TxBodyContent build era -> ShowS Source #

show :: TxBodyContent build era -> String Source #

showList :: [TxBodyContent build era] -> ShowS Source #

IsShelleyBasedEra era => Eq (TxBodyContent build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxBodyContent build era -> TxBodyContent build era -> Bool Source #

(/=) :: TxBodyContent build era -> TxBodyContent build era -> Bool Source #

Byron only

Transaction body builders

setTxIns :: TxIns build era -> TxBodyContent build era -> TxBodyContent build era Source #

modTxIns :: (TxIns build era -> TxIns build era) -> TxBodyContent build era -> TxBodyContent build era Source #

addTxIn :: (TxIn, BuildTxWith build (Witness WitCtxTxIn era)) -> TxBodyContent build era -> TxBodyContent build era Source #

addTxIns :: TxIns build era -> TxBodyContent build era -> TxBodyContent build era Source #

setTxInsReference :: TxInsReference build era -> TxBodyContent build era -> TxBodyContent build era Source #

modTxInsReference :: (TxInsReference build era -> TxInsReference build era) -> TxBodyContent build era -> TxBodyContent build era Source #

setTxOuts :: [TxOut CtxTx era] -> TxBodyContent build era -> TxBodyContent build era Source #

modTxOuts :: ([TxOut CtxTx era] -> [TxOut CtxTx era]) -> TxBodyContent build era -> TxBodyContent build era Source #

addTxOut :: TxOut CtxTx era -> TxBodyContent build era -> TxBodyContent build era Source #

addTxOuts :: [TxOut CtxTx era] -> TxBodyContent build era -> TxBodyContent build era Source #

setTxFee :: TxFee era -> TxBodyContent build era -> TxBodyContent build era Source #

modTxFee :: (TxFee era -> TxFee era) -> TxBodyContent build era -> TxBodyContent build era Source #

modTxAuxScripts :: (TxAuxScripts era -> TxAuxScripts era) -> TxBodyContent build era -> TxBodyContent build era Source #

setTxWithdrawals :: TxWithdrawals build era -> TxBodyContent build era -> TxBodyContent build era Source #

modTxWithdrawals :: (TxWithdrawals build era -> TxWithdrawals build era) -> TxBodyContent build era -> TxBodyContent build era Source #

setTxCertificates :: TxCertificates build era -> TxBodyContent build era -> TxBodyContent build era Source #

modTxCertificates :: (TxCertificates build era -> TxCertificates build era) -> TxBodyContent build era -> TxBodyContent build era Source #

setTxMintValue :: TxMintValue build era -> TxBodyContent build era -> TxBodyContent build era Source #

modTxMintValue :: (TxMintValue build era -> TxMintValue build era) -> TxBodyContent build era -> TxBodyContent build era Source #

subtractTxMintValue :: IsMaryBasedEra era => Map PolicyId (PolicyAssets, BuildTxWith build (ScriptWitness WitCtxMint era)) -> TxBodyContent build era -> TxBodyContent build era Source #

Adds the negation of the provided assets and quantities to the txMintValue field of the TxBodyContent.

data TxScriptValidity era where Source #

A representation of whether the era supports tx script validity.

The Alonzo and subsequent eras support script validity.

Constructors

TxScriptValidityNone :: forall era. TxScriptValidity era 
TxScriptValidity :: forall era. AlonzoEraOnwards era -> ScriptValidity -> TxScriptValidity era

Tx script validity is supported in transactions in the Alonzo era onwards.

Instances

Instances details
Show (TxScriptValidity era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Eq (TxScriptValidity era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data ScriptValidity Source #

Indicates whether a script is expected to fail or pass validation.

Constructors

ScriptInvalid

Script is expected to fail validation. Transactions marked as such can include scripts that fail validation. Such transactions may be submitted to the chain, in which case the collateral will be taken upon on chain script validation failure.

ScriptValid

Script is expected to pass validation. Transactions marked as such cannot include scripts that fail validation.

newtype UTxO era Source #

Constructors

UTxO 

Fields

Instances

Instances details
IsShelleyBasedEra era => FromJSON (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

parseJSON :: Value -> Parser (UTxO era) #

parseJSONList :: Value -> Parser [UTxO era] #

omittedField :: Maybe (UTxO era) #

IsCardanoEra era => ToJSON (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

toJSON :: UTxO era -> Value #

toEncoding :: UTxO era -> Encoding #

toJSONList :: [UTxO era] -> Value #

toEncodingList :: [UTxO era] -> Encoding #

omitField :: UTxO era -> Bool #

Monoid (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

mempty :: UTxO era Source #

mappend :: UTxO era -> UTxO era -> UTxO era Source #

mconcat :: [UTxO era] -> UTxO era Source #

Semigroup (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

(<>) :: UTxO era -> UTxO era -> UTxO era Source #

sconcat :: NonEmpty (UTxO era) -> UTxO era Source #

stimes :: Integral b => b -> UTxO era -> UTxO era Source #

IsList (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Associated Types

type Item (UTxO era) 
Instance details

Defined in Cardano.Api.UTxO

type Item (UTxO era) = (TxIn, TxOut CtxUTxO era)

Methods

fromList :: [Item (UTxO era)] -> UTxO era Source #

fromListN :: Int -> [Item (UTxO era)] -> UTxO era Source #

toList :: UTxO era -> [Item (UTxO era)] Source #

Show (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

showsPrec :: Int -> UTxO era -> ShowS Source #

show :: UTxO era -> String Source #

showList :: [UTxO era] -> ShowS Source #

Eq (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

(==) :: UTxO era -> UTxO era -> Bool Source #

(/=) :: UTxO era -> UTxO era -> Bool Source #

MonoFoldable (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

ofoldMap :: Monoid m => (Element (UTxO era) -> m) -> UTxO era -> m

ofoldr :: (Element (UTxO era) -> b -> b) -> b -> UTxO era -> b

ofoldl' :: (a -> Element (UTxO era) -> a) -> a -> UTxO era -> a

otoList :: UTxO era -> [Element (UTxO era)]

oall :: (Element (UTxO era) -> Bool) -> UTxO era -> Bool

oany :: (Element (UTxO era) -> Bool) -> UTxO era -> Bool

onull :: UTxO era -> Bool

olength :: UTxO era -> Int

olength64 :: UTxO era -> Int64

ocompareLength :: Integral i => UTxO era -> i -> Ordering

otraverse_ :: Applicative f => (Element (UTxO era) -> f b) -> UTxO era -> f ()

ofor_ :: Applicative f => UTxO era -> (Element (UTxO era) -> f b) -> f ()

omapM_ :: Applicative m => (Element (UTxO era) -> m ()) -> UTxO era -> m ()

oforM_ :: Applicative m => UTxO era -> (Element (UTxO era) -> m ()) -> m ()

ofoldlM :: Monad m => (a -> Element (UTxO era) -> m a) -> a -> UTxO era -> m a

ofoldMap1Ex :: Semigroup m => (Element (UTxO era) -> m) -> UTxO era -> m

ofoldr1Ex :: (Element (UTxO era) -> Element (UTxO era) -> Element (UTxO era)) -> UTxO era -> Element (UTxO era)

ofoldl1Ex' :: (Element (UTxO era) -> Element (UTxO era) -> Element (UTxO era)) -> UTxO era -> Element (UTxO era)

headEx :: UTxO era -> Element (UTxO era)

lastEx :: UTxO era -> Element (UTxO era)

unsafeHead :: UTxO era -> Element (UTxO era)

unsafeLast :: UTxO era -> Element (UTxO era)

maximumByEx :: (Element (UTxO era) -> Element (UTxO era) -> Ordering) -> UTxO era -> Element (UTxO era)

minimumByEx :: (Element (UTxO era) -> Element (UTxO era) -> Ordering) -> UTxO era -> Element (UTxO era)

oelem :: Element (UTxO era) -> UTxO era -> Bool

onotElem :: Element (UTxO era) -> UTxO era -> Bool

MonoFunctor (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

omap :: (Element (UTxO era) -> Element (UTxO era)) -> UTxO era -> UTxO era

MonoTraversable (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

Methods

otraverse :: Applicative f => (Element (UTxO era) -> f (Element (UTxO era))) -> UTxO era -> f (UTxO era)

omapM :: Applicative m => (Element (UTxO era) -> m (Element (UTxO era))) -> UTxO era -> m (UTxO era)

type Item (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

type Item (UTxO era) = (TxIn, TxOut CtxUTxO era)
type Element (UTxO era) Source # 
Instance details

Defined in Cardano.Api.UTxO

type Element (UTxO era) = TxOut CtxUTxO era

Transaction Ids

newtype TxId Source #

Instances

Instances details
FromJSON TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

parseJSON :: Value -> Parser TxId #

parseJSONList :: Value -> Parser [TxId] #

omittedField :: Maybe TxId #

FromJSONKey TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

fromJSONKey :: FromJSONKeyFunction TxId

fromJSONKeyList :: FromJSONKeyFunction [TxId]

ToJSON TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

toJSON :: TxId -> Value #

toEncoding :: TxId -> Encoding #

toJSONList :: [TxId] -> Value #

toEncodingList :: [TxId] -> Encoding #

omitField :: TxId -> Bool #

ToJSONKey TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

toJSONKey :: ToJSONKeyFunction TxId

toJSONKeyList :: ToJSONKeyFunction [TxId]

Show TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

HasTypeProxy TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Associated Types

data AsType TxId 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

SerialiseAsRawBytes TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Eq TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

(==) :: TxId -> TxId -> Bool Source #

(/=) :: TxId -> TxId -> Bool Source #

Ord TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Pretty TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

pretty :: TxId -> Doc ann #

prettyList :: [TxId] -> Doc ann #

data AsType TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

getTxId :: TxBody era -> TxId Source #

Calculate the transaction identifier for a TxBody.

Transaction inputs

data TxIn Source #

Constructors

TxIn TxId TxIx 

Instances

Instances details
FromJSON TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

parseJSON :: Value -> Parser TxIn #

parseJSONList :: Value -> Parser [TxIn] #

omittedField :: Maybe TxIn #

FromJSONKey TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

fromJSONKey :: FromJSONKeyFunction TxIn

fromJSONKeyList :: FromJSONKeyFunction [TxIn]

ToJSON TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

toJSON :: TxIn -> Value #

toEncoding :: TxIn -> Encoding #

toJSONList :: [TxIn] -> Value #

toEncodingList :: [TxIn] -> Encoding #

omitField :: TxIn -> Bool #

ToJSONKey TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

toJSONKey :: ToJSONKeyFunction TxIn

toJSONKeyList :: ToJSONKeyFunction [TxIn]

Show TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Eq TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

(==) :: TxIn -> TxIn -> Bool Source #

(/=) :: TxIn -> TxIn -> Bool Source #

Ord TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Pretty TxIn Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

pretty :: TxIn -> Doc ann #

prettyList :: [TxIn] -> Doc ann #

type TxIns build era = [(TxIn, BuildTxWith build (Witness WitCtxTxIn era))] Source #

indexTxIns :: TxIns BuildTx era -> [(ScriptWitnessIndex, TxIn, Witness WitCtxTxIn era)] Source #

Index transaction inputs ordered by TxIn Please note that the result can contain also KeyWitnesses. See section 4.1 of https://github.com/intersectmbo/cardano-ledger/releases/latest/download/alonzo-ledger.pdf

newtype TxIx Source #

Constructors

TxIx Word 

Instances

Instances details
FromJSON TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

parseJSON :: Value -> Parser TxIx #

parseJSONList :: Value -> Parser [TxIx] #

omittedField :: Maybe TxIx #

ToJSON TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

toJSON :: TxIx -> Value #

toEncoding :: TxIx -> Encoding #

toJSONList :: [TxIx] -> Value #

toEncodingList :: [TxIx] -> Encoding #

omitField :: TxIx -> Bool #

Enum TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Show TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Eq TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

(==) :: TxIx -> TxIx -> Bool Source #

(/=) :: TxIx -> TxIx -> Bool Source #

Ord TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Pretty TxIx Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

Methods

pretty :: TxIx -> Doc ann #

prettyList :: [TxIx] -> Doc ann #

genesisUTxOPseudoTxIn :: NetworkId -> Hash GenesisUTxOKey -> TxIn Source #

Compute the TxIn of the initial UTxO pseudo-transaction corresponding to the given address in the genesis initial funds.

The Shelley initial UTxO is constructed from the sgInitialFunds which is not a full UTxO but just a map from addresses to coin values.

This gets turned into a UTxO by making a pseudo-transaction for each address, with the 0th output being the coin value. So to spend from the initial UTxO we need this same TxIn to use as an input to the spending transaction.

getReferenceInputsSizeForTxIds :: ShelleyLedgerEra era ~ ledgerera => BabbageEraOnwards era -> UTxO ledgerera -> Set TxIn -> Int Source #

Calculate the reference inputs size in bytes for provided set of transaction IDs and UTXOs.

Transaction outputs

data CtxTx Source #

The context is a transaction body

Instances

Instances details
IsShelleyBasedEra era => FromJSON (TxOut CtxTx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

parseJSON :: Value -> Parser (TxOut CtxTx era) #

parseJSONList :: Value -> Parser [TxOut CtxTx era] #

omittedField :: Maybe (TxOut CtxTx era) #

data CtxUTxO Source #

The context is the UTxO

Instances

Instances details
IsShelleyBasedEra era => FromJSON (TxOut CtxUTxO era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

parseJSON :: Value -> Parser (TxOut CtxUTxO era) #

parseJSONList :: Value -> Parser [TxOut CtxUTxO era] #

omittedField :: Maybe (TxOut CtxUTxO era) #

data TxOut ctx era Source #

Constructors

TxOut (AddressInEra era) (TxOutValue era) (TxOutDatum ctx era) (ReferenceScript era) 

Instances

Instances details
IsShelleyBasedEra era => FromJSON (TxOut CtxTx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

parseJSON :: Value -> Parser (TxOut CtxTx era) #

parseJSONList :: Value -> Parser [TxOut CtxTx era] #

omittedField :: Maybe (TxOut CtxTx era) #

IsShelleyBasedEra era => FromJSON (TxOut CtxUTxO era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

parseJSON :: Value -> Parser (TxOut CtxUTxO era) #

parseJSONList :: Value -> Parser [TxOut CtxUTxO era] #

omittedField :: Maybe (TxOut CtxUTxO era) #

IsCardanoEra era => ToJSON (TxOut ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

toJSON :: TxOut ctx era -> Value #

toEncoding :: TxOut ctx era -> Encoding #

toJSONList :: [TxOut ctx era] -> Value #

toEncodingList :: [TxOut ctx era] -> Encoding #

omitField :: TxOut ctx era -> Bool #

Show (TxOut ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

showsPrec :: Int -> TxOut ctx era -> ShowS Source #

show :: TxOut ctx era -> String Source #

showList :: [TxOut ctx era] -> ShowS Source #

Eq (TxOut ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

(==) :: TxOut ctx era -> TxOut ctx era -> Bool Source #

(/=) :: TxOut ctx era -> TxOut ctx era -> Bool Source #

data TxOutValue era where Source #

Instances

Instances details
IsShelleyBasedEra era => FromJSON (TxOutValue era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

parseJSON :: Value -> Parser (TxOutValue era) #

parseJSONList :: Value -> Parser [TxOutValue era] #

omittedField :: Maybe (TxOutValue era) #

IsCardanoEra era => ToJSON (TxOutValue era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

toJSON :: TxOutValue era -> Value #

toEncoding :: TxOutValue era -> Encoding #

toJSONList :: [TxOutValue era] -> Value #

toEncodingList :: [TxOutValue era] -> Encoding #

omitField :: TxOutValue era -> Bool #

Show (TxOutValue era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Eq (TxOutValue era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

(==) :: TxOutValue era -> TxOutValue era -> Bool Source #

(/=) :: TxOutValue era -> TxOutValue era -> Bool Source #

data TxOutDatum ctx era where Source #

Constructors

TxOutDatumNone :: forall ctx era. TxOutDatum ctx era 
TxOutDatumHash :: forall era ctx. AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era

A transaction output that only specifies the hash of the datum, but not the full datum value.

TxOutSupplementalDatum :: forall era. AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era

A transaction output that specifies the whole datum value. This can only be used in the context of the transaction body (i.e this is a supplemental datum), and does not occur in the UTxO. The UTxO only contains the datum hash.

TxOutDatumInline :: forall era ctx. BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era

A transaction output that specifies the whole datum instead of the datum hash. Note that the datum map will not be updated with this datum, it only exists at the transaction output.

Instances

Instances details
Show (TxOutDatum ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

showsPrec :: Int -> TxOutDatum ctx era -> ShowS Source #

show :: TxOutDatum ctx era -> String Source #

showList :: [TxOutDatum ctx era] -> ShowS Source #

Eq (TxOutDatum ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Output

Methods

(==) :: TxOutDatum ctx era -> TxOutDatum ctx era -> Bool Source #

(/=) :: TxOutDatum ctx era -> TxOutDatum ctx era -> Bool Source #

txOutInAnyEra :: CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra Source #

Convenience constructor for TxOutInAnyEra

Other transaction body types

data TxInsCollateral era where Source #

Constructors

TxInsCollateralNone :: forall era. TxInsCollateral era 
TxInsCollateral :: forall era. AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era 

Instances

Instances details
Show (TxInsCollateral era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxInsCollateral era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

data TxInsReference build era where Source #

Constructors

TxInsReferenceNone :: forall build era. TxInsReference build era 
TxInsReference 

Fields

  • :: forall era build. BabbageEraOnwards era
     
  • -> [TxIn]

    A list of reference inputs

  • -> TxInsReferenceDatums build

    A set of public key inputs resolved datums, whose hashes are referenced in UTXO of reference inputs. Those datums will be inserted to the datum map available to the scripts. Note that inserting a datum with hash not present in the reference input will result in an error on transaction submission.

  • -> TxInsReference build era
     

Instances

Instances details
Show (TxInsReference build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

showsPrec :: Int -> TxInsReference build era -> ShowS Source #

show :: TxInsReference build era -> String Source #

showList :: [TxInsReference build era] -> ShowS Source #

Eq (TxInsReference build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxInsReference build era -> TxInsReference build era -> Bool Source #

(/=) :: TxInsReference build era -> TxInsReference build era -> Bool Source #

type TxInsReferenceDatums build = BuildTxWith build (Set HashableScriptData) Source #

The public key inputs' resolved datums, referenced by hash in the transaction reference inputs.

data TxReturnCollateral ctx era where Source #

Constructors

TxReturnCollateralNone :: forall ctx era. TxReturnCollateral ctx era 
TxReturnCollateral :: forall era ctx. BabbageEraOnwards era -> TxOut ctx era -> TxReturnCollateral ctx era 

Instances

Instances details
Show (TxReturnCollateral ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxReturnCollateral ctx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

data TxTotalCollateral era where Source #

Constructors

TxTotalCollateralNone :: forall era. TxTotalCollateral era 
TxTotalCollateral :: forall era. BabbageEraOnwards era -> Coin -> TxTotalCollateral era 

data TxFee era where Source #

Constructors

TxFeeExplicit :: forall era. ShelleyBasedEra era -> Coin -> TxFee era 

Instances

Instances details
Show (TxFee era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

showsPrec :: Int -> TxFee era -> ShowS Source #

show :: TxFee era -> String Source #

showList :: [TxFee era] -> ShowS Source #

Eq (TxFee era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxFee era -> TxFee era -> Bool Source #

(/=) :: TxFee era -> TxFee era -> Bool Source #

data TxValidityUpperBound era where Source #

This was formerly known as the TTL.

Constructors

TxValidityUpperBound :: forall era. ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era 

data TxMetadataInEra era where Source #

Constructors

TxMetadataNone :: forall era. TxMetadataInEra era 
TxMetadataInEra :: forall era. ShelleyBasedEra era -> TxMetadata -> TxMetadataInEra era 

Instances

Instances details
Show (TxMetadataInEra era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxMetadataInEra era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

data TxAuxScripts era where Source #

Constructors

TxAuxScriptsNone :: forall era. TxAuxScripts era 
TxAuxScripts :: forall era. AllegraEraOnwards era -> [ScriptInEra era] -> TxAuxScripts era 

Instances

Instances details
Show (TxAuxScripts era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxAuxScripts era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

data TxWithdrawals build era where Source #

Constructors

TxWithdrawalsNone :: forall build era. TxWithdrawals build era 
TxWithdrawals :: forall era build. ShelleyBasedEra era -> [(StakeAddress, Coin, BuildTxWith build (Witness WitCtxStake era))] -> TxWithdrawals build era 

Instances

Instances details
Show (TxWithdrawals build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

showsPrec :: Int -> TxWithdrawals build era -> ShowS Source #

show :: TxWithdrawals build era -> String Source #

showList :: [TxWithdrawals build era] -> ShowS Source #

Eq (TxWithdrawals build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxWithdrawals build era -> TxWithdrawals build era -> Bool Source #

(/=) :: TxWithdrawals build era -> TxWithdrawals build era -> Bool Source #

data TxCertificates build era where Source #

Constructors

TxCertificatesNone :: forall build era. TxCertificates build era

No certificates

TxCertificates :: forall era build. ShelleyBasedEra era -> OMap (Certificate era) (BuildTxWith build (Maybe (StakeCredential, Witness WitCtxStake era))) -> TxCertificates build era

Represents certificates present in transaction. Prefer using mkTxCertificates to constructing this type with a constructor

Instances

Instances details
Show (TxCertificates build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

showsPrec :: Int -> TxCertificates build era -> ShowS Source #

show :: TxCertificates build era -> String Source #

showList :: [TxCertificates build era] -> ShowS Source #

Eq (TxCertificates build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxCertificates build era -> TxCertificates build era -> Bool Source #

(/=) :: TxCertificates build era -> TxCertificates build era -> Bool Source #

mkTxCertificates :: Applicative (BuildTxWith build) => ShelleyBasedEra era -> [(Certificate era, Maybe (ScriptWitness WitCtxStake era))] -> TxCertificates build era Source #

Create TxCertificates. Note that 'Certificate era' will be deduplicated. Only Certificates with a stake credential will be in the result.

Note that, when building a transaction in Conway era, a witness is not required for staking credential registration, but this is only the case during the transitional period of Conway era and only for staking credential registration certificates without a deposit. Future eras will require a witness for registration certificates, because the one without a deposit will be removed.

indexTxCertificates :: TxCertificates BuildTx era -> [(ScriptWitnessIndex, Certificate era, StakeCredential, Witness WitCtxStake era)] Source #

Index certificates with witnesses by the order they appear in the list (in the transaction). See section 4.1 of https://github.com/intersectmbo/cardano-ledger/releases/latest/download/alonzo-ledger.pdf

data TxUpdateProposal era where Source #

Constructors

TxUpdateProposalNone :: forall era. TxUpdateProposal era 
TxUpdateProposal :: forall era. ShelleyToBabbageEra era -> UpdateProposal -> TxUpdateProposal era 

Instances

Instances details
Show (TxUpdateProposal era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxUpdateProposal era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

data TxMintValue build era where Source #

Constructors

TxMintNone :: forall build era. TxMintValue build era 
TxMintValue :: forall era build. MaryEraOnwards era -> Map PolicyId (PolicyAssets, BuildTxWith build (ScriptWitness WitCtxMint era)) -> TxMintValue build era 

Instances

Instances details
Monoid (TxMintValue build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

mempty :: TxMintValue build era Source #

mappend :: TxMintValue build era -> TxMintValue build era -> TxMintValue build era Source #

mconcat :: [TxMintValue build era] -> TxMintValue build era Source #

Semigroup (TxMintValue build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(<>) :: TxMintValue build era -> TxMintValue build era -> TxMintValue build era Source #

sconcat :: NonEmpty (TxMintValue build era) -> TxMintValue build era Source #

stimes :: Integral b => b -> TxMintValue build era -> TxMintValue build era Source #

Show (TxMintValue build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

showsPrec :: Int -> TxMintValue build era -> ShowS Source #

show :: TxMintValue build era -> String Source #

showList :: [TxMintValue build era] -> ShowS Source #

Eq (TxMintValue build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxMintValue build era -> TxMintValue build era -> Bool Source #

(/=) :: TxMintValue build era -> TxMintValue build era -> Bool Source #

mkTxMintValue :: MaryEraOnwards era -> [(PolicyId, PolicyAssets, BuildTxWith build (ScriptWitness WitCtxMint era))] -> TxMintValue build era Source #

A helper function for building TxMintValue with present witnesses. Only the first witness in the argument will be used for each policy id.

txMintValueToValue :: TxMintValue build era -> Value Source #

Convert TxMintValue to a more handy Value.

data TxVotingProcedures build era where Source #

Constructors

TxVotingProceduresNone :: forall build era. TxVotingProcedures build era 
TxVotingProcedures :: forall era build. VotingProcedures (ShelleyLedgerEra era) -> BuildTxWith build (Map Voter (ScriptWitness WitCtxStake era)) -> TxVotingProcedures build era 

Instances

Instances details
Show (TxVotingProcedures build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxVotingProcedures build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxVotingProcedures build era -> TxVotingProcedures build era -> Bool Source #

(/=) :: TxVotingProcedures build era -> TxVotingProcedures build era -> Bool Source #

mkTxVotingProcedures :: Applicative (BuildTxWith build) => [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))] -> Either (VotesMergingConflict era) (TxVotingProcedures build era) Source #

Create voting procedures from map of voting procedures and optional witnesses. Validates the function argument, to make sure the list of votes is legal. See mergeVotingProcedures for validation rules.

indexTxVotingProcedures :: TxVotingProcedures BuildTx era -> [(ScriptWitnessIndex, Voter, ScriptWitness WitCtxStake era)] Source #

Index voting procedures by the order of the votes (Ord).

data TxProposalProcedures build era where Source #

Constructors

TxProposalProceduresNone :: forall build era. TxProposalProcedures build era

No proposals in transaction..

TxProposalProcedures :: forall era build. EraPParams (ShelleyLedgerEra era) => OMap (ProposalProcedure (ShelleyLedgerEra era)) (BuildTxWith build (Maybe (ScriptWitness WitCtxStake era))) -> TxProposalProcedures build era

Represents proposal procedures present in transaction.

Instances

Instances details
Show (TxProposalProcedures build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (TxProposalProcedures build era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Methods

(==) :: TxProposalProcedures build era -> TxProposalProcedures build era -> Bool Source #

(/=) :: TxProposalProcedures build era -> TxProposalProcedures build era -> Bool Source #

mkTxProposalProcedures :: forall era build. (Applicative (BuildTxWith build), IsShelleyBasedEra era) => [(ProposalProcedure (ShelleyLedgerEra era), Maybe (ScriptWitness WitCtxStake era))] -> TxProposalProcedures build era Source #

A smart constructor for TxProposalProcedures. It makes sure that the value produced is consistent - the witnessed proposals are also present in the first constructor parameter.

indexTxProposalProcedures :: TxProposalProcedures BuildTx era -> [(ScriptWitnessIndex, ProposalProcedure (ShelleyLedgerEra era), ScriptWitness WitCtxStake era)] Source #

Index proposal procedures by their order (Ord). | and filter out the ones that do not have a witness.

Building vs viewing transactions

data BuildTxWith build a where Source #

Constructors

ViewTx :: forall a. BuildTxWith ViewTx a 
BuildTxWith :: forall a. a -> BuildTxWith BuildTx a 

Instances

Instances details
Applicative (BuildTxWith BuildTx) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Applicative (BuildTxWith ViewTx) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Functor (BuildTxWith build) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Methods

fmap :: (a -> b) -> BuildTxWith build a -> BuildTxWith build b Source #

(<$) :: a -> BuildTxWith build b -> BuildTxWith build a Source #

(Applicative (BuildTxWith build), Monoid a) => Monoid (BuildTxWith build a) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Methods

mempty :: BuildTxWith build a Source #

mappend :: BuildTxWith build a -> BuildTxWith build a -> BuildTxWith build a Source #

mconcat :: [BuildTxWith build a] -> BuildTxWith build a Source #

Semigroup a => Semigroup (BuildTxWith build a) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Methods

(<>) :: BuildTxWith build a -> BuildTxWith build a -> BuildTxWith build a Source #

sconcat :: NonEmpty (BuildTxWith build a) -> BuildTxWith build a Source #

stimes :: Integral b => b -> BuildTxWith build a -> BuildTxWith build a Source #

Show a => Show (BuildTxWith build a) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Methods

showsPrec :: Int -> BuildTxWith build a -> ShowS Source #

show :: BuildTxWith build a -> String Source #

showList :: [BuildTxWith build a] -> ShowS Source #

Eq a => Eq (BuildTxWith build a) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.BuildTxWith

Methods

(==) :: BuildTxWith build a -> BuildTxWith build a -> Bool Source #

(/=) :: BuildTxWith build a -> BuildTxWith build a -> Bool Source #

Inspecting ScriptWitnesses

data AnyScriptWitness era where Source #

A ScriptWitness in any WitCtx. This lets us handle heterogeneous collections of script witnesses from multiple contexts.

Constructors

AnyScriptWitness :: forall witctx era. Typeable witctx => ScriptWitness witctx era -> AnyScriptWitness era 

Instances

Instances details
Show (AnyScriptWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

Eq (AnyScriptWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Body

data ScriptWitnessIndex Source #

Identify the location of a ScriptWitness within the context of a TxBody. These are indexes of the objects within the transaction that need or can use script witnesses: inputs, minted assets, withdrawals and certificates. These are simple numeric indices, enumerated from zero. Thus the indices are not stable if the transaction body is modified.

Constructors

ScriptWitnessIndexTxIn !Word32

The n'th transaction input, in the order of the TxIds.

ScriptWitnessIndexMint !Word32

The n'th minting PolicyId, in the order of the PolicyIds.

ScriptWitnessIndexCertificate !Word32

The n'th certificate, in the list order of the certificates.

ScriptWitnessIndexWithdrawal !Word32

The n'th withdrawal, in the order of the StakeAddresss.

ScriptWitnessIndexVoting !Word32

The n'th vote, in the order of the votes.

ScriptWitnessIndexProposing !Word32

The n'th proposal, in the order of the proposals.

Conversion to inline data

scriptDataToInlineDatum :: Era ledgerera => HashableScriptData -> Datum ledgerera Source #

Conversion of ScriptData to binary data which allows for the storage of data onchain within a transaction output.

Internal conversion functions & types

convScripts :: ShelleyLedgerEra era ~ ledgerera => [(ScriptWitnessIndex, AnyScriptWitness era)] -> [Script ledgerera] Source #

convTxOuts :: forall ctx era ledgerera. (HasCallStack, ShelleyLedgerEra era ~ ledgerera) => ShelleyBasedEra era -> [TxOut ctx era] -> StrictSeq (TxOut ledgerera) Source #

convTxUpdateProposal Source #

Arguments

:: ShelleyBasedEra era 
-> TxUpdateProposal era 
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))

Left when there's protocol params conversion error, Right otherwise, 'Right SNothing' means that there's no update proposal

Convert transaction update proposal into ledger update proposal

mkCommonTxBody :: HasCallStack => ShelleyBasedEra era -> TxIns BuildTx era -> [TxOut ctx era] -> TxFee era -> TxWithdrawals build era -> Maybe (TxAuxData (ShelleyLedgerEra era)) -> LedgerTxBody era Source #

A helper function that constructs a TxBody with all of the fields that are common for all eras

toAuxiliaryData :: ShelleyBasedEra era -> TxMetadataInEra era -> TxAuxScripts era -> Maybe (TxAuxData (ShelleyLedgerEra era)) Source #

In the Allegra and Mary eras the auxiliary data consists of the tx metadata and the axiliary scripts. In the Alonzo and later eras the auxiliary data consists of the tx metadata and the axiliary scripts, and the axiliary script data.

toShelleyTxIn :: TxIn -> TxIn Source #

This function may overflow on the transaction index. Call sites must ensure that all uses of this function are appropriately guarded.

toShelleyTxOut :: (HasCallStack, ShelleyLedgerEra era ~ ledgerera) => ShelleyBasedEra era -> TxOut CtxUTxO era -> TxOut ledgerera Source #

toShelleyTxOutAny :: forall ctx era ledgerera. (HasCallStack, ShelleyLedgerEra era ~ ledgerera) => ShelleyBasedEra era -> TxOut ctx era -> TxOut ledgerera Source #

A variant of 'toShelleyTxOutAny that is used only internally to this module that works with a TxOut in any context (including CtxTx) by ignoring embedded datums (taking only their hash).

Misc helpers

Data family instances

data family AsType t Source #

A family of singleton types used in this API to indicate which type to use where it would otherwise be ambiguous or merely unclear.

Values of this type are passed to deserialisation functions for example.

Instances

Instances details
data AsType AddressAny Source # 
Instance details

Defined in Cardano.Api.Address

data AsType ByronAddr Source # 
Instance details

Defined in Cardano.Api.Address

data AsType ShelleyAddr Source # 
Instance details

Defined in Cardano.Api.Address

data AsType StakeAddress Source # 
Instance details

Defined in Cardano.Api.Address

data AsType BlockHeader Source # 
Instance details

Defined in Cardano.Api.Block

data AsType ByronKey Source # 
Instance details

Defined in Cardano.Api.Byron.Internal.Key

data AsType ByronKeyLegacy Source # 
Instance details

Defined in Cardano.Api.Byron.Internal.Key

data AsType ByronUpdateProposal Source # 
Instance details

Defined in Cardano.Api.Byron.Internal.Proposal

data AsType ByronVote Source # 
Instance details

Defined in Cardano.Api.Byron.Internal.Proposal

data AsType DRepMetadata Source # 
Instance details

Defined in Cardano.Api.Certificate.Internal.DRepMetadata

data AsType OperationalCertificate Source # 
Instance details

Defined in Cardano.Api.Certificate.Internal.OperationalCertificate

data AsType OperationalCertificateIssueCounter Source # 
Instance details

Defined in Cardano.Api.Certificate.Internal.OperationalCertificate

data AsType StakePoolMetadata Source # 
Instance details

Defined in Cardano.Api.Certificate.Internal.StakePoolMetadata

data AsType AllegraEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType AlonzoEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType BabbageEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType ByronEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType ConwayEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType MaryEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType ShelleyEra Source # 
Instance details

Defined in Cardano.Api.Era.Internal.Core

data AsType GovernancePoll Source # 
Instance details

Defined in Cardano.Api.Governance.Internal.Poll

data AsType GovernancePollAnswer Source # 
Instance details

Defined in Cardano.Api.Governance.Internal.Poll

data AsType CommitteeColdExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType CommitteeColdKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType CommitteeHotExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType CommitteeHotKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType DRepExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType DRepKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType GenesisDelegateExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType GenesisDelegateKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType GenesisExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType GenesisKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType GenesisUTxOKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType PaymentExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType PaymentKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType StakeExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType StakeKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType StakePoolExtendedKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType StakePoolKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal

data AsType KesKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal.Praos

data AsType VrfKey Source # 
Instance details

Defined in Cardano.Api.Key.Internal.Praos

data AsType PlutusScriptV1 Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType PlutusScriptV2 Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType PlutusScriptV3 Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType ScriptHash Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType ScriptInAnyLang Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType SimpleScript' Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType HashableScriptData Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.ScriptData

data AsType ScriptData Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.ScriptData

data AsType PraosNonce Source # 
Instance details

Defined in Cardano.Api.ProtocolParameters

data AsType UpdateProposal Source # 
Instance details

Defined in Cardano.Api.ProtocolParameters

data AsType EraHistory Source # 
Instance details

Defined in Cardano.Api.Query.Internal.Type.QueryInMode

data AsType TextEnvelope Source # 
Instance details

Defined in Cardano.Api.Serialise.TextEnvelope.Internal

data AsType TxId Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxIn

data AsType TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

data AsType AssetName Source # 
Instance details

Defined in Cardano.Api.Value.Internal

data AsType PolicyId Source # 
Instance details

Defined in Cardano.Api.Value.Internal

data AsType GovActionId Source # 
Instance details

Defined in Cardano.Api.Internal.Orphans.Serialisation

data AsType Term Source # 
Instance details

Defined in Cardano.Api.Serialise.Cbor.Canonical

data AsType (Address addrtype) Source # 
Instance details

Defined in Cardano.Api.Address

data AsType (Address addrtype) = AsAddress (AsType addrtype)
data AsType (AddressInEra era) Source # 
Instance details

Defined in Cardano.Api.Address

data AsType (Certificate era) Source # 
Instance details

Defined in Cardano.Api.Certificate.Internal

data AsType (Proposal era) Source # 
Instance details

Defined in Cardano.Api.Governance.Internal.Action.ProposalProcedure

data AsType (VotingProcedure era) Source # 
Instance details

Defined in Cardano.Api.Governance.Internal.Action.VotingProcedure

data AsType (VotingProcedures era) Source # 
Instance details

Defined in Cardano.Api.Governance.Internal.Action.VotingProcedure

data AsType (Hash a) Source # 
Instance details

Defined in Cardano.Api.Hash

data AsType (Hash a) = AsHash (AsType a)
data AsType (SigningKey a) Source # 
Instance details

Defined in Cardano.Api.Key.Internal.Class

data AsType (VerificationKey a) Source # 
Instance details

Defined in Cardano.Api.Key.Internal.Class

data AsType (PlutusScript lang) Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType (Script lang) Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType (Script lang) = AsScript (AsType lang)
data AsType (ScriptInEra era) Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

data AsType (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (Tx era) = AsTx (AsType era)
data AsType (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (TxBody era) = AsTxBody (AsType era)
data AsType (Credential 'ColdCommitteeRole) Source # 
Instance details

Defined in Cardano.Api.Internal.Orphans.Serialisation

data AsType (Credential 'DRepRole) Source # 
Instance details

Defined in Cardano.Api.Internal.Orphans.Serialisation

data AsType (Credential 'HotCommitteeRole) Source # 
Instance details

Defined in Cardano.Api.Internal.Orphans.Serialisation

data AsType (PlutusScriptInEra era lang) Source # 
Instance details

Defined in Cardano.Api.Plutus.Internal.Script

Convenience construction functions

constructBalancedTx Source #

Arguments

:: ShelleyBasedEra era 
-> TxBodyContent BuildTx era 
-> AddressInEra era

Change address

-> Maybe Word

Override key witnesses

-> UTxO era

Just the transaction inputs, not the entire UTxO.

-> LedgerProtocolParameters era 
-> LedgerEpochInfo 
-> SystemStart 
-> Set PoolId

The set of registered stake pools

-> Map StakeCredential Coin 
-> Map (Credential 'DRepRole) Coin 
-> [ShelleyWitnessSigningKey] 
-> Either (TxBodyErrorAutoBalance era) (Tx era) 

Construct a balanced transaction. See Cardano.Api.Query.Internal.Convenience.queryStateForBalancedTx for a convenient way of querying the node to get the required arguements for constructBalancedTx.

Misc

Ledger TxBody wrapper with useful lens

newtype LedgerTxBody era Source #

Constructors

LedgerTxBody 

Constructors

Lenses

strictMaybeL :: forall a f. Functor f => (Maybe a -> f (Maybe a)) -> StrictMaybe a -> f (StrictMaybe a) Source #

invalidBeforeL :: Lens' ValidityInterval (Maybe SlotNo) Source #

Lens to access the invalidBefore field of a ValidityInterval as a 'Maybe SlotNo'.

invalidHereAfterL :: Lens' ValidityInterval (Maybe SlotNo) Source #

Lens to access the invalidHereAfter field of a ValidityInterval as a 'Maybe SlotNo'.

invalidBeforeStrictL :: Lens' ValidityInterval (StrictMaybe SlotNo) Source #

Lens to access the invalidBefore field of a ValidityInterval as a 'StrictMaybe SlotNo'. Ideally this should be defined in cardano-ledger

invalidHereAfterStrictL :: Lens' ValidityInterval (StrictMaybe SlotNo) Source #

Lens to access the invalidHereAfter field of a ValidityInterval as a 'StrictMaybe SlotNo'. Ideally this should be defined in cardano-ledger

invalidHereAfterTxBodyL :: ShelleyBasedEra era -> Lens' (LedgerTxBody era) (Maybe SlotNo) Source #

Compatibility lens that provides a consistent interface over ttlTxBodyL and 'vldtTxBodyL . invalidHereAfterStrictL' across all shelley based eras.

The ledger uses ttlTxBodyL in Shelley only and from Allegra onwards uses vldtTxBodyL instead.

The former is a SlotNo with no limit represented as maxBound.

The latter is a ValidityInterval which is a pair of SlotNos that represent the lower and upper bounds.

The upper bound field is similar t ttlTxBodyL except it is a 'StrictMaybe SlotNo' type where no bounds is represented by SNothing.

invalidHereAfterTxBodyL lens over both with a 'Maybe SlotNo' type representation. Withing the Shelley era, setting Nothing will set the ttl to maxBound in the underlying ledger type.

ttlAsInvalidHereAfterTxBodyL :: ShelleyEraOnly era -> Lens' (LedgerTxBody era) (Maybe SlotNo) Source #

Compatibility lens over ttlTxBodyL which represents maxBound as Nothing and all other values as Just.

txBodyL :: forall era f. Functor f => (TxBody (ShelleyLedgerEra era) -> f (TxBody (ShelleyLedgerEra era))) -> LedgerTxBody era -> f (LedgerTxBody era) Source #

Fees calculation

The Cardano.Api.Tx.Internal.Body documentation demonstrates how to create a TxBodyContent for a transaction that takes 12 ada and sends 10 ada to an address, and spends 2 ada for fees. If a UTXO with exactly 12 ada is available, this would be a valid transaction, because it is balanced, and has sufficient fees, as 2 ada is more than enough to cover the fees for such a simple transaction on mainnet at the time of writing.

A simple transaction that spends UTXOs is considered balanced if the value consumed equals the value produced. Simply put, a transaction that spends only lovelace must account for the total lovelace at the inputs, output(s), and transaction fee.

In other words:

inputs = outputs + fee

In this equation, the inputs would include the minted tokens, and the outputs would include the burned tokens.

However, we don't always want to spend all the ada from a UTXO. Balancing a transaction ensures that we send the desired amount, pay only the necessary fees, and calculate any extra currency to be sent back to a change address.

Since changes to the transaction body can affect the required, finding this balance can be challenging. Fortunately, there are functions available to help achieve this.

This module offers several methods for calculating transaction fees or fully balancing a draft transaction. Each method requires varying amounts of information and provides different levels of accuracy and automation.

Next, this module explores three examples of fee calculation methods. Other methods exist but they have similar requirements.

Examples below use the following qualified modules:

import qualified Cardano.Api as Api                -- the general `cardano-api` exports

Example 1: Simple fee calculation and manual balancing

This method requires minimal information and some manual work.

It calculates the transaction fees, but we need to balance the transaction manually.

We need to know:

  1. The Shelley-based era witness for the current era, which can be obtained by using shelleyBasedEra.
let sbe :: Api.ShelleyBasedEra Api.ConwayEra = Api.shelleyBasedEra
  1. The protocol parameters for the current era, which can be obtained using the QueryProtocolParameters query defined in Cardano.Api.Query.Internal.Type.QueryInMode. Cardano.Api.Network.IPC.Internal documentation illustrates how to make a query using IPC protocol. Let's assume they are stored in the exampleProtocolParams variable.
  2. The draft transaction body, which can be created using createTransactionBody defined in Cardano.Api.Tx.Internal.Body:
let (Right txBody) = Api.createTransactionBody sbe txBodyContent
  1. The number of Byron and Shelley key witnesses, which corresponds to the number of keys required to sign the transaction. We can estimate this by using estimateTransactionKeyWitnessCount. For a simple transaction with a single UTXO locked by a single modern Shelley key, there would be 0 Byron witnesses and 1 Shelley witness.
  2. The size of any reference scripts in bytes (if any). For simple transactions, this would be 0.

With this in mind, it is possible to estimate the fees required by the transaction by calling evaluateTransactionFee as follows:

let fees = Api.evaluateTransactionFee sbe exampleProtocolParams txBody 0 1 0

Once we know the required fees, we can balance the transaction by subtracting fees from the total value of the UTXO being spent.

For example, if we have a UTXO with 12 ada, the fees are 0.2 ada, and we want to send 10 ada to an address, the transaction could look like this:

  • 1 input of 12 ada (from the UTXO)
  • 1 output of 10 ada (to the recipient address)
  • 1 output of 1.8 ada (to the change address)
  • 0.2 ada in fees (calculated fees, in this case, an overestimation).

We would then have to update the TxBodyContent accordingly and continue building the transaction as demonstrated in Cardano.Api.Experimental.Tx.

Example 2: Automated balancing without chain information (no UTXO, no ledger state)

This method requires more information, but better automates the process, reducing the need for estimation. It also works with a TxBodyContent, rather than a full TxBody.

The following information is required:

  1. The MaryEraOnwards witness for the current era. In this case, we use the one for the Conway era:
let meo = Api.MaryEraOnwardsConway
  1. The draft TxBodyContent for the transaction we want to balance. See how to create one in Cardano.Api.Tx.Internal.Body. It is assumed to be stored in the txBodyContent variable.
  2. The protocol parameters for the current era, which can be obtained using the QueryProtocolParameters query defined in Cardano.Api.Query.Internal.Type.QueryInMode. Cardano.Api.Network.IPC.Internal documentation illustrates how to make a query using IPC protocol. Let's assume they are stored in the exampleProtocolParams variable.
  3. For stake pool and governance actions, we will also need:

    • The set of registered stake pools being unregistered in this transaction
    • The map of all deposits for stake credentials being unregistered in this transaction
    • The map of all deposits for DRep credentials that are unregistered in this transaction
    • Plutus script execution units for all script witnesses used in the transaction.

This example assumes we are only spending key-locked UTXOs. Therefore, we can ignore the above and use mempty.

  1. The following amounts:

    • Collateral amount: required only for transactions involving Plutus scripts. Since this transaction does not include any, the collateral is 0.
    • Amount of Shelley key witnesses to be added: estimated using estimateTransactionKeyWitnessCount. For a simple transaction spending a single UTXO locked by a modern Shelley key, there is 1 Shelley witness.
    • Amount of Byron key witnesses to be added: assumed to be 0 for this transaction.
    • Size of all reference scripts (in bytes): since no reference scripts are used, this value is 0.
  2. The address for sending the change. We can deserialize it from its bech32 representation using the deserialiseAddress function defined in Cardano.Api.Address:
let Just exampleChangeAddress =
           Api.deserialiseAddress
             (Api.AsAddressInEra eraAsType)
             "addr_test1vzpfxhjyjdlgk5c0xt8xw26avqxs52rtf69993j4tajehpcue4v2v"

Alternatively, we can get it from our signing key:

let exampleChangeAddress =
      Api.shelleyAddressInEra sbe $
        Api.makeShelleyAddress
          (Api.Testnet $ Api.NetworkMagic 2)    -- The magic for the network we are using
          (Api.PaymentCredentialByKey
             $ Api.verificationKeyHash
                 $ Api.getVerificationKey
                     signingKey)
          Api.NoStakeAddress                    -- Potentially, the stake credential if we want to use one
  1. Finally, we need the total amount of ada (and other tokens) in the UTXOs being spent. In this example, the transaction spends 12 ada:
let totalUTxOValue = Api.lovelaceToValue 12_000_000

With all this information, a balanced transaction can be obtained by calling estimateBalancedTxBody as follows:

let (Right (Api.BalancedTxBody
              updatedTxBodyContent
              updatedTxBody
              changeOutput
              fees)) =
      Api.estimateBalancedTxBody
        meo
        txBodyContent
        exampleProtocolParams
        mempty
        mempty
        mempty
        mempty
        0
        1
        0
        0
        exampleChangeAddress

This will produce a balanced transaction body with calculated fees and a change output, but it still needs to be signed and submitted.

Example 3: Fully automated balancing with chain information (requires UTXO and ledger state data)

The previous example required manually providing various details, which was feasible for a simple transaction. However, for more complex transactions involving scripts or advanced functionalities such as governance actions, a more automated approach is available. This method performs most calculations in exchange for general ledger information.

The following details are required:

  1. Shelley-based era witness for the current era, retrievable using shelleyBasedEra.
let sbe :: Api.ShelleyBasedEra Api.ConwayEra = Api.shelleyBasedEra
  1. Network start time, obtainable using the QuerySystemStart query defined in Cardano.Api.Query.Internal.Type.QueryInMode. Cardano.Api.Network.IPC.Internal documentation illustrates how to make a query using IPC protocol. Assume we have it in the exampleSystemStart variable.
  2. Ledger epoch information, derivable by applying toLedgerEpochInfo to the EraHistory, which can be retrieved using the QueryEraHistory query defined in Cardano.Api.Query.Internal.Type.QueryInMode. Assume this is stored in the exampleLedgerEpochInfo variable.
  3. Protocol parameters for the current era, accessible through the QueryProtocolParameters query defined in Cardano.Api.Query.Internal.Type.QueryInMode. Assume this is stored in the exampleProtocolParams variable.
  4. For stake pool and gov actions, additional data is requried:

    • The set of registered stake pools being unregistered in this transaction
    • The map of all deposits associated with stake credentials being unregistered in this transaction
    • The map of all deposits associated with DRep credentials being unregistered in this transaction.

For this example, no stake pool deregistration or governance actions are considered, so mempty is used for the corresponding parameters.

  1. UTXO set being spent -- the full UTXO set can be obtained using the QueryUTxO query from Cardano.Api.Query.Internal.Type.QueryInMode. Assume this is stored in the utxoToUse variable.
  2. Draft transaction body content -- the TxBodyContent for the transaction that requires balancing. The process for creating this structure is demonstrated in Cardano.Api.Tx.Internal.Body.
  3. Change address -- the address where any remaining balance should be returned. This can be deserialized from its Bech32 representation using the deserialiseAddress function from Cardano.Api.Address:
let (Just exampleChangeAddress) =
            Api.deserialiseAddress
              (Api.AsAddressInEra eraAsType)
              "addr_test1vzpfxhjyjdlgk5c0xt8xw26avqxs52rtf69993j4tajehpcue4v2v"

Alternatively, it is possible to get it from the signing key:

let exampleChangeAddress =
      Api.shelleyAddressInEra sbe $
        Api.makeShelleyAddress
          (Api.Testnet $ Api.NetworkMagic 2)    -- The magic for the network we are using
          (Api.PaymentCredentialByKey
             $ Api.verificationKeyHash
                 $ Api.getVerificationKey
                     signingKey)
          Api.NoStakeAddress                    -- Potentially, the stake credential if we want to use one
  1. Finally, the number of key witnesses required for the transaction can be manually specified. However, if set to Nothing, the function will automatically estimate the required number.

With all the necessary information available, a balanced transaction can be obtained by calling makeTransactionBodyAutoBalance as follows:

let Right (Api.BalancedTxBody
             updatedTxBodyContent
             updatedTxBody
             changeOutput
             fees) =
   Api.makeTransactionBodyAutoBalance
     sbe
     exampleSystemStart
     exampleLedgerEpochInfo
     (Api.LedgerProtocolParameters exampleProtocolParams)
     mempty
     mempty
     mempty
     utxoToUse
     txBodyContent
     exampleChangeAddress
     Nothing

This will give us a balanced transaction with the fees calculated and the change output included. The transaction can now be signed and submitted.

Transaction fees

evaluateTransactionFee Source #

Arguments

:: ShelleyBasedEra era 
-> PParams (ShelleyLedgerEra era) 
-> TxBody era 
-> Word

The number of Shelley key witnesses

-> Word

The number of Byron key witnesses

-> Int

Reference script size in bytes

-> Coin 

Transaction fees can be computed for a proposed transaction based on the expected number of key witnesses (i.e. signatures).

When possible, use calculateMinTxFee, as it provides a more accurate estimate:

calculateMinTxFee Source #

Arguments

:: ShelleyBasedEra era 
-> PParams (ShelleyLedgerEra era) 
-> UTxO era 
-> TxBody era 
-> Word

The number of Shelley key witnesses

-> Coin 

Estimate the minimum transaction fee by analyzing the transaction structure and determining the required number and type of key witnesses.

It requires access to the relevant portion of the UTXO set to look up any transaction inputs (txins) included in the transaction. However, it cannot reliably determine the number of witnesses required for native scripts.

Therefore, the number of witnesses needed for native scripts must be provided as an additional argument.

estimateTransactionKeyWitnessCount :: TxBodyContent BuildTx era -> Word Source #

Provide and approximate count of the key witnesses (i.e. signatures) required for a transaction.

This estimate is not exact and may overestimate the required number of witnesses. The function makes conservative assumptions, including:

  • Treating all inputs as originating from distinct addresses. In reality, multiple inputs may share the same address, requiring only one witness per address.
  • Assuming regular and collateral inputs are distinct, even though they may overlap.

TODO: Consider implementing a more precise calculation that leverages the UTXO set to determine which inputs correspond to distinct addresses. Additionally, the estimate can be refined by distinguishing between Shelley and Byron-style witnesses.

Script execution units

evaluateTransactionExecutionUnits :: CardanoEra era -> SystemStart -> LedgerEpochInfo -> LedgerProtocolParameters era -> UTxO era -> TxBody era -> Map ScriptWitnessIndex (Either ScriptExecutionError (EvalTxExecutionUnitsLog, ExecutionUnits)) Source #

Compute the ExecutionUnits required for each script in the transaction.

This process involves executing all scripts and counting the actual execution units consumed.

data ScriptExecutionError Source #

This data type represents the possible reasons for a script’s execution failure, as reported by the evaluateTransactionExecutionUnits function.

The first three errors relate to issues before executing the script, while the last two arise during script execution.

TODO: Consider replacing ScriptWitnessIndex with the ledger’s PlutusPurpose AsIx ledgerera. This change would require parameterizing the ScriptExecutionError.

Constructors

ScriptErrorMissingTxIn TxIn

The script depends on a TxIn that has not been provided in the given UTxO subset. The given UTxO must cover all the inputs the transaction references.

ScriptErrorTxInWithoutDatum TxIn

The TxIn the script is spending does not have a ScriptDatum. All inputs guarded by Plutus scripts need to have been created with a ScriptDatum.

ScriptErrorWrongDatum (Hash ScriptData)

The ScriptDatum provided does not match the one from the UTxO. This means the wrong ScriptDatum value has been provided.

ScriptErrorEvaluationFailed DebugPlutusFailure

The script evaluation failed. This usually means it evaluated to an error value. This is not a case of running out of execution units (which is not possible for evaluateTransactionExecutionUnits since the whole point of it is to discover how many execution units are needed).

ScriptErrorExecutionUnitsOverflow

The execution units overflowed a 64bit word. Congratulations if you encounter this error. With the current style of cost model this would need a script to run for over 7 months, which is somewhat more than the expected maximum of a few milliseconds.

ScriptErrorNotPlutusWitnessedTxIn ScriptWitnessIndex ScriptHash

An attempt was made to spend a key witnessed tx input with a script witness.

ScriptErrorRedeemerPointsToUnknownScriptHash ScriptWitnessIndex

The redeemer pointer points to a script hash that does not exist in the transaction nor in the UTxO as a reference script"

ScriptErrorMissingScript ScriptWitnessIndex ResolvablePointers

A redeemer pointer points to a script that does not exist.

ScriptErrorMissingCostModel Language

A cost model was missing for a language which was used.

(EraPlutusContext (ShelleyLedgerEra era), Show (ContextError (ShelleyLedgerEra era))) => ScriptErrorTranslationError (ContextError (ShelleyLedgerEra era)) 

data TransactionValidityError era where Source #

Constructors

TransactionValidityIntervalError :: forall era. PastHorizonException -> TransactionValidityError era

The transaction validity interval is too far into the future.

Transactions containing Plutus scripts must have a validity interval that is not excessively far in the future. This ensures that the UTC corresponding to the validity interval expressed in slot numbers, can be reliably determined.

Plutus scripts are given the transaction validity interval in UTC to prevent sensitivity to variations in slot lengths.

If either end of the validity interval exceeds the "time horizon", the consensus algorithm cannot reliably establish the relationship between slots and time.

This error occurs when thevalidity interval exceeds the time horizon. For the Cardano mainnet, the time horizon is set to 36 hours beyond the current time. This effectively restricts the submission and validation of transactions that include Plutus scripts if the end of their validity interval extends more than 36 hours into the future.

TransactionValidityCostModelError :: forall era. Map AnyPlutusScriptVersion CostModel -> String -> TransactionValidityError era 

Transaction balance

evaluateTransactionBalance :: ShelleyBasedEra era -> PParams (ShelleyLedgerEra era) -> Set PoolId -> Map StakeCredential Coin -> Map (Credential 'DRepRole) Coin -> UTxO era -> TxBody era -> TxOutValue era Source #

Compute the total balance of the proposed transaction. Ultimately, a valid transaction must be fully balanced, which means that it has a total value of zero.

Finding the (non-zero) balance of a partially constructed transaction is useful for adjusting a transaction to be fully balanced.

Automated transaction building

estimateBalancedTxBody Source #

Arguments

:: HasCallStack 
=> MaryEraOnwards era 
-> TxBodyContent BuildTx era 
-> PParams (ShelleyLedgerEra era) 
-> Set PoolId

The set of registered stake pools, being unregistered in this transaction.

-> Map StakeCredential Coin

A map of all deposits for stake credentials that are being unregistered in this transaction.

-> Map (Credential 'DRepRole) Coin

A map of all deposits for DRep credentials that are being unregistered in this transaction.

-> Map ScriptWitnessIndex ExecutionUnits

Plutus script execution units.

-> Coin

Total potential collateral amount.

-> Int

The number of key witnesses to be added to the transaction.

-> Int

The number of Byron key witnesses to be added to the transaction.

-> Int

The size of all reference scripts in bytes.

-> AddressInEra era

Change address.

-> Value

Total value of UTXOs being spent.

-> Either (TxFeeEstimationError era) (BalancedTxBody era) 

Use when you do not have access to the UTxOs you intend to spend

makeTransactionBodyAutoBalance Source #

Arguments

:: HasCallStack 
=> ShelleyBasedEra era 
-> SystemStart 
-> LedgerEpochInfo 
-> LedgerProtocolParameters era 
-> Set PoolId

The set of registered stake pools, being unregistered in this transaction.

-> Map StakeCredential Coin

The map of all deposits for stake credentials that are being unregistered in this transaction

-> Map (Credential 'DRepRole) Coin

The map of all deposits for DRep credentials that are being unregistered in this transaction

-> UTxO era

The transaction inputs (including reference and collateral ones), not the entire UTxO.

-> TxBodyContent BuildTx era 
-> AddressInEra era

Change address

-> Maybe Word

Override key witnesses

-> Either (TxBodyErrorAutoBalance era) (BalancedTxBody era) 

This is similar to makeTransactionBody but with greater automation to calculate suitable values for several things.

In particular:

  • It calculates the correct script ExecutionUnits (ignoring the provided values, which can thus be zero).
  • It calculates the transaction fees based on the script ExecutionUnits, the current ProtocolParameters, and an estimate of the number of key witnesses (i.e. signatures). There is an override for the number of key witnesses.
  • It accepts a change address, calculates the balance of the transaction and puts the excess change into the change output.
  • It also checks that the balance is positive and the change is above the minimum threshold.

To do this, it requires more information than makeTransactionBody, all of which can be queried from a local node.

calcReturnAndTotalCollateral Source #

Arguments

:: AlonzoEraPParams (ShelleyLedgerEra era) 
=> BabbageEraOnwards era 
-> Coin

Fee

-> PParams (ShelleyLedgerEra era) 
-> TxInsCollateral era

From the initial TxBodyContent

-> TxReturnCollateral CtxTx era

From the initial TxBodyContent

-> TxTotalCollateral era

From the initial TxBodyContent

-> AddressInEra era

Change address

-> Value (ShelleyLedgerEra era)

Total available collateral (can include non-ada)

-> (TxReturnCollateral CtxTx era, TxTotalCollateral era) 

data BalancedTxBody era Source #

Constructors

BalancedTxBody 

Fields

Instances

Instances details
IsShelleyBasedEra era => Show (BalancedTxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Fee

data FeeEstimationMode era Source #

Constructors

CalculateWithSpendableUTxO

Accurate fee calculation.

Fields

EstimateWithoutSpendableUTxO

Less accurate fee estimation.

Fields

data TxBodyErrorAutoBalance era Source #

The possible errors that can arise from makeTransactionBodyAutoBalance.

Constructors

TxBodyError TxBodyError

The same errors that can arise from makeTransactionBody.

TxBodyScriptExecutionError [(ScriptWitnessIndex, ScriptExecutionError)]

One or more scripts failed to execute correctly.

TxBodyScriptBadScriptValidity

One or more scripts were expected to fail validation, but none did.

TxBodyErrorBalanceNegative Coin MultiAsset

There is not enough ada and non-ada to cover both the outputs and the fees. The transaction should be changed to provide more input assets, or otherwise adjusted to need less (e.g. outputs, script etc).

TxBodyErrorAdaBalanceTooSmall

There is enough ada to cover both the outputs and the fees, but the resulting change is too small: it is under the minimum value for new UTXO entries. The transaction should be changed to provide more input ada.

Fields

TxBodyErrorByronEraNotSupported

makeTransactionBodyAutoBalance does not yet support the Byron era.

TxBodyErrorMissingParamMinUTxO

The ProtocolParameters must provide the value for the min utxo parameter, for eras that use this parameter.

TxBodyErrorMinUTxONotMet

The minimum spendable UTxO threshold has not been met.

Fields

TxBodyErrorNonAdaAssetsUnbalanced Value 
TxBodyErrorScriptWitnessIndexMissingFromExecUnitsMap ScriptWitnessIndex (Map ScriptWitnessIndex ExecutionUnits) 

Minimum UTxO calculation

Internal helpers

Signing a transaction

Example: Creating a ShelleyWitnessSigningKey Signing a transaction requires a witness, for example, a ShelleyWitnessSigningKey.

This example uses the following qualified module:

import qualified Cardano.Api as Api                -- the general `cardano-api` exports (including the old API)

There are several ways of signing a transaction and representing a signing key. If the bech32 representation of the signing key is available, it is possible to use the deserialiseFromBech32 function as follows:

let (Right signingKey) = Api.deserialiseFromBech32 (Api.AsSigningKey Api.AsPaymentKey) "addr_sk1648253w4tf6fv5fk28dc7crsjsaw7d9ymhztd4favg3cwkhz7x8sl5u3ms"

Then, simply wrap the signing key in a ShelleyWitnessSigningKey value:

let witness = Api.WitnessPaymentKey signingKey

This could also be done using an extended key, such as AsPaymentExtendedKey and WitnessPaymentExtendedKey.

Signing transactions

Creating transaction witnesses one by one, or all in one go.

data Tx era where Source #

Constructors

ShelleyTx :: forall era. ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era 

Bundled Patterns

pattern Tx :: TxBody era -> [KeyWitness era] -> Tx era

This pattern will be deprecated in the future. We advise against introducing new usage of it.

Instances

Instances details
Show (InAnyCardanoEra Tx) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Show (InAnyShelleyBasedEra Tx) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Show (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Methods

showsPrec :: Int -> Tx era -> ShowS Source #

show :: Tx era -> String Source #

showList :: [Tx era] -> ShowS Source #

HasTypeProxy era => HasTypeProxy (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Associated Types

data AsType (Tx era) 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (Tx era) = AsTx (AsType era)

Methods

proxyToAsType :: Proxy (Tx era) -> AsType (Tx era) Source #

IsShelleyBasedEra era => SerialiseAsCBOR (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

IsShelleyBasedEra era => HasTextEnvelope (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Eq (InAnyCardanoEra Tx) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Eq (InAnyShelleyBasedEra Tx) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Eq (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Methods

(==) :: Tx era -> Tx era -> Bool Source #

(/=) :: Tx era -> Tx era -> Bool Source #

data AsType (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data AsType (Tx era) = AsTx (AsType era)

data ATxAux a Source #

Constructors

ATxAux 

Fields

Instances

Instances details
Functor ATxAux 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

fmap :: (a -> b) -> ATxAux a -> ATxAux b Source #

(<$) :: a -> ATxAux b -> ATxAux a Source #

FromCBOR TxAux 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

ToCBOR TxAux 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

toCBOR :: TxAux -> Encoding Source #

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy TxAux -> Size Source #

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [TxAux] -> Size Source #

DecCBOR TxAux 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

EncCBOR TxAux 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

encCBOR :: TxAux -> Encoding Source #

encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size) -> Proxy TxAux -> Size Source #

encodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size) -> Proxy [TxAux] -> Size Source #

Buildable TxAux 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

build :: TxAux -> Builder

ToJSON a => ToJSON (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

toJSON :: ATxAux a -> Value #

toEncoding :: ATxAux a -> Encoding #

toJSONList :: [ATxAux a] -> Value #

toEncodingList :: [ATxAux a] -> Encoding #

omitField :: ATxAux a -> Bool #

Generic (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Associated Types

type Rep (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

type Rep (ATxAux a) = D1 ('MetaData "ATxAux" "Cardano.Chain.UTxO.TxAux" "cardano-ledger-byron-1.1.0.0-7fb551a04b7ebd202180a636c363fd4c69d431c37908920ba820fedd2c0d0ade" 'False) (C1 ('MetaCons "ATxAux" 'PrefixI 'True) (S1 ('MetaSel ('Just "aTaTx") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated Tx a)) :*: (S1 ('MetaSel ('Just "aTaWitness") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated TxWitness a)) :*: S1 ('MetaSel ('Just "aTaAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))))

Methods

from :: ATxAux a -> Rep (ATxAux a) x Source #

to :: Rep (ATxAux a) x -> ATxAux a Source #

Show a => Show (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

FromCBOR (ATxAux ByteSpan) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Decoded (ATxAux ByteString) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Associated Types

type BaseType (ATxAux ByteString) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

DecCBOR (ATxAux ByteSpan) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

NFData a => NFData (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

rnf :: ATxAux a -> () Source #

Eq a => Eq (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

Methods

(==) :: ATxAux a -> ATxAux a -> Bool Source #

(/=) :: ATxAux a -> ATxAux a -> Bool Source #

type Rep (ATxAux a) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

type Rep (ATxAux a) = D1 ('MetaData "ATxAux" "Cardano.Chain.UTxO.TxAux" "cardano-ledger-byron-1.1.0.0-7fb551a04b7ebd202180a636c363fd4c69d431c37908920ba820fedd2c0d0ade" 'False) (C1 ('MetaCons "ATxAux" 'PrefixI 'True) (S1 ('MetaSel ('Just "aTaTx") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated Tx a)) :*: (S1 ('MetaSel ('Just "aTaWitness") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated TxWitness a)) :*: S1 ('MetaSel ('Just "aTaAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))))
type BaseType (ATxAux ByteString) 
Instance details

Defined in Cardano.Chain.UTxO.TxAux

getTxBody :: Tx era -> TxBody era Source #

Signing in one go

data ShelleySigningKey Source #

We support making key witnesses with both normal and extended signing keys.

Constructors

ShelleyNormalSigningKey (SignKeyDSIGN DSIGN)

A normal ed25519 signing key

ShelleyExtendedSigningKey XPrv

An extended ed25519 signing key

Incremental signing and separate witnesses

data KeyWitness era where Source #

Instances

Instances details
Show (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

HasTypeProxy era => HasTypeProxy (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Associated Types

data AsType (KeyWitness era) 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

IsCardanoEra era => SerialiseAsCBOR (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

IsCardanoEra era => HasTextEnvelope (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Eq (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

Methods

(==) :: KeyWitness era -> KeyWitness era -> Bool Source #

(/=) :: KeyWitness era -> KeyWitness era -> Bool Source #

data AsType (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.Sign

data WitnessNetworkIdOrByronAddress Source #

Either a network ID or a Byron address to be used in constructing a Shelley bootstrap witness.

Constructors

WitnessNetworkId !NetworkId

Network ID.

If this value is used in the construction of a Shelley bootstrap witness, the result will not consist of a derivation path. If that is required, specify a WitnessByronAddress value instead.

WitnessByronAddress !(Address ByronAddr)

Byron address.

If this value is used in the construction of a Shelley bootstrap witness, both the network ID and derivation path will be extracted from the address and used in the construction of the witness.

TxMetadata

newtype TxMetadata Source #

Instances

Instances details
Monoid TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Semigroup TxMetadata Source #

Merge metadata maps. When there are clashing entries the left hand side takes precedence.

Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Show TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

HasTypeProxy TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Associated Types

data AsType TxMetadata 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

SerialiseAsCBOR TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Eq TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

data AsType TxMetadata Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Constructing metadata

metaTextChunks :: Text -> TxMetadataValue Source #

Create a TxMetadataValue from a Text as a list of chunks of an acceptable size.

metaBytesChunks :: ByteString -> TxMetadataValue Source #

Create a TxMetadataValue from a ByteString as a list of chunks of an accaptable size.

Validating metadata

validateTxMetadata :: TxMetadata -> Either [(Word64, TxMetadataRangeError)] () Source #

Validate transaction metadata. This is for use with existing constructed metadata values, e.g. constructed manually or decoded from CBOR directly.

data TxMetadataRangeError Source #

An error in transaction metadata due to an out-of-range value.

Constructors

TxMetadataNumberOutOfRange !Integer

The number is outside the maximum range of -2^64-1 .. 2^64-1.

TxMetadataTextTooLong !Int

The length of a text string metadatum value exceeds the maximum of 64 bytes as UTF8.

TxMetadataBytesTooLong !Int

The length of a byte string metadatum value exceeds the maximum of 64 bytes.

Instances

Instances details
Data TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TxMetadataRangeError -> c TxMetadataRangeError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TxMetadataRangeError Source #

toConstr :: TxMetadataRangeError -> Constr Source #

dataTypeOf :: TxMetadataRangeError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TxMetadataRangeError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TxMetadataRangeError) Source #

gmapT :: (forall b. Data b => b -> b) -> TxMetadataRangeError -> TxMetadataRangeError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataRangeError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataRangeError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TxMetadataRangeError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TxMetadataRangeError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TxMetadataRangeError -> m TxMetadataRangeError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataRangeError -> m TxMetadataRangeError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataRangeError -> m TxMetadataRangeError Source #

Show TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Error TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Eq TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Conversion to/from JSON

data TxMetadataJsonSchema Source #

Tx metadata is similar to JSON but not exactly the same. It has some deliberate limitations such as no support for floating point numbers or special forms for null or boolean values. It also has limitations on the length of strings. On the other hand, unlike JSON, it distinguishes between byte strings and text strings. It also supports any value as map keys rather than just string.

We provide two different mappings between tx metadata and JSON, useful for different purposes:

  1. A mapping that allows almost any JSON value to be converted into tx metadata. This does not require a specific JSON schema for the input. It does not expose the full representation capability of tx metadata.
  2. A mapping that exposes the full representation capability of tx metadata, but relies on a specific JSON schema for the input JSON.

In the "no schema" mapping, the idea is that (almost) any JSON can be turned into tx metadata and then converted back, without loss. That is, we can round-trip the JSON.

The subset of JSON supported is all JSON except: * No null or bool values * No floating point, only integers in the range of a 64bit signed integer * A limitation on string lengths

The approach for this mapping is to use whichever representation as tx metadata is most compact. In particular:

  • JSON lists and maps represented as CBOR lists and maps
  • JSON strings represented as CBOR strings
  • JSON hex strings with "0x" prefix represented as CBOR byte strings
  • JSON integer numbers represented as CBOR signed or unsigned numbers
  • JSON maps with string keys that parse as numbers or hex byte strings, represented as CBOR map keys that are actually numbers or byte strings.

The string length limit depends on whether the hex string representation is used or not. For text strings the limit is 64 bytes for the UTF8 representation of the text string. For byte strings the limit is 64 bytes for the raw byte form (ie not the input hex, but after hex decoding).

In the "detailed schema" mapping, the idea is that we expose the full representation capability of the tx metadata in the form of a JSON schema. This means the full representation is available and can be controlled precisely. It also means any tx metadata can be converted into the JSON and back without loss. That is we can round-trip the tx metadata via the JSON and also round-trip schema-compliant JSON via tx metadata.

Constructors

TxMetadataJsonNoSchema

Use the "no schema" mapping between JSON and tx metadata as described above.

TxMetadataJsonDetailedSchema

Use the "detailed schema" mapping between JSON and tx metadata as described above.

metadataFromJson :: TxMetadataJsonSchema -> Value -> Either TxMetadataJsonError TxMetadata Source #

Convert a value from JSON into tx metadata, using the given choice of mapping between JSON and tx metadata.

This may fail with a conversion error if the JSON is outside the supported subset for the chosen mapping. See TxMetadataJsonSchema for the details.

metadataToJson :: TxMetadataJsonSchema -> TxMetadata -> Value Source #

Convert a tx metadata value into JSON , using the given choice of mapping between JSON and tx metadata.

This conversion is total but is not necessarily invertible. See TxMetadataJsonSchema for the details.

data TxMetadataJsonError Source #

Instances

Instances details
Data TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TxMetadataJsonError -> c TxMetadataJsonError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TxMetadataJsonError Source #

toConstr :: TxMetadataJsonError -> Constr Source #

dataTypeOf :: TxMetadataJsonError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TxMetadataJsonError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TxMetadataJsonError) Source #

gmapT :: (forall b. Data b => b -> b) -> TxMetadataJsonError -> TxMetadataJsonError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TxMetadataJsonError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TxMetadataJsonError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TxMetadataJsonError -> m TxMetadataJsonError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonError -> m TxMetadataJsonError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonError -> m TxMetadataJsonError Source #

Show TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Error TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Eq TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

data TxMetadataJsonSchemaError Source #

Instances

Instances details
Data TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TxMetadataJsonSchemaError -> c TxMetadataJsonSchemaError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TxMetadataJsonSchemaError Source #

toConstr :: TxMetadataJsonSchemaError -> Constr Source #

dataTypeOf :: TxMetadataJsonSchemaError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TxMetadataJsonSchemaError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TxMetadataJsonSchemaError) Source #

gmapT :: (forall b. Data b => b -> b) -> TxMetadataJsonSchemaError -> TxMetadataJsonSchemaError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonSchemaError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonSchemaError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TxMetadataJsonSchemaError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TxMetadataJsonSchemaError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TxMetadataJsonSchemaError -> m TxMetadataJsonSchemaError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonSchemaError -> m TxMetadataJsonSchemaError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonSchemaError -> m TxMetadataJsonSchemaError Source #

Show TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Error TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Eq TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.Tx.Internal.TxMetadata

Internal conversion functions

Shared parsing utils

parseAll :: Parser a -> Text -> Maybe a Source #