Safe Haskell | None |
---|---|
Language | Haskell2010 |
A basic cardano-node client that can talk to a local cardano-node.
The idea of this module is to provide a Haskell interface on top of cardano-cli's API, - using cardano-api types.
Synopsis
- type NodeSocket = FilePath
- buildAddress :: VerificationKey PaymentKey -> NetworkId -> Address ShelleyAddr
- buildScriptAddress :: Script PlutusScriptV1 -> NetworkId -> Address ShelleyAddr
- queryUtxo :: NetworkId -> FilePath -> [Address ShelleyAddr] -> IO (UTxO AlonzoEra)
- queryUtxoByTxIn :: NetworkId -> FilePath -> [TxIn] -> IO (UTxO AlonzoEra)
- txOutLovelace :: TxOut ctx era -> Lovelace
- queryProtocolParameters :: NetworkId -> FilePath -> IO ProtocolParameters
- queryStakePools :: NetworkId -> FilePath -> IO (Set PoolId)
- runQuery :: NetworkId -> FilePath -> QueryInMode CardanoMode (Either EraMismatch a) -> IO a
- localNodeConnectInfo :: NetworkId -> FilePath -> LocalNodeConnectInfo CardanoMode
- cardanoModeParams :: ConsensusModeParams CardanoMode
- queryTipSlotNo :: NetworkId -> FilePath -> IO SlotNo
- querySystemStart :: NetworkId -> FilePath -> IO SystemStart
- queryEraHistory :: NetworkId -> FilePath -> IO (EraHistory CardanoMode)
- buildRaw :: [TxIn] -> [TxOut CtxTx AlonzoEra] -> Lovelace -> Either TxBodyError (TxBody AlonzoEra)
- build :: NetworkId -> FilePath -> Address ShelleyAddr -> [(TxIn, Maybe (Script PlutusScriptV1, ScriptData, ScriptRedeemer))] -> [TxIn] -> [TxOut CtxTx AlonzoEra] -> IO (Either TxBodyErrorAutoBalance (TxBody AlonzoEra))
- calculateMinFee :: NetworkId -> TxBody AlonzoEra -> Sizes -> ProtocolParameters -> Lovelace
- data Sizes = Sizes {}
- defaultSizes :: Sizes
- sign :: SigningKey -> TxBody AlonzoEra -> Tx AlonzoEra
- submit :: NetworkId -> FilePath -> Tx AlonzoEra -> IO ()
- data CardanoClientException
- waitForPayment :: NetworkId -> FilePath -> Lovelace -> Address ShelleyAddr -> IO (UTxO AlonzoEra)
- waitForTransaction :: NetworkId -> FilePath -> CardanoTx -> IO (UTxO AlonzoEra)
- mkGenesisTx :: NetworkId -> ProtocolParameters -> Lovelace -> SigningKey PaymentKey -> VerificationKey PaymentKey -> Lovelace -> CardanoTx
- generatePaymentToCommit :: NetworkId -> RunningNode -> SigningKey -> VerificationKey -> Natural -> IO Utxo
Documentation
type NodeSocket = FilePath #
buildAddress :: VerificationKey PaymentKey -> NetworkId -> Address ShelleyAddr #
Build an address give a key.
From https://github.com/input-output-hk/cardano-node/blob/master/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs#L106 + using cardano-api types.
Synopsis
- type NodeSocket = FilePath
- buildAddress :: VerificationKey PaymentKey -> NetworkId -> Address ShelleyAddr
- buildScriptAddress :: Script PlutusScriptV1 -> NetworkId -> Address ShelleyAddr
- queryUtxo :: NetworkId -> FilePath -> [Address ShelleyAddr] -> IO (UTxO AlonzoEra)
- queryUtxoByTxIn :: NetworkId -> FilePath -> [TxIn] -> IO (UTxO AlonzoEra)
- txOutLovelace :: TxOut ctx era -> Lovelace
- queryProtocolParameters :: NetworkId -> FilePath -> IO ProtocolParameters
- queryStakePools :: NetworkId -> FilePath -> IO (Set PoolId)
- runQuery :: NetworkId -> FilePath -> QueryInMode CardanoMode (Either EraMismatch a) -> IO a
- localNodeConnectInfo :: NetworkId -> FilePath -> LocalNodeConnectInfo CardanoMode
- cardanoModeParams :: ConsensusModeParams CardanoMode
- queryTipSlotNo :: NetworkId -> FilePath -> IO SlotNo
- querySystemStart :: NetworkId -> FilePath -> IO SystemStart
- queryEraHistory :: NetworkId -> FilePath -> IO (EraHistory CardanoMode)
- buildRaw :: [TxIn] -> [TxOut CtxTx AlonzoEra] -> Lovelace -> Either TxBodyError (TxBody AlonzoEra)
- build :: NetworkId -> FilePath -> Address ShelleyAddr -> [(TxIn, Maybe (Script PlutusScriptV1, ScriptData, ScriptRedeemer))] -> [TxIn] -> [TxOut CtxTx AlonzoEra] -> IO (Either TxBodyErrorAutoBalance (TxBody AlonzoEra))
- calculateMinFee :: NetworkId -> TxBody AlonzoEra -> Sizes -> ProtocolParameters -> Lovelace
- data Sizes = Sizes {}
- defaultSizes :: Sizes
- sign :: SigningKey -> TxBody AlonzoEra -> Tx AlonzoEra
- submit :: NetworkId -> FilePath -> Tx AlonzoEra -> IO ()
- data CardanoClientException
- waitForPayment :: NetworkId -> FilePath -> Lovelace -> Address ShelleyAddr -> IO (UTxO AlonzoEra)
- waitForUtxo :: NetworkId -> FilePath -> Utxo -> IO ()
- waitForTransaction :: NetworkId -> FilePath -> CardanoTx -> IO (UTxO AlonzoEra)
- mkGenesisTx :: NetworkId -> ProtocolParameters -> Lovelace -> SigningKey PaymentKey -> VerificationKey PaymentKey -> Lovelace -> CardanoTx
- generatePaymentToCommit :: NetworkId -> RunningNode -> SigningKey -> VerificationKey -> Natural -> IO Utxo
Documentation
type NodeSocket = FilePath #
buildAddress :: VerificationKey PaymentKey -> NetworkId -> Address ShelleyAddr #
Build an address give a key.
From https://github.com/input-output-hk/cardano-node/blob/master/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs#L106
Throws CardanoClientException
if the query fails.
queryUtxo :: NetworkId -> FilePath -> [Address ShelleyAddr] -> IO (UTxO AlonzoEra) #
Query UTxO for all given addresses.
This query is specialised for Shelley addresses in Alonzo era.
Throws CardanoClientException
if query fails.
txOutLovelace :: TxOut ctx era -> Lovelace #
Extract ADA value from an output NOTE(AB): there is txOutValueToLovelace in more recent cardano-api versions which - serves same purpose
queryProtocolParameters :: NetworkId -> FilePath -> IO ProtocolParameters #
Query current protocol parameters.
Throws CardanoClientException
if query fails.
runQuery :: NetworkId -> FilePath -> QueryInMode CardanoMode (Either EraMismatch a) -> IO a #
querySystemStart :: NetworkId -> FilePath -> IO SystemStart #
queryEraHistory :: NetworkId -> FilePath -> IO (EraHistory CardanoMode) #
buildRaw :: [TxIn] -> [TxOut CtxTx AlonzoEra] -> Lovelace -> Either TxBodyError (TxBody AlonzoEra) #
Build a "raw" transaction from a bunch of inputs, outputs and fees.
build :: NetworkId -> FilePath -> Address ShelleyAddr -> [(TxIn, Maybe (Script PlutusScriptV1, ScriptData, ScriptRedeemer))] -> [TxIn] -> [TxOut CtxTx AlonzoEra] -> IO (Either TxBodyErrorAutoBalance (TxBody AlonzoEra)) #
defaultSizes :: Sizes #
sign :: SigningKey -> TxBody AlonzoEra -> Tx AlonzoEra #
Sign a transaction body with given signing key.
submit :: NetworkId -> FilePath -> Tx AlonzoEra -> IO () #
Submit a (signed) transaction to the node.
Throws CardanoClientException
if submission fails.
data CardanoClientException #
Instances
Show CardanoClientException # | |
Defined in CardanoClient showsPrec :: Int -> CardanoClientException -> ShowS show :: CardanoClientException -> String showList :: [CardanoClientException] -> ShowS | |
Exception CardanoClientException # | |
Defined in CardanoClient |
waitForPayment :: NetworkId -> FilePath -> Lovelace -> Address ShelleyAddr -> IO (UTxO AlonzoEra) #
:: NetworkId | |
-> ProtocolParameters | |
-> Lovelace | Amount of initialFunds |
-> SigningKey PaymentKey | Owner of the |
-> VerificationKey PaymentKey | Recipient of this transaction. |
-> Lovelace | Amount to pay |
-> CardanoTx |
generatePaymentToCommit :: NetworkId -> RunningNode -> SigningKey -> VerificationKey -> Natural -> IO Utxo #