Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shmish111
shmish111 / Playground.hs
Created March 4, 2021 16:43
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@shmish111
shmish111 / Playground.hs
Created March 4, 2021 16:05
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@shmish111
shmish111 / Playground.hs
Created March 4, 2021 15:42
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@shmish111
shmish111 / Playground.hs
Created March 4, 2021 14:09
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@shmish111
shmish111 / Playground.hs
Created March 2, 2021 16:25
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@shmish111
shmish111 / Playground.hs
Created February 13, 2021 19:51
Plutus Playground Smart Contract
-- Vesting scheme as a PLC contract
import Control.Monad (void, when)
import qualified Data.Map as Map
import qualified Data.Text as T
import Language.Plutus.Contract hiding (when)
import qualified Language.Plutus.Contract.Typed.Tx as Typed
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude hiding (Semigroup (..), fold)
import Ledger (Address, PubKeyHash, Slot (Slot), Validator, pubKeyHash)
@shmish111
shmish111 / Main.hs
Last active March 4, 2021 15:57
Untitled Project
{-# LANGUAGE OverloadedStrings #-}
module Escrow where
import Language.Marlowe
main :: IO ()
main = print . pretty $ contract
{- What does the vanilla contract look like?
@shmish111
shmish111 / Main.hs
Created January 27, 2021 16:17
Untitled Project
{-# LANGUAGE OverloadedStrings #-}
module Escrow where
import Language.Marlowe
main :: IO ()
main = print . pretty $ contract
{- What does the vanilla contract look like?
@shmish111
shmish111 / blockly.xml
Created January 12, 2021 16:47
Untitled Project
(When [(Case (Deposit (Role "alice") (Role "alice") (Token "" "") (Constant 450)) (When [(Case (Choice (ChoiceId "choice" (Role "alice")) [(Bound 0 1)]) (When [(Case (Choice (ChoiceId "choice" (Role "bob")) [(Bound 0 1)]) (If (ValueEQ (ChoiceValue (ChoiceId "choice" (Role "alice"))) (ChoiceValue (ChoiceId "choice" (Role "bob")))) (If (ValueEQ (ChoiceValue (ChoiceId "choice" (Role "alice"))) (Constant 0)) (Pay (Role "alice") (Party (Role "bob")) (Token "" "") (Constant 450) Close) Close) (When [(Case (Choice (ChoiceId "choice" (Role "carol")) [(Bound 1 1)]) Close),(Case (Choice (ChoiceId "choice" (Role "carol")) [(Bound 0 0)]) (Pay (Role "alice") (Party (Role "bob")) (Token "" "") (Constant 450) Close))] 100 Close)))] 60 (When [(Case (Choice (ChoiceId "choice" (Role "carol")) [(Bound 1 1)]) Close),(Case (Choice (ChoiceId "choice" (Role "carol")) [(Bound 0 0)]) (Pay (Role "alice") (Party (Role "bob")) (Token "" "") (Constant 450) Close))] 100 Close)))] 40 (When [(Case (Choice (ChoiceId "choice" (Role "carol"))
@shmish111
shmish111 / blockly.xml
Created January 12, 2021 16:30
Check Blockly
<xml xmlns="https://developers.google.com/blockly/xml"><block type="BaseContractType" id="root_contract" deletable="false" x="13" y="187"><statement name="BaseContractType"><block type="WhenContractType" id="2Vyo!/1A*onBm@4__HV5"><field name="timeout">10</field><statement name="case"><block type="DepositActionType" id="_J5mua{UXj,WM6GUz;$_"><value name="from_party"><block type="RolePartyType" id="}#+4/lxE}U.mk=_n-3r/"><field name="role">alice</field></block></value><value name="value"><block type="ConstantValueType" id="{wn3:O+(:LBr98m~_a85"><field name="constant">350</field></block></value><value name="token"><block type="AdaTokenType" id="=eMx7YSJ8(znSxjcqJ-Z"/></value><value name="party"><block type="RolePartyType" id="jj$GMl/u)#+|,aYf@/qA"><field name="role">alice</field></block></value><statement name="contract"><block type="WhenContractType" id="b8sgwoSNX@uE{HlN9eMe"><field name="timeout">40</field><statement name="case"><block type="ChoiceActionType" id="*@@p^dT[fQ8%0T)#-bRL"><field name="choice_name">