Skip to content

Instantly share code, notes, and snippets.

@ngoluuduythai
Last active March 24, 2021 04:23
Show Gist options
  • Save ngoluuduythai/a041f54e88754f300134425921326e8c to your computer and use it in GitHub Desktop.
Save ngoluuduythai/a041f54e88754f300134425921326e8c to your computer and use it in GitHub Desktop.
Plutus Playground Smart Contract
import qualified Data.Text as T
import Language.Plutus.Contract hiding (when)
import Language.PlutusTx.Prelude
import Playground.Contract
-- | A 'Contract' that logs a message.
-- public Contract<BlockchainActions, T.Text, void) hello(){
-- return logInfo(@string "Hello, world");
-- }
-- T.Text is error
-- BlockchainActions or schema contains effects as producing transactions, collecting
-- inputs from users, and watching the blockchain for chanegs
-- type BlockchainActions =
-- AwaitSlot
-- .\/ WatchAddress
-- .\/ WriteTx
-- .\/ UtxoAt
-- .\/ OwnPubKey
-- .\/ TxConfirmation
-- .\/ ContractInstanceNotify
-- .\/ OwnId
-- CustomBlockChainActions
hello :: Contract BlockchainActions T.Text ()
hello = logInfo @String "Hello, world"
-- | Log a message at the 'Info' level
-- logInfo :: ToJSON a => a -> Contract w s e ()
-- logInfo = Contract . L.logInfo . toJSON
-- . => f(g(x)) Contract(L.logInfo(a.toJSON)))
-- | endpoints talk plutus what to show in the ui
endpoints :: Contract BlockchainActions T.Text ()
endpoints = hello
-- What schema we using
mkSchemaDefinitions ''BlockchainActions
-- use for plutus scripts
$(mkKnownCurrencies [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment