Closed Luis-omega closed 2 years ago
After a process of elimination, if someone wants to use Aeson to parse the Ogmios JSON, can almost do it with the following instance
instance FromJSON ProtocolParametersWrapper where
parseJSON =
Aeson.withObject "ProtocolParametersWrapper" $ \top -> do
o :: Aeson.Object <- top .: "result"
v <- o .: "protocolVersion"
params <-
Shelley.ProtocolParameters
<$> ((,) <$> v .: "major" <*> v .: "minor")
<*> o .: "decentralizationParameter"
<*> o .: "extraEntropy"
<*> o .: "maxBlockHeaderSize"
<*> o .: "maxBlockBodySize"
<*> o .: "maxTxSize"
<*> o .: "minFeeConstant"
<*> o .: "minFeeCoefficient"
<*> o .: "minUTxOValue" -- Don't know the corresponding value
<*> o .: "stakeKeyDeposit"
<*> o .: "poolDeposit"
<*> o .: "minPoolCost"
<*> o .: "poolRetirementEpochBound"
<*> o .: "desiredNumberOfPools"
<*> o .: "poolInfluence"
<*> o .: "monetaryExpansion"
<*> o .: "treasuryExpansion"
<*> o .:? "coinsPerUTxOWord"
<*> o .:? "costModels" .!= Map.empty -- Ogmios use `plutus:v1` instead of the cardanos `PlutusScriptV1`
-- so, this must need further work.
<*> o .:? "prices"
<*> o .:? "maxExecutionUnitsPerTransaction"
<*> o .:? "maxExecutionUnitsPerBlock"
<*> o .:? "maxValueSize"
<*> o .:? "collateralPercentage"
<*> o .:? "maxCollateralInputs"
return $ ProtocolParametersWrapper params
I still don't know the corresponding minUTxOValue
parameter.
Hey! Thanks for reaching out and let me clarify a few things. The protocol parameters regards the Cardano network. The cardano-cli / cardano-api are respectively a command-line interface and a Haskell library that are using some (JSON) representation of those parameters. Ogmios offers a different representation of the same network parameters. Why is that? Mainly because the pieces of software were developed in isolation with slightly different design decisions; they now offer two different flavors. Yet, the same information is available on both side because they ultimately stem from the on-chain binary representation of protocol parameters.
Having said that, know that there are actually 2 versions of the protocol parameters; one introduced with the Shelley era, and a revised one introduced with the Alonzo era. Depending on which era your node is when making the query, you'll get one or the other. In all likelihood, on a synchronized node on Mainnet, you'll get the Alonzo's version. In Alonzo, the minUTxOValue
is gone and was replaced by a coinsPerUTxOWord
(or utxoCostPerWord
in cardano-api
/ cardano-cli
). In addition, stakePoolTargetNum
is called desiredNumberOfPools
in Ogmios.
I hope this helps a bit.
Yes, this has helpme a lot, thanks!
Also, pretty much thanks for the work in Ogmios.
Hi, I'm trying to get the Cardano parameters using Ogmios but I found that the names in the response to
currentProtocolParameters
are different from the ones used by Cardano in itsfromJSON
instance for Aeson.This is the current Cardano
fromJSON
instance :and this is the current local server response :
Some of the parameters I don't know how to map are:
minUTxOValue
andstakePoolTargetNum
Thanks for your time.