Last active
July 10, 2019 23:07
-
-
Save ramanan12345/b5828b1692724c0eaffb20acb6ccae51 to your computer and use it in GitHub Desktop.
Plutus Playground Smart Contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Contract endpoints that generate different kinds of errors for the log: | |
| -- logAMessage produces a log message from a wallet | |
| -- submitInvalidTxn submits an invalid txn which should result in a | |
| -- "Validation failed" message throwWalletAPIError throws an error from | |
| -- a wallet (client) | |
| import Language.PlutusTx.Prelude | |
| import qualified Data.Map as Map | |
| import qualified Data.Set as Set | |
| import Data.Text (Text) | |
| import Ledger | |
| import qualified Ledger.Ada as Ada | |
| import Ledger.Validation | |
| import Playground.Contract | |
| import Wallet | |
| logAMessage :: MonadWallet m => m () | |
| logAMessage = logMsg "wallet log" | |
| submitInvalidTxn :: MonadWallet m => m () | |
| submitInvalidTxn = do | |
| logMsg "Preparing to submit an invalid transaction" | |
| let tx = Tx | |
| { txInputs = Set.empty | |
| , txOutputs = [] | |
| , txForge = Ada.adaValueOf 2 | |
| , txFee = 0 | |
| , txValidRange = defaultSlotRange | |
| , txSignatures = Map.empty | |
| } | |
| submitTxn tx | |
| throwWalletAPIError :: MonadWallet m => Text -> m () | |
| throwWalletAPIError = throwOtherError | |
| $(mkFunctions ['logAMessage, 'submitInvalidTxn, 'throwWalletAPIError]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [0,[{"wallets":[{"simulatorWalletWallet":{"getWallet":1},"simulatorWalletBalance":{"getValue":[[{"unCurrencySymbol":""},[[{"unTokenName":""},102]]]]}},{"simulatorWalletWallet":{"getWallet":2},"simulatorWalletBalance":{"getValue":[[{"unCurrencySymbol":""},[[{"unTokenName":""},90]]]]}}],"signatures":[{"functionName":"logAMessage","argumentSchema":[]},{"functionName":"submitInvalidTxn","argumentSchema":[]},{"functionName":"throwWalletAPIError","argumentSchema":[{"tag":"SimpleStringSchema"}]},{"functionName":"payToWallet_","argumentSchema":[{"contents":[["getValue",{"contents":[["unMap",{"contents":[{"tag":"SimpleHexSchema"},{"contents":[["unMap",{"contents":[{"tag":"SimpleStringSchema"},{"tag":"SimpleIntSchema"}],"tag":"SimpleArraySchema"}]],"tag":"SimpleObjectSchema"}],"tag":"SimpleArraySchema"}]],"tag":"SimpleObjectSchema"}]],"tag":"ValueSchema"},{"contents":[["getWallet",{"tag":"SimpleIntSchema"}]],"tag":"SimpleObjectSchema"}]}],"currencies":[{"knownTokens":[{"unTokenName":""}],"hash":"","friendlyName":"Ada"}],"actions":[{"simulatorWallet":{"simulatorWalletWallet":{"getWallet":1},"simulatorWalletBalance":{"getValue":[[{"unCurrencySymbol":""},[[{"unTokenName":""},102]]]]}},"functionSchema":{"functionName":"logAMessage","argumentSchema":[]},"tag":"Action"},{"simulatorWallet":{"simulatorWalletWallet":{"getWallet":1},"simulatorWalletBalance":{"getValue":[[{"unCurrencySymbol":""},[[{"unTokenName":""},102]]]]}},"functionSchema":{"functionName":"logAMessage","argumentSchema":[]},"tag":"Action"},{"blocks":12,"tag":"Wait"},{"blocks":10,"tag":"Wait"}]}]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment