Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides a convenient way to spread assets between wallets and scripts at the initialization of the mock chain. These initial assets can be accompanied by datums, staking credentials and reference scripts.
Synopsis
- data InitialDistribution where
- InitialDistribution :: {..} -> InitialDistribution
- distributionFromList :: [(Wallet, [Value])] -> InitialDistribution
- toInitDistWithMinAda :: InitialDistribution -> Either GenerateTxError InitialDistribution
- unsafeToInitDistWithMinAda :: InitialDistribution -> InitialDistribution
Documentation
data InitialDistribution where Source #
Describes the initial distribution of UTxOs per wallet. This is important
since transaction validation must specify a collateral. Hence, wallets must
have more than one UTxO to begin with in order to execute a transaction and
have some collateral option. The txCollateral
is transferred to the node
operator in case the transaction fails to validate.
The following specifies a starting state where wallet 1
owns two UTxOs,
one with 42 Ada and one with 2 Ada and one TOK token; wallet 2
owns a
single UTxO with 10 Ada and wallet 3
has 10 Ada and a permanent value. See
Cooked.Currencies for more information on quick and permanent values.
i0 = distributionFromList $ [ (wallet 1 , [ ada 42 , ada 2 <> quickValue "TOK" 1 ] , (wallet 2 , [ ada 10 ]) , (wallet 3 , [ ada 10 <> permanentValue "XYZ" 10]) ]
Note that initial distribution can lead to payments that would not be accepted if part of an actual transaction, such as payment without enough ada to sustain themselves.
InitialDistribution | |
|
Instances
Monoid InitialDistribution Source # | |
Defined in Cooked.InitialDistribution | |
Semigroup InitialDistribution Source # | |
Defined in Cooked.InitialDistribution (<>) :: InitialDistribution -> InitialDistribution -> InitialDistribution # sconcat :: NonEmpty InitialDistribution -> InitialDistribution # stimes :: Integral b => b -> InitialDistribution -> InitialDistribution # | |
Default InitialDistribution Source # | 5 UTxOs with 100 Ada each, for each of the |
Defined in Cooked.InitialDistribution |
distributionFromList :: [(Wallet, [Value])] -> InitialDistribution Source #
Creating a initial distribution with simple values assigned to wallets
toInitDistWithMinAda :: InitialDistribution -> Either GenerateTxError InitialDistribution Source #
Transforms a given initial distribution by ensuring each payment has enough ada so that the resulting outputs can sustain themselves. This can fail if any of the payments cannot be translated to their Cardano counterpart.
unsafeToInitDistWithMinAda :: InitialDistribution -> InitialDistribution Source #
Unsafe variant of toInitDistWithMinAda