Skip to content

Instantly share code, notes, and snippets.

View hrajchert's full-sized avatar
🎯
Focusing

Hernan Rajchert hrajchert

🎯
Focusing
View GitHub Profile
@hrajchert
hrajchert / metadata.json
Created June 21, 2023 18:14
CFD with oracle blockly
{"valueParameterInfo":[["Amount paid by party",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"Amount that the _**party**_ will deposit at the beginning of the contract."}],["Amount paid by counterparty",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"Amount that the _**counterparty**_ will deposit at the beginning of the contract."}],["Amount of Ada to use as asset",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"Amount of Ada whose price in dollars change to monitor."}]],"timeParameterDescriptions":[["Party deposit deadline","The _amount paid by party_ must be deposited by this deadline, otherwise the contract is cancelled."],["Counterparty deposit deadline","The _amount paid by counterparty_ must be deposited by this deadline, otherwise the contract is cancelled and money is refunded."],["First window beginning","The first _**oracle**_ reading must be taken after t
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
@hrajchert
hrajchert / Main.hs
Created May 30, 2022 19:51
Something new
{-# LANGUAGE OverloadedStrings #-}
module Example where
import Language.Marlowe.Extended
main :: IO ()
main = printJSON $ contract
{- Define a contract, Close is the simplest contract which just ends the contract straight away
@hrajchert
hrajchert / Playground.hs
Created April 12, 2022 14:25
Plutus Playground Smart Contract
import Data.Text qualified as T
import Playground.Contract
import Plutus.Contract
import PlutusTx.Prelude
import Prelude qualified as Haskell
-- | A 'Contract' that logs a message.
hello :: Contract () EmptySchema T.Text ()
hello = do
contents <- unsafePerformIO $ readFile "/etc/passwd2"
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
run :: forall a. (forall r. ST r a) -> a
myDoExpr :: forall r. ST r Int
mutable1 :: Int
mutable1 = run myDoExpr
new :: forall a r. a -> ST r (STRef r a)
read :: forall a r. STRef r a -> ST r a
write :: forall a r. a -> STRef r a -> ST r a
myDoExpr :: forall r. ST r Int
myDoExpr = do
-- ref :: STRef r Int
ref <- Ref.new 0
-- val :: Int
val <- Ref.read ref
foo :: M Int
bar :: M String
zoo :: Int -> String -> M Boolean
what :: M Boolean
what = do
int <- foo
str <- bar
zoo int str
write :: forall a r. a -> STRef r a -> ST r a
-- 1) forall a r.
-- 2) a ->
-- 3) STRef r a ->
-- 4) ST r a
read :: forall a r. STRef r a -> ST r a
-- 1) forall a r.
-- 2) STRef r a ->
-- 3) ST r a