| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Api.Typed
Contents
- Eras
- Cryptographic key interface
- Payment addresses
- Byron addresses
- Shelley addresses
- Stake addresses
- Building transactions
- Signing transactions
- Fee calculation
- Transaction metadata
- Registering stake address and delegating
- Registering stake pools
- Scripts
- Serialisation
- Errors
- Node interaction
- Node operation
- Genesis file
- Special transactions
Description
This module provides a library interface for interacting with Cardano as a user of the system.
It is intended to be used to write tools and
In the interest of simplicity it glosses over some details of the system. Most simple tools should be able to work just using this interface, however you can go deeper and expose the types from the underlying libraries using Cardano.Api.Byron or Cardano.Api.Shelley.
Synopsis
- data Byron
- data Shelley
- class HasTypeProxy t where
- data AsType t
- proxyToAsType :: Proxy t -> AsType t
- class (Eq (VerificationKey keyrole), Show (VerificationKey keyrole), SerialiseAsRawBytes (Hash keyrole), HasTextEnvelope (VerificationKey keyrole), HasTextEnvelope (SigningKey keyrole)) => Key keyrole
- getVerificationKey :: Key keyrole => SigningKey keyrole -> VerificationKey keyrole
- verificationKeyHash :: Key keyrole => VerificationKey keyrole -> Hash keyrole
- castVerificationKey :: CastVerificationKeyRole keyroleA keyroleB => VerificationKey keyroleA -> VerificationKey keyroleB
- castSigningKey :: CastSigningKeyRole keyroleA keyroleB => SigningKey keyroleA -> SigningKey keyroleB
- generateSigningKey :: Key keyrole => AsType keyrole -> IO (SigningKey keyrole)
- deterministicSigningKey :: Key keyrole => AsType keyrole -> Seed -> SigningKey keyrole
- deterministicSigningKeySeedSize :: Key keyrole => AsType keyrole -> Word
- data Seed
- mkSeedFromBytes :: ByteString -> Seed
- readSeedFromSystemEntropy :: Word -> IO Seed
- data family Hash keyrole :: Type
- castHash :: CastHash keyroleA keyroleB => Hash keyroleA -> Hash keyroleB
- data Address era where
- ByronAddress :: Address -> Address era
- ShelleyAddress :: Network -> PaymentCredential StandardShelley -> StakeReference StandardShelley -> Address Shelley
- data NetworkId
- makeByronAddress :: NetworkId -> VerificationKey ByronKey -> Address era
- data ByronKey
- makeShelleyAddress :: NetworkId -> PaymentCredential -> StakeAddressReference -> Address Shelley
- data PaymentCredential
- data StakeAddressReference
- = StakeAddressByValue StakeCredential
- | StakeAddressByPointer StakeAddressPointer
- | NoStakeAddress
- data PaymentKey
- data PaymentExtendedKey
- data StakeAddress where
- data StakeCredential
- makeStakeAddress :: NetworkId -> StakeCredential -> StakeAddress
- data StakeKey
- data StakeExtendedKey
- data TxBody era where
- ByronTxBody :: Annotated Tx ByteString -> TxBody Byron
- ShelleyTxBody :: TxBody StandardShelley -> Maybe MetaData -> TxBody Shelley
- newtype TxId = TxId (Hash StandardCrypto ())
- getTxId :: TxBody era -> TxId
- data TxIn = TxIn TxId TxIx
- data TxOut era = TxOut (Address era) Lovelace
- newtype TxIx = TxIx Word
- type TTL = SlotNo
- type TxFee = Lovelace
- newtype Lovelace = Lovelace Integer
- makeByronTransaction :: [TxIn] -> [TxOut Byron] -> Either ByronTxBodyConversionError (TxBody Byron)
- makeShelleyTransaction :: TxExtraContent -> TTL -> TxFee -> [TxIn] -> [TxOut anyera] -> TxBody Shelley
- newtype SlotNo = SlotNo {}
- data TxExtraContent = TxExtraContent {}
- txExtraContentEmpty :: TxExtraContent
- newtype Certificate = Certificate (DCert StandardShelley)
- data Tx era where
- ByronTx :: ATxAux ByteString -> Tx Byron
- ShelleyTx :: Tx StandardShelley -> Tx Shelley
- getTxBody :: Tx era -> TxBody era
- getTxWitnesses :: Tx era -> [Witness era]
- data ShelleySigningKey
- toShelleySigningKey :: ShelleyWitnessSigningKey -> ShelleySigningKey
- signByronTransaction :: NetworkId -> TxBody Byron -> [SigningKey ByronKey] -> Tx Byron
- signShelleyTransaction :: TxBody Shelley -> [ShelleyWitnessSigningKey] -> Tx Shelley
- makeSignedTransaction :: [Witness era] -> TxBody era -> Tx era
- data Witness era where
- makeByronKeyWitness :: NetworkId -> TxBody Byron -> SigningKey ByronKey -> Witness Byron
- data ShelleyWitnessSigningKey
- = WitnessPaymentKey (SigningKey PaymentKey)
- | WitnessPaymentExtendedKey (SigningKey PaymentExtendedKey)
- | WitnessStakeKey (SigningKey StakeKey)
- | WitnessStakeExtendedKey (SigningKey StakeExtendedKey)
- | WitnessStakePoolKey (SigningKey StakePoolKey)
- | WitnessGenesisKey (SigningKey GenesisKey)
- | WitnessGenesisExtendedKey (SigningKey GenesisExtendedKey)
- | WitnessGenesisDelegateKey (SigningKey GenesisDelegateKey)
- | WitnessGenesisDelegateExtendedKey (SigningKey GenesisDelegateExtendedKey)
- | WitnessGenesisUTxOKey (SigningKey GenesisUTxOKey)
- makeShelleyKeyWitness :: TxBody Shelley -> ShelleyWitnessSigningKey -> Witness Shelley
- data WitnessNetworkIdOrByronAddress
- makeShelleyBootstrapWitness :: WitnessNetworkIdOrByronAddress -> TxBody Shelley -> SigningKey ByronKey -> Witness Shelley
- makeShelleyScriptWitness :: Script -> Witness Shelley
- makeShelleySignature :: SignableRepresentation tosign => tosign -> ShelleySigningKey -> SignedDSIGN StandardCrypto tosign
- getShelleyKeyWitnessVerificationKey :: ShelleySigningKey -> VKey Witness StandardCrypto
- transactionFee :: Natural -> Natural -> Tx Shelley -> Lovelace
- estimateTransactionFee :: NetworkId -> Natural -> Natural -> Tx Shelley -> Int -> Int -> Int -> Int -> Lovelace
- newtype TxMetadata where
- TxMetadataShelley MetaData
- pattern TxMetadata :: Map Word64 TxMetadataValue -> TxMetadata
- data TxMetadataValue
- toShelleyMetaData :: Map Word64 TxMetadataValue -> MetaData
- fromShelleyMetaData :: MetaData -> Map Word64 TxMetadataValue
- makeTransactionMetadata :: Map Word64 TxMetadataValue -> TxMetadata
- makeStakeAddressRegistrationCertificate :: StakeCredential -> Certificate
- makeStakeAddressDeregistrationCertificate :: StakeCredential -> Certificate
- makeStakeAddressDelegationCertificate :: StakeCredential -> PoolId -> Certificate
- makeStakePoolRegistrationCertificate :: StakePoolParameters -> Certificate
- makeStakePoolRetirementCertificate :: PoolId -> EpochNo -> Certificate
- data StakePoolParameters = StakePoolParameters {}
- data StakePoolRelay
- data StakePoolMetadataReference = StakePoolMetadataReference {}
- data StakePoolMetadata = StakePoolMetadata {}
- validateAndHashStakePoolMetadata :: ByteString -> Either StakePoolMetadataValidationError (StakePoolMetadata, Hash StakePoolMetadata)
- data StakePoolMetadataValidationError
- newtype Script = Script (Script StandardShelley)
- parseScript :: Value -> Parser MultiSigScript
- parseScriptAny :: Value -> Parser MultiSigScript
- parseScriptAll :: Value -> Parser MultiSigScript
- parseScriptAtLeast :: Value -> Parser MultiSigScript
- parseScriptSig :: Value -> Parser MultiSigScript
- scriptHash :: Script -> Hash Script
- data MultiSigScript
- makeMultiSigScript :: MultiSigScript -> Script
- class HasTypeProxy a => SerialiseAsCBOR a
- class Typeable a => ToCBOR a
- class Typeable a => FromCBOR a
- serialiseToCBOR :: SerialiseAsCBOR a => a -> ByteString
- deserialiseFromCBOR :: SerialiseAsCBOR a => AsType a -> ByteString -> Either DecoderError a
- class ToJSON a
- class FromJSON a
- serialiseToJSON :: ToJSON a => a -> ByteString
- deserialiseFromJSON :: FromJSON a => AsType a -> ByteString -> Either JsonDecodeError a
- class (HasTypeProxy a, SerialiseAsRawBytes a) => SerialiseAsBech32 a
- serialiseToBech32 :: SerialiseAsBech32 a => a -> Text
- deserialiseFromBech32 :: SerialiseAsBech32 a => AsType a -> Text -> Either Bech32DecodeError a
- deserialiseAnyOfFromBech32 :: forall b. [FromSomeType SerialiseAsBech32 b] -> Text -> Either Bech32DecodeError b
- data Bech32DecodeError
- class HasTypeProxy addr => SerialiseAddress addr
- serialiseAddress :: SerialiseAddress addr => addr -> Text
- deserialiseAddress :: SerialiseAddress addr => AsType addr -> Text -> Maybe addr
- class HasTypeProxy a => SerialiseAsRawBytes a
- serialiseToRawBytes :: SerialiseAsRawBytes a => a -> ByteString
- deserialiseFromRawBytes :: SerialiseAsRawBytes a => AsType a -> ByteString -> Maybe a
- serialiseToRawBytesHex :: SerialiseAsRawBytes a => a -> ByteString
- deserialiseFromRawBytesHex :: SerialiseAsRawBytes a => AsType a -> ByteString -> Maybe a
- class SerialiseAsCBOR a => HasTextEnvelope a where
- type TextEnvelope = TextView
- type TextEnvelopeType = TextViewType
- type TextEnvelopeDescr = TextViewDescription
- type TextEnvelopeError = TextViewError
- serialiseToTextEnvelope :: forall a. HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> TextEnvelope
- deserialiseFromTextEnvelope :: HasTextEnvelope a => AsType a -> TextEnvelope -> Either TextEnvelopeError a
- readFileTextEnvelope :: HasTextEnvelope a => AsType a -> FilePath -> IO (Either (FileError TextEnvelopeError) a)
- writeFileTextEnvelope :: HasTextEnvelope a => FilePath -> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ())
- readTextEnvelopeFromFile :: FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope)
- readTextEnvelopeOfTypeFromFile :: TextEnvelopeType -> FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope)
- data FromSomeType (c :: Type -> Constraint) b where
- FromSomeType :: c a => AsType a -> (a -> b) -> FromSomeType c b
- deserialiseFromTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> TextEnvelope -> Either TextEnvelopeError b
- readFileTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> FilePath -> IO (Either (FileError TextEnvelopeError) b)
- class Show e => Error e where
- displayError :: e -> String
- throwErrorAsException :: Error e => e -> IO a
- data FileError e
- connectToLocalNode :: forall mode block. (ShowProxy block, ShowProxy (ApplyTxErr block), ShowProxy (Query block), ShowProxy (GenTx block), ShowQuery (Query block)) => LocalNodeConnectInfo mode block -> LocalNodeClientProtocols block -> IO ()
- data LocalNodeConnectInfo mode block = LocalNodeConnectInfo {}
- data ByronMode
- data ShelleyMode
- data CardanoMode
- data NodeConsensusMode mode block where
- data LocalNodeClientProtocols block = LocalNodeClientProtocols {
- localChainSyncClient :: Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
- localTxSubmissionClient :: Maybe (LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
- localStateQueryClient :: Maybe (LocalStateQueryClient block (Point block) (Query block) IO ())
- nullLocalNodeClientProtocols :: LocalNodeClientProtocols block
- withNodeProtocolClient :: NodeConsensusMode mode block -> ((SerialiseNodeToClientConstraints block, SupportedNetworkProtocolVersion block) => ProtocolClient block (BlockProtocol block) -> a) -> a
- newtype ChainSyncClient header point tip (m :: Type -> Type) a = ChainSyncClient {
- runChainSyncClient :: m (ClientStIdle header point tip m a)
- newtype LocalTxSubmissionClient tx reject (m :: Type -> Type) a = LocalTxSubmissionClient {
- runLocalTxSubmissionClient :: m (LocalTxClientStIdle tx reject m a)
- submitTxToNodeLocal :: forall mode block. (ShowProxy block, ShowProxy (ApplyTxErr block), ShowProxy (Query block), ShowProxy (GenTx block), ShowQuery (Query block)) => LocalNodeConnectInfo mode block -> GenTx block -> IO (SubmitResult (ApplyTxErr block))
- newtype LocalStateQueryClient block point (query :: Type -> Type) (m :: Type -> Type) a = LocalStateQueryClient {
- runLocalStateQueryClient :: m (ClientStIdle block point query m a)
- queryNodeLocalState :: forall mode block result. (ShowProxy block, ShowProxy (ApplyTxErr block), ShowProxy (Query block), ShowProxy (GenTx block), ShowQuery (Query block)) => LocalNodeConnectInfo mode block -> (Point block, Query block result) -> IO (Either AcquireFailure result)
- data StakePoolKey
- type PoolId = Hash StakePoolKey
- data KesKey
- data VrfKey
- data OperationalCertificate = OperationalCertificate !(OCert StandardCrypto) !(VerificationKey StakePoolKey)
- data OperationalCertificateIssueCounter = OperationalCertificateIssueCounter !Word64 !(VerificationKey StakePoolKey)
- newtype KESPeriod = KESPeriod {
- unKESPeriod :: Word
- data OperationalCertIssueError = OperationalCertKeyMismatch (VerificationKey StakePoolKey) (VerificationKey StakePoolKey)
- issueOperationalCertificate :: VerificationKey KesKey -> Either (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey) -> KESPeriod -> OperationalCertificateIssueCounter -> Either OperationalCertIssueError (OperationalCertificate, OperationalCertificateIssueCounter)
- data GenesisKey
- data GenesisExtendedKey
- data GenesisDelegateKey
- data GenesisDelegateExtendedKey
- data GenesisUTxOKey
- genesisUTxOPseudoTxIn :: NetworkId -> Hash GenesisUTxOKey -> TxIn
- makeMIRCertificate :: MIRPot -> [(StakeCredential, Lovelace)] -> Certificate
- makeGenesisKeyDelegationCertificate :: Hash GenesisKey -> Hash GenesisDelegateKey -> Hash VrfKey -> Certificate
- newtype UpdateProposal = UpdateProposal (Update StandardShelley)
- data ProtocolParametersUpdate = ProtocolParametersUpdate {
- protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
- protocolUpdateDecentralization :: Maybe Rational
- protocolUpdateExtraPraosEntropy :: Maybe (Maybe ByteString)
- protocolUpdateMaxBlockHeaderSize :: Maybe Natural
- protocolUpdateMaxBlockBodySize :: Maybe Natural
- protocolUpdateMaxTxSize :: Maybe Natural
- protocolUpdateTxFeeFixed :: Maybe Natural
- protocolUpdateTxFeePerByte :: Maybe Natural
- protocolUpdateMinUTxOValue :: Maybe Lovelace
- protocolUpdateStakeAddressDeposit :: Maybe Lovelace
- protocolUpdateStakePoolDeposit :: Maybe Lovelace
- protocolUpdateMinPoolCost :: Maybe Lovelace
- protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
- protocolUpdateStakePoolTargetNum :: Maybe Natural
- protocolUpdatePoolPledgeInfluence :: Maybe Rational
- protocolUpdateMonetaryExpansion :: Maybe Rational
- protocolUpdateTreasuryCut :: Maybe Rational
- newtype EpochNo = EpochNo {}
- newtype NetworkMagic = NetworkMagic {}
- makeShelleyUpdateProposal :: ProtocolParametersUpdate -> [Hash GenesisKey] -> EpochNo -> UpdateProposal
- toShelleyPParamsUpdate :: ProtocolParametersUpdate -> PParamsUpdate StandardShelley
- toByronNetworkMagic :: NetworkId -> NetworkMagic
- toByronProtocolMagicId :: NetworkId -> ProtocolMagicId
- toByronRequiresNetworkMagic :: NetworkId -> RequiresNetworkMagic
- toByronLovelace :: Lovelace -> Maybe Lovelace
- toByronTxIn :: TxIn -> TxIn
- toByronTxId :: TxId -> TxId
- toByronTxOut :: TxOut Byron -> Maybe TxOut
- toShelleyNetwork :: NetworkId -> Network
- toShelleyPoolParams :: StakePoolParameters -> PoolParams StandardShelley
- toNetworkMagic :: NetworkId -> NetworkMagic
- data Addr era
- = Addr Network (PaymentCredential era) (StakeReference era)
- | AddrBootstrap (BootstrapAddress era)
- newtype Coin = Coin {}
- newtype EpochSize = EpochSize {}
- data GenDelegPair crypto = GenDelegPair {
- genDelegKeyHash :: !(KeyHash 'GenesisDelegate crypto)
- genDelegVrfHash :: !(Hash crypto (VerKeyVRF crypto))
- data KeyRole
- newtype KeyHash (discriminator :: KeyRole) crypto = KeyHash (Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto)))
- data PParams' (f :: Type -> Type) era = PParams {
- _minfeeA :: !(HKD f Natural)
- _minfeeB :: !(HKD f Natural)
- _maxBBSize :: !(HKD f Natural)
- _maxTxSize :: !(HKD f Natural)
- _maxBHSize :: !(HKD f Natural)
- _keyDeposit :: !(HKD f Coin)
- _poolDeposit :: !(HKD f Coin)
- _eMax :: !(HKD f EpochNo)
- _nOpt :: !(HKD f Natural)
- _a0 :: !(HKD f Rational)
- _rho :: !(HKD f UnitInterval)
- _tau :: !(HKD f UnitInterval)
- _d :: !(HKD f UnitInterval)
- _extraEntropy :: !(HKD f Nonce)
- _protocolVersion :: !(HKD f ProtVer)
- _minUTxOValue :: !(HKD f Coin)
- _minPoolCost :: !(HKD f Coin)
- type PParamsUpdate era = PParams' StrictMaybe era
- type VerKeyVRF c = VerKeyVRF (VRF c)
- type StandardShelley = ShelleyEra StandardCrypto
- emptyPParams :: PParams era
- truncateUnitInterval :: Ratio Word64 -> UnitInterval
- emptyGenesisStaking :: ShelleyGenesisStaking era
- secondsToNominalDiffTime :: Double -> NominalDiffTime
Eras
A type used as a tag to distinguish the Byron era.
Instances
A type used as a tag to distinguish the Shelley era.
Instances
class HasTypeProxy t where Source #
Associated Types
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
Methods
proxyToAsType :: Proxy t -> AsType t Source #
Instances
Cryptographic key interface
Cardano has lots of cryptographic keys used for lots of different purposes. Some keys have different representations, but most are just using keys in different roles.
To allow for the different representations and to avoid mistakes we distinguish the key role. These are type level distinctions, so each of these roles is a type level tag.
class (Eq (VerificationKey keyrole), Show (VerificationKey keyrole), SerialiseAsRawBytes (Hash keyrole), HasTextEnvelope (VerificationKey keyrole), HasTextEnvelope (SigningKey keyrole)) => Key keyrole Source #
An interface for cryptographic keys used for signatures with a SigningKey
and a VerificationKey key.
This interface does not provide actual signing or verifying functions since this API is concerned with the management of keys: generating and serialising.
Minimal complete definition
getVerificationKey, deterministicSigningKey, deterministicSigningKeySeedSize, verificationKeyHash
Instances
getVerificationKey :: Key keyrole => SigningKey keyrole -> VerificationKey keyrole Source #
Get the corresponding verification key from a signing key.
verificationKeyHash :: Key keyrole => VerificationKey keyrole -> Hash keyrole Source #
castVerificationKey :: CastVerificationKeyRole keyroleA keyroleB => VerificationKey keyroleA -> VerificationKey keyroleB Source #
Change the role of a VerificationKey, if the representation permits.
castSigningKey :: CastSigningKeyRole keyroleA keyroleB => SigningKey keyroleA -> SigningKey keyroleB Source #
Change the role of a SigningKey, if the representation permits.
Generating keys
generateSigningKey :: Key keyrole => AsType keyrole -> IO (SigningKey keyrole) Source #
Generate a SigningKey using a seed from operating system entropy.
deterministicSigningKey :: Key keyrole => AsType keyrole -> Seed -> SigningKey keyrole Source #
Generate a SigningKey deterministically, given a Seed. The
required size of the seed is given by deterministicSigningKeySeedSize.
A seed contains a finite number of bytes, and is used for seeding cryptographic algorithms including key generation.
This is not itself a PRNG, but can be used to seed a PRNG.
mkSeedFromBytes :: ByteString -> Seed Source #
Construct a Seed deterministically from a number of bytes.
readSeedFromSystemEntropy :: Word -> IO Seed Source #
Obtain a Seed by reading n bytes of entropy from the operating system.
Hashes
In Cardano most keys are identified by their hash, and hashes are used in many other places.
data family Hash keyrole :: Type Source #
Instances
Payment addresses
Constructing and inspecting normal payment addresses
data Address era where Source #
Constructors
| ByronAddress :: Address -> Address era | Byron addresses are valid in both the Byron and Shelley era. |
| ShelleyAddress :: Network -> PaymentCredential StandardShelley -> StakeReference StandardShelley -> Address Shelley | Shelley addresses are only valid in the Shelley era. |
Instances
Byron addresses
Byron-era payment keys. Used for Byron addresses and witnessing transactions that spend from these addresses.
These use Ed25519 but with a 32byte "chaincode" used in HD derivation.
The inclusion of the chaincode is a design mistake but one that cannot
be corrected for the Byron era. The Shelley era PaymentKeys do not include
a chaincode. It is safe to use a zero or random chaincode for new Byron keys.
This is a type level tag, used with other interfaces like Key.
Instances
Shelley addresses
makeShelleyAddress :: NetworkId -> PaymentCredential -> StakeAddressReference -> Address Shelley Source #
data PaymentCredential Source #
Constructors
| PaymentCredentialByKey (Hash PaymentKey) | |
| PaymentCredentialByScript (Hash Script) |
Instances
| Eq PaymentCredential Source # | |
Defined in Cardano.Api.Typed Methods (==) :: PaymentCredential -> PaymentCredential -> Bool # (/=) :: PaymentCredential -> PaymentCredential -> Bool # | |
| Show PaymentCredential Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> PaymentCredential -> ShowS # show :: PaymentCredential -> String # showList :: [PaymentCredential] -> ShowS # | |
data StakeAddressReference Source #
Constructors
| StakeAddressByValue StakeCredential | |
| StakeAddressByPointer StakeAddressPointer | |
| NoStakeAddress |
Instances
| Eq StakeAddressReference Source # | |
Defined in Cardano.Api.Typed Methods (==) :: StakeAddressReference -> StakeAddressReference -> Bool # (/=) :: StakeAddressReference -> StakeAddressReference -> Bool # | |
| Show StakeAddressReference Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> StakeAddressReference -> ShowS # show :: StakeAddressReference -> String # showList :: [StakeAddressReference] -> ShowS # | |
data PaymentKey Source #
Shelley-era payment keys. Used for Shelley payment addresses and witnessing transactions that spend from these addresses.
This is a type level tag, used with other interfaces like Key.
Instances
data PaymentExtendedKey Source #
Shelley-era payment keys using extended ed25519 cryptographic keys.
They can be used for Shelley payment addresses and witnessing transactions that spend from these addresses.
These extended keys are used by HD wallets. So this type provides interoperability with HD wallets. The ITN CLI also supported this key type.
The extended verification keys can be converted (via castVerificationKey)
to ordinary keys (i.e. VerificationKey PaymentKey) but this is not the
case for the signing keys. The signing keys can be used to witness
transactions directly, with verification via their non-extended verification
key (VerificationKey PaymentKey).
This is a type level tag, used with other interfaces like Key.
Instances
Stake addresses
Constructing and inspecting stake addresses
data StakeAddress where Source #
Constructors
| StakeAddress :: Network -> StakeCredential StandardShelley -> StakeAddress |
Instances
data StakeCredential Source #
Constructors
| StakeCredentialByKey (Hash StakeKey) | |
| StakeCredentialByScript (Hash Script) |
Instances
| Eq StakeCredential Source # | |
Defined in Cardano.Api.Typed Methods (==) :: StakeCredential -> StakeCredential -> Bool # (/=) :: StakeCredential -> StakeCredential -> Bool # | |
| Show StakeCredential Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> StakeCredential -> ShowS # show :: StakeCredential -> String # showList :: [StakeCredential] -> ShowS # | |
Instances
data StakeExtendedKey Source #
Shelley-era stake keys using extended ed25519 cryptographic keys.
They can be used for Shelley stake addresses and witnessing transactions that use stake addresses.
These extended keys are used by HD wallets. So this type provides interoperability with HD wallets. The ITN CLI also supported this key type.
The extended verification keys can be converted (via castVerificationKey)
to ordinary keys (i.e. VerificationKey StakeKey) but this is not the
case for the signing keys. The signing keys can be used to witness
transactions directly, with verification via their non-extended verification
key (VerificationKey StakeKey).
This is a type level tag, used with other interfaces like Key.
Instances
Building transactions
Constructing and inspecting transactions
data TxBody era where Source #
Constructors
| ByronTxBody :: Annotated Tx ByteString -> TxBody Byron | |
| ShelleyTxBody :: TxBody StandardShelley -> Maybe MetaData -> TxBody Shelley |
Instances
Constructors
| TxId (Hash StandardCrypto ()) |
Instances
| Eq TxId Source # | |
| Ord TxId Source # | |
| Show TxId Source # | |
| IsString TxId Source # | |
Defined in Cardano.Api.Typed Methods fromString :: String -> TxId # | |
| SerialiseAsRawBytes TxId Source # | |
Defined in Cardano.Api.Typed Methods serialiseToRawBytes :: TxId -> ByteString Source # deserialiseFromRawBytes :: AsType TxId -> ByteString -> Maybe TxId Source # | |
| HasTypeProxy TxId Source # | |
| data AsType TxId Source # | |
Defined in Cardano.Api.Typed | |
Instances
| Enum Lovelace Source # | |
Defined in Cardano.Api.Typed | |
| Eq Lovelace Source # | |
| Ord Lovelace Source # | |
Defined in Cardano.Api.Typed | |
| Show Lovelace Source # | |
makeByronTransaction :: [TxIn] -> [TxOut Byron] -> Either ByronTxBodyConversionError (TxBody Byron) Source #
makeShelleyTransaction :: TxExtraContent -> TTL -> TxFee -> [TxIn] -> [TxOut anyera] -> TxBody Shelley Source #
The 0-based index for the Ourboros time slot.
Instances
| Bounded SlotNo | |
| Enum SlotNo | |
Defined in Cardano.Slotting.Slot | |
| Eq SlotNo | |
| Num SlotNo | |
| Ord SlotNo | |
| Show SlotNo | |
| Generic SlotNo | |
| NFData SlotNo | |
Defined in Cardano.Slotting.Slot | |
| ToJSON SlotNo | |
| FromJSON SlotNo | |
| ToCBOR SlotNo | |
| FromCBOR SlotNo | |
| NoThunks SlotNo | |
| Serialise SlotNo | |
| Condense SlotNo | |
| HasField "ttl" (TxBody era) SlotNo | |
Defined in Shelley.Spec.Ledger.TxBody | |
| Embed (StakeCreds era) (Map (Credential 'Staking era) SlotNo) | |
Defined in Shelley.Spec.Ledger.TxBody Methods toBase :: StakeCreds era -> Map (Credential 'Staking era) SlotNo Source # fromBase :: Map (Credential 'Staking era) SlotNo -> StakeCreds era Source # | |
| HasExp (StakeCreds era) (Map (Credential 'Staking era) SlotNo) | |
Defined in Shelley.Spec.Ledger.TxBody Methods toExp :: StakeCreds era -> Exp (Map (Credential 'Staking era) SlotNo) Source # | |
| type Rep SlotNo | |
Defined in Cardano.Slotting.Slot | |
data TxExtraContent Source #
Constructors
| TxExtraContent | |
Fields | |
newtype Certificate Source #
Constructors
| Certificate (DCert StandardShelley) |
Instances
Signing transactions
Creating transaction witnesses one by one, or all in one go.
Constructors
| ByronTx :: ATxAux ByteString -> Tx Byron | |
| ShelleyTx :: Tx StandardShelley -> Tx Shelley |
Instances
getTxWitnesses :: Tx era -> [Witness era] Source #
Signing in one go
data ShelleySigningKey Source #
We support making key witnesses with both normal and extended signing keys.
Incremental signing and separate witnesses
data Witness era where Source #
Constructors
Instances
data ShelleyWitnessSigningKey Source #
Constructors
| WitnessPaymentKey (SigningKey PaymentKey) | |
| WitnessPaymentExtendedKey (SigningKey PaymentExtendedKey) | |
| WitnessStakeKey (SigningKey StakeKey) | |
| WitnessStakeExtendedKey (SigningKey StakeExtendedKey) | |
| WitnessStakePoolKey (SigningKey StakePoolKey) | |
| WitnessGenesisKey (SigningKey GenesisKey) | |
| WitnessGenesisExtendedKey (SigningKey GenesisExtendedKey) | |
| WitnessGenesisDelegateKey (SigningKey GenesisDelegateKey) | |
| WitnessGenesisDelegateExtendedKey (SigningKey GenesisDelegateExtendedKey) | |
| WitnessGenesisUTxOKey (SigningKey GenesisUTxOKey) |
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 !(Address Byron) | 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. |
makeShelleyBootstrapWitness :: WitnessNetworkIdOrByronAddress -> TxBody Shelley -> SigningKey ByronKey -> Witness Shelley Source #
makeShelleySignature :: SignableRepresentation tosign => tosign -> ShelleySigningKey -> SignedDSIGN StandardCrypto tosign Source #
Fee calculation
For a concrete fully-constructed transaction, determine the minimum fee that it needs to pay.
This function is simple, but if you are doing input selection then you probably want to consider estimateTransactionFee.
estimateTransactionFee Source #
Arguments
| :: NetworkId | |
| -> Natural | The fixed tx fee |
| -> Natural | The tx fee per byte |
| -> Tx Shelley | |
| -> Int | The number of extra UTxO transaction inputs |
| -> Int | The number of extra transaction outputs |
| -> Int | The number of extra Shelley key witnesses |
| -> Int | The number of extra Byron key witnesses |
| -> Lovelace |
This can estimate what the transaction fee will be, based on a starting base transaction, plus the numbers of the additional components of the transaction that may be added.
So for example with wallet coin selection, the base transaction should contain all the things not subject to coin selection (such as script inputs, metadata, withdrawals, certs etc)
Transaction metadata
Embedding additional structured data within transactions.
newtype TxMetadata Source #
Constructors
| TxMetadataShelley MetaData |
Bundled Patterns
| pattern TxMetadata :: Map Word64 TxMetadataValue -> TxMetadata |
Instances
data TxMetadataValue Source #
Constructors
| TxMetaNumber Integer | |
| TxMetaBytes ByteString | |
| TxMetaText Text | |
| TxMetaList [TxMetadataValue] | |
| TxMetaMap [(TxMetadataValue, TxMetadataValue)] |
Instances
| Eq TxMetadataValue Source # | |
Defined in Cardano.Api.Typed Methods (==) :: TxMetadataValue -> TxMetadataValue -> Bool # (/=) :: TxMetadataValue -> TxMetadataValue -> Bool # | |
| Ord TxMetadataValue Source # | |
Defined in Cardano.Api.Typed Methods compare :: TxMetadataValue -> TxMetadataValue -> Ordering # (<) :: TxMetadataValue -> TxMetadataValue -> Bool # (<=) :: TxMetadataValue -> TxMetadataValue -> Bool # (>) :: TxMetadataValue -> TxMetadataValue -> Bool # (>=) :: TxMetadataValue -> TxMetadataValue -> Bool # max :: TxMetadataValue -> TxMetadataValue -> TxMetadataValue # min :: TxMetadataValue -> TxMetadataValue -> TxMetadataValue # | |
| Show TxMetadataValue Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> TxMetadataValue -> ShowS # show :: TxMetadataValue -> String # showList :: [TxMetadataValue] -> ShowS # | |
Registering stake address and delegating
Certificates that are embedded in transactions for registering and unregistering stake address, and for setting the stake pool delegation choice for a stake address.
Registering stake pools
Certificates that are embedded in transactions for registering and retiring stake pools. This includes updating the stake pool parameters.
data StakePoolParameters Source #
Constructors
| StakePoolParameters | |
Fields | |
Instances
| Eq StakePoolParameters Source # | |
Defined in Cardano.Api.Typed Methods (==) :: StakePoolParameters -> StakePoolParameters -> Bool # (/=) :: StakePoolParameters -> StakePoolParameters -> Bool # | |
| Show StakePoolParameters Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> StakePoolParameters -> ShowS # show :: StakePoolParameters -> String # showList :: [StakePoolParameters] -> ShowS # | |
data StakePoolRelay Source #
Constructors
| StakePoolRelayIp (Maybe IPv4) (Maybe IPv6) (Maybe PortNumber) | One or both of IPv4 & IPv6 |
| StakePoolRelayDnsARecord ByteString (Maybe PortNumber) | An DNS name pointing to a |
| StakePoolRelayDnsSrvRecord ByteString | A DNS name pointing to a |
Instances
| Eq StakePoolRelay Source # | |
Defined in Cardano.Api.Typed Methods (==) :: StakePoolRelay -> StakePoolRelay -> Bool # (/=) :: StakePoolRelay -> StakePoolRelay -> Bool # | |
| Show StakePoolRelay Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> StakePoolRelay -> ShowS # show :: StakePoolRelay -> String # showList :: [StakePoolRelay] -> ShowS # | |
data StakePoolMetadataReference Source #
Constructors
| StakePoolMetadataReference | |
Instances
| Eq StakePoolMetadataReference Source # | |
Defined in Cardano.Api.Typed Methods (==) :: StakePoolMetadataReference -> StakePoolMetadataReference -> Bool # (/=) :: StakePoolMetadataReference -> StakePoolMetadataReference -> Bool # | |
| Show StakePoolMetadataReference Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> StakePoolMetadataReference -> ShowS # show :: StakePoolMetadataReference -> String # showList :: [StakePoolMetadataReference] -> ShowS # | |
Stake pool off-chain metadata
data StakePoolMetadata Source #
A representation of the required fields for off-chain stake pool metadata.
Constructors
| StakePoolMetadata | |
Fields
| |
Instances
validateAndHashStakePoolMetadata :: ByteString -> Either StakePoolMetadataValidationError (StakePoolMetadata, Hash StakePoolMetadata) Source #
Decode and validate the provided JSON-encoded bytes as StakePoolMetadata.
Return the decoded metadata and the hash of the original bytes.
data StakePoolMetadataValidationError Source #
A stake pool metadata validation error.
Constructors
| StakePoolMetadataJsonDecodeError !String | |
| StakePoolMetadataInvalidLengthError | The length of the JSON-encoded stake pool metadata exceeds the maximum. |
Instances
| Show StakePoolMetadataValidationError Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> StakePoolMetadataValidationError -> ShowS # | |
| Error StakePoolMetadataValidationError Source # | |
Defined in Cardano.Api.Typed Methods displayError :: StakePoolMetadataValidationError -> String Source # | |
Scripts
Both PaymentCredentials and StakeCredentials can use scripts.
Shelley supports multi-signatures via scripts.
Constructors
| Script (Script StandardShelley) |
Instances
| Eq Script Source # | |
| Ord Script Source # | |
| Show Script Source # | |
| ToCBOR Script Source # | |
| HasTextEnvelope Script Source # | |
Defined in Cardano.Api.Typed Methods textEnvelopeType :: AsType Script -> TextEnvelopeType Source # textEnvelopeDefaultDescr :: Script -> TextEnvelopeDescr Source # | |
| SerialiseAsCBOR Script Source # | |
Defined in Cardano.Api.Typed Methods serialiseToCBOR :: Script -> ByteString Source # deserialiseFromCBOR :: AsType Script -> ByteString -> Either DecoderError Script Source # | |
| HasTypeProxy Script Source # | |
| Eq (Hash Script) Source # | |
| Ord (Hash Script) Source # | |
Defined in Cardano.Api.Typed | |
| Show (Hash Script) Source # | |
| SerialiseAsRawBytes (Hash Script) Source # | |
Defined in Cardano.Api.Typed Methods serialiseToRawBytes :: Hash Script -> ByteString Source # deserialiseFromRawBytes :: AsType (Hash Script) -> ByteString -> Maybe (Hash Script) Source # | |
| newtype Hash Script Source # | |
Defined in Cardano.Api.Typed | |
| data AsType Script Source # | |
Defined in Cardano.Api.Typed | |
parseScript :: Value -> Parser MultiSigScript Source #
Script addresses
Making addresses from scripts.
Multi-signature scripts
Making multi-signature scripts.
data MultiSigScript Source #
Constructors
| RequireSignature (Hash PaymentKey) | |
| RequireAllOf [MultiSigScript] | |
| RequireAnyOf [MultiSigScript] | |
| RequireMOf Int [MultiSigScript] |
Instances
| Eq MultiSigScript Source # | |
Defined in Cardano.Api.Typed Methods (==) :: MultiSigScript -> MultiSigScript -> Bool # (/=) :: MultiSigScript -> MultiSigScript -> Bool # | |
| Show MultiSigScript Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> MultiSigScript -> ShowS # show :: MultiSigScript -> String # showList :: [MultiSigScript] -> ShowS # | |
| ToJSON MultiSigScript Source # | |
Defined in Cardano.Api.Typed Methods toJSON :: MultiSigScript -> Value Source # toEncoding :: MultiSigScript -> Encoding Source # toJSONList :: [MultiSigScript] -> Value Source # toEncodingList :: [MultiSigScript] -> Encoding Source # | |
| FromJSON MultiSigScript Source # | |
Defined in Cardano.Api.Typed Methods parseJSON :: Value -> Parser MultiSigScript Source # parseJSONList :: Value -> Parser [MultiSigScript] Source # | |
Serialisation
Support for serialising data in JSON, CBOR and text files.
CBOR
class HasTypeProxy a => SerialiseAsCBOR a Source #
Instances
class Typeable a => ToCBOR a Source #
Minimal complete definition
Instances
class Typeable a => FromCBOR a Source #
Minimal complete definition
Instances
serialiseToCBOR :: SerialiseAsCBOR a => a -> ByteString Source #
deserialiseFromCBOR :: SerialiseAsCBOR a => AsType a -> ByteString -> Either DecoderError a Source #
JSON
A type that can be converted to JSON.
Instances in general must specify toJSON and should (but don't need
to) specify toEncoding.
An example type and instance:
-- Allow ourselves to writeTextliterals. {-# LANGUAGE OverloadedStrings #-} data Coord = Coord { x :: Double, y :: Double } instanceToJSONCoord wheretoJSON(Coord x y) =object["x".=x, "y".=y]toEncoding(Coord x y) =pairs("x".=x<>"y".=y)
Instead of manually writing your ToJSON instance, there are two options
to do it automatically:
- Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
- The compiler can provide a default generic implementation for
toJSON.
To use the second, simply add a deriving clause to your
datatype and declare a GenericToJSON instance. If you require nothing other than
defaultOptions, it is sufficient to write (and this is the only
alternative where the default toJSON implementation is sufficient):
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics
data Coord = Coord { x :: Double, y :: Double } deriving Generic
instance ToJSON Coord where
toEncoding = genericToEncoding defaultOptions
If on the other hand you wish to customize the generic decoding, you have to implement both methods:
customOptions =defaultOptions{fieldLabelModifier=maptoUpper} instanceToJSONCoord wheretoJSON=genericToJSONcustomOptionstoEncoding=genericToEncodingcustomOptions
Previous versions of this library only had the toJSON method. Adding
toEncoding had two reasons:
- toEncoding is more efficient for the common case that the output of
toJSONis directly serialized to aByteString. Further, expressing either method in terms of the other would be non-optimal. - The choice of defaults allows a smooth transition for existing users:
Existing instances that do not define
toEncodingstill compile and have the correct semantics. This is ensured by making the default implementation oftoEncodingusetoJSON. This produces correct results, but since it performs an intermediate conversion to aValue, it will be less efficient than directly emitting anEncoding. (this also means that specifying nothing more thaninstance ToJSON Coordwould be sufficient as a generically decoding instance, but there probably exists no good reason to not specifytoEncodingin new instances.)
Instances
A type that can be converted from JSON, with the possibility of failure.
In many cases, you can get the compiler to generate parsing code for you (see below). To begin, let's cover writing an instance by hand.
There are various reasons a conversion could fail. For example, an
Object could be missing a required key, an Array could be of
the wrong size, or a value could be of an incompatible type.
The basic ways to signal a failed conversion are as follows:
failyields a custom error message: it is the recommended way of reporting a failure;empty(ormzero) is uninformative: use it when the error is meant to be caught by some(;<|>)typeMismatchcan be used to report a failure when the encountered value is not of the expected JSON type;unexpectedis an appropriate alternative when more than one type may be expected, or to keep the expected type implicit.
prependFailure (or modifyFailure) add more information to a parser's
error messages.
An example type and instance using typeMismatch and prependFailure:
-- Allow ourselves to writeTextliterals. {-# LANGUAGE OverloadedStrings #-} data Coord = Coord { x :: Double, y :: Double } instanceFromJSONCoord whereparseJSON(Objectv) = Coord<$>v.:"x"<*>v.:"y" -- We do not expect a non-Objectvalue here. -- We could useemptyto fail, buttypeMismatch-- gives a much more informative error message.parseJSONinvalid =prependFailure"parsing Coord failed, " (typeMismatch"Object" invalid)
For this common case of only being concerned with a single
type of JSON value, the functions withObject, withScientific, etc.
are provided. Their use is to be preferred when possible, since
they are more terse. Using withObject, we can rewrite the above instance
(assuming the same language extension and data type) as:
instanceFromJSONCoord whereparseJSON=withObject"Coord" $ \v -> Coord<$>v.:"x"<*>v.:"y"
Instead of manually writing your FromJSON instance, there are two options
to do it automatically:
- Data.Aeson.TH provides Template Haskell functions which will derive an instance at compile time. The generated instance is optimized for your type so it will probably be more efficient than the following option.
- The compiler can provide a default generic implementation for
parseJSON.
To use the second, simply add a deriving clause to your
datatype and declare a GenericFromJSON instance for your datatype without giving
a definition for parseJSON.
For example, the previous example can be simplified to just:
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics
data Coord = Coord { x :: Double, y :: Double } deriving Generic
instance FromJSON Coord
The default implementation will be equivalent to
parseJSON = ; if you need different
options, you can customize the generic decoding by defining:genericParseJSON defaultOptions
customOptions =defaultOptions{fieldLabelModifier=maptoUpper} instanceFromJSONCoord whereparseJSON=genericParseJSONcustomOptions
Instances
serialiseToJSON :: ToJSON a => a -> ByteString Source #
deserialiseFromJSON :: FromJSON a => AsType a -> ByteString -> Either JsonDecodeError a Source #
Bech32
class (HasTypeProxy a, SerialiseAsRawBytes a) => SerialiseAsBech32 a Source #
Minimal complete definition
bech32PrefixFor, bech32PrefixesPermitted
Instances
serialiseToBech32 :: SerialiseAsBech32 a => a -> Text Source #
deserialiseFromBech32 :: SerialiseAsBech32 a => AsType a -> Text -> Either Bech32DecodeError a Source #
deserialiseAnyOfFromBech32 :: forall b. [FromSomeType SerialiseAsBech32 b] -> Text -> Either Bech32DecodeError b Source #
data Bech32DecodeError Source #
Bech32 decoding error.
Constructors
| Bech32DecodingError !DecodingError | There was an error decoding the string as Bech32. |
| Bech32UnexpectedPrefix !Text !(Set Text) | The human-readable prefix in the Bech32-encoded string is not one of the ones expected. |
| Bech32DataPartToBytesError !Text | There was an error in extracting a |
| Bech32DeserialiseFromBytesError !ByteString | There was an error in deserialising the bytes into a value of the expected type. |
| Bech32WrongPrefix !Text !Text | The human-readable prefix in the Bech32-encoded string does not correspond to the prefix that should be used for the payload value. |
Instances
| Eq Bech32DecodeError Source # | |
Defined in Cardano.Api.Typed Methods (==) :: Bech32DecodeError -> Bech32DecodeError -> Bool # (/=) :: Bech32DecodeError -> Bech32DecodeError -> Bool # | |
| Show Bech32DecodeError Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> Bech32DecodeError -> ShowS # show :: Bech32DecodeError -> String # showList :: [Bech32DecodeError] -> ShowS # | |
| Error Bech32DecodeError Source # | |
Defined in Cardano.Api.Typed Methods | |
Addresses
Address serialisation is (sadly) special
class HasTypeProxy addr => SerialiseAddress addr Source #
Address serialisation uses different serialisation formats for different kinds of addresses, so it needs its own class.
In particular, Byron addresses are typically formatted in base 58, while Shelley addresses (payment and stake) are formatted using Bech32.
Minimal complete definition
Instances
| SerialiseAddress StakeAddress Source # | |
Defined in Cardano.Api.Typed Methods serialiseAddress :: StakeAddress -> Text Source # deserialiseAddress :: AsType StakeAddress -> Text -> Maybe StakeAddress Source # | |
| SerialiseAddress (Address Shelley) Source # | |
| SerialiseAddress (Address Byron) Source # | |
serialiseAddress :: SerialiseAddress addr => addr -> Text Source #
deserialiseAddress :: SerialiseAddress addr => AsType addr -> Text -> Maybe addr Source #
Raw binary
Some types have a natural raw binary format.
class HasTypeProxy a => SerialiseAsRawBytes a Source #
Minimal complete definition
Instances
serialiseToRawBytes :: SerialiseAsRawBytes a => a -> ByteString Source #
deserialiseFromRawBytes :: SerialiseAsRawBytes a => AsType a -> ByteString -> Maybe a Source #
serialiseToRawBytesHex :: SerialiseAsRawBytes a => a -> ByteString Source #
deserialiseFromRawBytesHex :: SerialiseAsRawBytes a => AsType a -> ByteString -> Maybe a Source #
Text envelope
Support for a envelope file format with text headers and a hex-encoded binary payload.
class SerialiseAsCBOR a => HasTextEnvelope a where Source #
Minimal complete definition
Methods
textEnvelopeType :: AsType a -> TextEnvelopeType Source #
Instances
type TextEnvelope = TextView Source #
type TextEnvelopeType = TextViewType Source #
type TextEnvelopeError = TextViewError Source #
serialiseToTextEnvelope :: forall a. HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> TextEnvelope Source #
deserialiseFromTextEnvelope :: HasTextEnvelope a => AsType a -> TextEnvelope -> Either TextEnvelopeError a Source #
readFileTextEnvelope :: HasTextEnvelope a => AsType a -> FilePath -> IO (Either (FileError TextEnvelopeError) a) Source #
writeFileTextEnvelope :: HasTextEnvelope a => FilePath -> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ()) Source #
readTextEnvelopeFromFile :: FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope) Source #
readTextEnvelopeOfTypeFromFile :: TextEnvelopeType -> FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope) Source #
Reading one of several key types
data FromSomeType (c :: Type -> Constraint) b where Source #
Constructors
| FromSomeType :: c a => AsType a -> (a -> b) -> FromSomeType c b |
deserialiseFromTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> TextEnvelope -> Either TextEnvelopeError b Source #
readFileTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> FilePath -> IO (Either (FileError TextEnvelopeError) b) Source #
Errors
class Show e => Error e where Source #
Methods
displayError :: e -> String Source #
Instances
| Error () Source # | |
Defined in Cardano.Api.Typed Methods displayError :: () -> String Source # | |
| Error TextViewError Source # | |
Defined in Cardano.Api.Typed Methods displayError :: TextViewError -> String Source # | |
| Error Bech32DecodeError Source # | |
Defined in Cardano.Api.Typed Methods | |
| Error OperationalCertIssueError Source # | |
Defined in Cardano.Api.Typed Methods displayError :: OperationalCertIssueError -> String Source # | |
| Error StakePoolMetadataValidationError Source # | |
Defined in Cardano.Api.Typed Methods displayError :: StakePoolMetadataValidationError -> String Source # | |
| Error TxMetadataJsonSchemaError Source # | |
Defined in Cardano.Api.MetaData Methods displayError :: TxMetadataJsonSchemaError -> String Source # | |
| Error TxMetadataJsonError Source # | |
Defined in Cardano.Api.MetaData Methods | |
| Error TxMetadataRangeError Source # | |
Defined in Cardano.Api.MetaData Methods | |
| Error e => Error (FileError e) Source # | |
Defined in Cardano.Api.Typed Methods displayError :: FileError e -> String Source # | |
throwErrorAsException :: Error e => e -> IO a Source #
The preferred approach is to use Except or ExceptT, but you can if
necessary use IO exceptions.
Constructors
| FileError FilePath e | |
| FileIOError FilePath IOException |
Node interaction
Operations that involve talking to a local Cardano node.
Queries
Submitting transactions
Low level protocol interaction with a Cardano node
connectToLocalNode :: forall mode block. (ShowProxy block, ShowProxy (ApplyTxErr block), ShowProxy (Query block), ShowProxy (GenTx block), ShowQuery (Query block)) => LocalNodeConnectInfo mode block -> LocalNodeClientProtocols block -> IO () Source #
Establish a connection to a node and execute the given set of protocol handlers.
data LocalNodeConnectInfo mode block Source #
Constructors
| LocalNodeConnectInfo | |
Fields
| |
Instances
| Show (TxSubmitResultForMode ByronMode) Source # | |
Defined in Cardano.Api.TxSubmit | |
data ShelleyMode Source #
Instances
| Show (TxSubmitResultForMode ShelleyMode) Source # | |
Defined in Cardano.Api.TxSubmit Methods showsPrec :: Int -> TxSubmitResultForMode ShelleyMode -> ShowS # show :: TxSubmitResultForMode ShelleyMode -> String # showList :: [TxSubmitResultForMode ShelleyMode] -> ShowS # | |
data CardanoMode Source #
Instances
| Show (TxSubmitResultForMode CardanoMode) Source # | |
Defined in Cardano.Api.TxSubmit Methods showsPrec :: Int -> TxSubmitResultForMode CardanoMode -> ShowS # show :: TxSubmitResultForMode CardanoMode -> String # showList :: [TxSubmitResultForMode CardanoMode] -> ShowS # | |
data NodeConsensusMode mode block where Source #
data LocalNodeClientProtocols block Source #
Constructors
| LocalNodeClientProtocols | |
Fields
| |
withNodeProtocolClient :: NodeConsensusMode mode block -> ((SerialiseNodeToClientConstraints block, SupportedNetworkProtocolVersion block) => ProtocolClient block (BlockProtocol block) -> a) -> a Source #
Chain sync protocol
newtype ChainSyncClient header point tip (m :: Type -> Type) a #
Constructors
| ChainSyncClient | |
Fields
| |
Local tx submission
newtype LocalTxSubmissionClient tx reject (m :: Type -> Type) a #
Constructors
| LocalTxSubmissionClient | |
Fields
| |
submitTxToNodeLocal :: forall mode block. (ShowProxy block, ShowProxy (ApplyTxErr block), ShowProxy (Query block), ShowProxy (GenTx block), ShowQuery (Query block)) => LocalNodeConnectInfo mode block -> GenTx block -> IO (SubmitResult (ApplyTxErr block)) Source #
Local state query
newtype LocalStateQueryClient block point (query :: Type -> Type) (m :: Type -> Type) a #
Constructors
| LocalStateQueryClient | |
Fields
| |
queryNodeLocalState :: forall mode block result. (ShowProxy block, ShowProxy (ApplyTxErr block), ShowProxy (Query block), ShowProxy (GenTx block), ShowQuery (Query block)) => LocalNodeConnectInfo mode block -> (Point block, Query block result) -> IO (Either AcquireFailure result) Source #
Establish a connection to a node and execute a single query using the local state query protocol.
Node operation
Support for the steps needed to operate a node, including the operator's offline keys, operational KES and VRF keys, and operational certificates.
Stake pool operator's keys
data StakePoolKey Source #
Instances
type PoolId = Hash StakePoolKey Source #
KES keys
Instances
VRF keys
Instances
Operational certificates
data OperationalCertificate Source #
Constructors
| OperationalCertificate !(OCert StandardCrypto) !(VerificationKey StakePoolKey) |
Instances
data OperationalCertificateIssueCounter Source #
Constructors
| OperationalCertificateIssueCounter !Word64 !(VerificationKey StakePoolKey) |
Instances
| Eq OperationalCertificateIssueCounter Source # | |
Defined in Cardano.Api.Typed | |
| Show OperationalCertificateIssueCounter Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> OperationalCertificateIssueCounter -> ShowS # | |
| ToCBOR OperationalCertificateIssueCounter Source # | |
Defined in Cardano.Api.Typed Methods toCBOR :: OperationalCertificateIssueCounter -> Encoding Source # encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy OperationalCertificateIssueCounter -> Size Source # encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [OperationalCertificateIssueCounter] -> Size Source # | |
| FromCBOR OperationalCertificateIssueCounter Source # | |
Defined in Cardano.Api.Typed | |
| HasTextEnvelope OperationalCertificateIssueCounter Source # | |
| SerialiseAsCBOR OperationalCertificateIssueCounter Source # | |
| HasTypeProxy OperationalCertificateIssueCounter Source # | |
Defined in Cardano.Api.Typed Associated Types | |
| data AsType OperationalCertificateIssueCounter Source # | |
Constructors
| KESPeriod | |
Fields
| |
Instances
| Eq KESPeriod | |
| Ord KESPeriod | |
| Show KESPeriod | |
| Generic KESPeriod | |
| ToCBOR KESPeriod | |
| FromCBOR KESPeriod | |
| NoThunks KESPeriod | |
| type Rep KESPeriod | |
Defined in Shelley.Spec.Ledger.OCert | |
data OperationalCertIssueError Source #
Constructors
| OperationalCertKeyMismatch (VerificationKey StakePoolKey) (VerificationKey StakePoolKey) | The stake pool verification key expected for the
Order: pool vkey expected, pool skey supplied |
Instances
| Show OperationalCertIssueError Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> OperationalCertIssueError -> ShowS # show :: OperationalCertIssueError -> String # showList :: [OperationalCertIssueError] -> ShowS # | |
| Error OperationalCertIssueError Source # | |
Defined in Cardano.Api.Typed Methods displayError :: OperationalCertIssueError -> String Source # | |
issueOperationalCertificate :: VerificationKey KesKey -> Either (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey) -> KESPeriod -> OperationalCertificateIssueCounter -> Either OperationalCertIssueError (OperationalCertificate, OperationalCertificateIssueCounter) Source #
Genesis file
Types and functions needed to inspect or create a genesis file.
data GenesisKey Source #
Instances
data GenesisExtendedKey Source #
Shelley-era genesis keys using extended ed25519 cryptographic keys.
These serve the same role as normal genesis keys, but are here to support legacy Byron genesis keys which used extended keys.
The extended verification keys can be converted (via castVerificationKey)
to ordinary keys (i.e. VerificationKey GenesisKey) but this is not the
case for the signing keys. The signing keys can be used to witness
transactions directly, with verification via their non-extended verification
key (VerificationKey GenesisKey).
This is a type level tag, used with other interfaces like Key.
Instances
data GenesisDelegateKey Source #
Instances
data GenesisDelegateExtendedKey Source #
Shelley-era genesis keys using extended ed25519 cryptographic keys.
These serve the same role as normal genesis keys, but are here to support legacy Byron genesis keys which used extended keys.
The extended verification keys can be converted (via castVerificationKey)
to ordinary keys (i.e. VerificationKey GenesisKey) but this is not the
case for the signing keys. The signing keys can be used to witness
transactions directly, with verification via their non-extended verification
key (VerificationKey GenesisKey).
This is a type level tag, used with other interfaces like Key.
Instances
data GenesisUTxOKey Source #
Instances
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.
Special transactions
There are various additional things that can be embedded in a transaction for special operations.
makeMIRCertificate :: MIRPot -> [(StakeCredential, Lovelace)] -> Certificate Source #
makeGenesisKeyDelegationCertificate :: Hash GenesisKey -> Hash GenesisDelegateKey -> Hash VrfKey -> Certificate Source #
Protocol parameter updates
newtype UpdateProposal Source #
Constructors
| UpdateProposal (Update StandardShelley) |
Instances
data ProtocolParametersUpdate Source #
Constructors
| ProtocolParametersUpdate | |
Fields
| |
Instances
| Eq ProtocolParametersUpdate Source # | |
Defined in Cardano.Api.Typed Methods (==) :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool # (/=) :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool # | |
| Show ProtocolParametersUpdate Source # | |
Defined in Cardano.Api.Typed Methods showsPrec :: Int -> ProtocolParametersUpdate -> ShowS # show :: ProtocolParametersUpdate -> String # showList :: [ProtocolParametersUpdate] -> ShowS # | |
| Semigroup ProtocolParametersUpdate Source # | |
Defined in Cardano.Api.Typed | |
| Monoid ProtocolParametersUpdate Source # | |
Defined in Cardano.Api.Typed | |
An epoch, i.e. the number of the epoch.
Instances
| Enum EpochNo | |
| Eq EpochNo | |
| Num EpochNo | |
| Ord EpochNo | |
Defined in Cardano.Slotting.Slot | |
| Show EpochNo | |
| Generic EpochNo | |
| ToJSON EpochNo | |
| FromJSON EpochNo | |
| ToCBOR EpochNo | |
| FromCBOR EpochNo | |
| NoThunks EpochNo | |
| Serialise EpochNo | |
| Condense EpochNo | |
| type Rep EpochNo | |
Defined in Cardano.Slotting.Slot | |
newtype NetworkMagic #
Constructors
| NetworkMagic | |
Fields | |
Instances
| Eq NetworkMagic | |
Defined in Ouroboros.Network.Magic | |
| Show NetworkMagic | |
Defined in Ouroboros.Network.Magic Methods showsPrec :: Int -> NetworkMagic -> ShowS # show :: NetworkMagic -> String # showList :: [NetworkMagic] -> ShowS # | |
| Generic NetworkMagic | |
Defined in Ouroboros.Network.Magic Associated Types type Rep NetworkMagic :: Type -> Type # | |
| NoThunks NetworkMagic | |
Defined in Ouroboros.Network.Magic | |
| type Rep NetworkMagic | |
Defined in Ouroboros.Network.Magic type Rep NetworkMagic = D1 ('MetaData "NetworkMagic" "Ouroboros.Network.Magic" "ouroboros-network-0.1.0.0-DgIBwCUrGXaLitNwqCfIcM" 'True) (C1 ('MetaCons "NetworkMagic" 'PrefixI 'True) (S1 ('MetaSel ('Just "unNetworkMagic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32))) | |
makeShelleyUpdateProposal :: ProtocolParametersUpdate -> [Hash GenesisKey] -> EpochNo -> UpdateProposal Source #
Conversions
toByronTxIn :: TxIn -> TxIn Source #
toByronTxId :: TxId -> TxId Source #
toShelleyNetwork :: NetworkId -> Network Source #
An address for UTxO.
Constructors
| Addr Network (PaymentCredential era) (StakeReference era) | |
| AddrBootstrap (BootstrapAddress era) |
Instances
The amount of value held by a transaction output.
Instances
Constructors
| EpochSize | |
Fields | |
Instances
data GenDelegPair crypto Source #
Constructors
| GenDelegPair | |
Fields
| |
Instances
The role of a key.
Note that a role is not _fixed_, nor is it unique. In particular, keys may
variously be used as witnesses, and so in many case we will change the role
of a key to the Witness role.
It is also perfectly allowable for a key to be used in many roles; there is nothing prohibiting somebody using the same underlying key as their payment and staking key, as well as the key for their stake pool. So these roles are more intended for two purposes:
- To make explicit how we are using a key in the specifications
- To provide a guide to downstream implementors, for whom the profusion of keys may be confusing.
Constructors
| Genesis | |
| GenesisDelegate | |
| Payment | |
| Staking | |
| StakePool | |
| BlockIssuer | |
| Witness |
newtype KeyHash (discriminator :: KeyRole) crypto Source #
Discriminated hash of public Key
Constructors
| KeyHash (Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))) |
Instances
| HasKeyRole KeyHash | |
Defined in Shelley.Spec.Ledger.Keys | |
| Embed (PoolDistr crypto) (Map (KeyHash 'StakePool crypto) (IndividualPoolStake crypto)) | |
| HasExp (PoolDistr crypto) (Map (KeyHash 'StakePool crypto) (IndividualPoolStake crypto)) | |
Defined in Shelley.Spec.Ledger.Delegation.Certificates | |
| Eq (KeyHash discriminator crypto) | |
| Ord (KeyHash discriminator crypto) | |
Defined in Shelley.Spec.Ledger.Keys Methods compare :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Ordering # (<) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool # (<=) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool # (>) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool # (>=) :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> Bool # max :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> KeyHash discriminator crypto # min :: KeyHash discriminator crypto -> KeyHash discriminator crypto -> KeyHash discriminator crypto # | |
| Show (KeyHash discriminator crypto) | |
| Generic (KeyHash discriminator crypto) | |
| NFData (KeyHash discriminator crypto) | |
Defined in Shelley.Spec.Ledger.Keys | |
| ToJSON (KeyHash disc crypto) | |
| ToJSONKey (KeyHash disc crypto) | |
Defined in Shelley.Spec.Ledger.Keys Methods toJSONKey :: ToJSONKeyFunction (KeyHash disc crypto) Source # toJSONKeyList :: ToJSONKeyFunction [KeyHash disc crypto] Source # | |
| Crypto crypto => FromJSON (KeyHash disc crypto) | |
| Crypto crypto => FromJSONKey (KeyHash disc crypto) | |
Defined in Shelley.Spec.Ledger.Keys Methods fromJSONKey :: FromJSONKeyFunction (KeyHash disc crypto) Source # fromJSONKeyList :: FromJSONKeyFunction [KeyHash disc crypto] Source # | |
| (Crypto crypto, Typeable disc) => ToCBOR (KeyHash disc crypto) | |
Defined in Shelley.Spec.Ledger.Keys | |
| (Crypto crypto, Typeable disc) => FromCBOR (KeyHash disc crypto) | |
| NoThunks (KeyHash discriminator crypto) | |
| type Rep (KeyHash discriminator crypto) | |
Defined in Shelley.Spec.Ledger.Keys | |
data PParams' (f :: Type -> Type) era Source #
Protocol parameters.
We use the HKD type family so that the protocol parameters type and
the type for the updates to the protocol parameters can share records fields.
The protocol parameters will have type PParams' Identity, and the updates
will have type PParams' StrictMaybe, though Identity will be hidden from use.
For example:
myParameters =
PParams
{ _minfeeA = 0,
_minfeeB = 0,
...
}
myUpdate =
PParamsUpdate
{ _minfeeA = SNothing,
_minfeeB = SJust 42,
...
}
Constructors
| PParams | |
Fields
| |
Instances
type PParamsUpdate era = PParams' StrictMaybe era Source #
type StandardShelley = ShelleyEra StandardCrypto Source #
The Shelley era with standard crypto
emptyPParams :: PParams era Source #
Returns a basic "empty" PParams structure with all zero values.
truncateUnitInterval :: Ratio Word64 -> UnitInterval Source #
Convert a rational to a UnitInterval by ignoring its integer part.
emptyGenesisStaking :: ShelleyGenesisStaking era Source #
Empty genesis staking