You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During audits, some minting policies are not provided and it takes repetitive boilerplate code to specify them and then mint and distribute some assets among wallets before reaching the actual desired initial state where that currency is spread in the world alongside Ada.
For example this is a typical module to provide convenience functions regarding a currency that is supposed to already exist in the wild. We use a OneShotCurrency here because it is simple and we have an admin wallet mint everything and then distribute it among other wallets (this could be simplified and done in a single transaction without the "admin", it is just code taken from a recent audit where an admin actually exists).
adminCoin::Cooked.Wallet
adminCoin =Cooked.wallet 1adminCoinPKH::Plutus.PubKeyHash
adminCoinPKH =Cooked.walletPKHash adminCoin
coinTotalAmount::Integer
coinTotalAmount =100_000_000coinPolicy::Plutus.MintingPolicy
coinPolicy =Plutus.curPolicy Plutus.$Plutus.OneShotCurrency
(h, i)
(Plutus.fromList [("coin", coinTotalAmount)])
whereRight ((h, i), _) =Cooked.runMockChain $do-- TODO: make type safe
[(Plutus.TxOutRef h' i', _)] <-Cooked.pkUtxos' adminCoinPKH
return (h', i')
coinCurrency::Plutus.CurrencySymbol
coinCurrency =Plutus.scriptCurrencySymbol coinPolicy
coinAsset::Plutus.AssetClass
coinAsset =Plutus.assetClass coinCurrency "coin"coinGeneration:: (Cooked.MonadMockChainm) =>m()
coinGeneration =Cooked.validateTxFromSkeleton $Cooked.txSkel
adminCoin
[ Cooked.mints [coinPolicy] oneHundredMillionCoin,
Cooked.PaysPK adminCoinPKH oneHundredMillionCoin
]
where
oneHundredMillionCoin =Plutus.assetClassValue coinAsset 100_000_000coin::Integer->Plutus.Value
coin =Plutus.assetClassValue coinAsset
--| Distribute coins from admin to different pkh.coinDistribution::Cooked.MonadMockChainm=>--| Quantity of coin to give to each recipient
[(Plutus.PubKeyHash, Integer)] ->m()
coinDistribution =Cooked.validateTxFromSkeleton .Cooked.txSkel adminCoin .map pays
where
pays (recipientPKH, quantity) =PaysPK recipientPKH (coin quantity)
It would be nice to be able to quickly specify:
a name for the tokens
an initial distribution of these among the known wallets :: [(Wallet, Integer)]
And then be able to bootstrap a mockchain with the chosen initial distribution of freshly minted tokens and a set of helper functions mapping the chosen name to the token name, currency symbol, asset class, and value constructor.
The text was updated successfully, but these errors were encountered:
During audits, some minting policies are not provided and it takes repetitive boilerplate code to specify them and then mint and distribute some assets among wallets before reaching the actual desired initial state where that currency is spread in the world alongside Ada.
For example this is a typical module to provide convenience functions regarding a currency that is supposed to already exist in the wild. We use a OneShotCurrency here because it is simple and we have an admin wallet mint everything and then distribute it among other wallets (this could be simplified and done in a single transaction without the "admin", it is just code taken from a recent audit where an admin actually exists).
It would be nice to be able to quickly specify:
:: [(Wallet, Integer)]
And then be able to bootstrap a mockchain with the chosen initial distribution of freshly minted tokens and a set of helper functions mapping the chosen name to the token name, currency symbol, asset class, and value constructor.
The text was updated successfully, but these errors were encountered: