Skip to content

Instantly share code, notes, and snippets.

@cryptowen
Created February 18, 2022 02:26
Show Gist options
  • Save cryptowen/8f9bea653bf5b362550815f4ba05f8a5 to your computer and use it in GitHub Desktop.
Save cryptowen/8f9bea653bf5b362550815f4ba05f8a5 to your computer and use it in GitHub Desktop.
Plutus Playground Smart Contract
import Control.Monad (void)
import Ledger (Address, ScriptContext, PaymentPubKeyHash)
import Ledger.Constraints qualified as Constraints
import Ledger.Typed.Scripts qualified as Scripts
import Ledger.Value (Value)
import Playground.Contract
import Plutus.Contract
import PlutusTx qualified
import PlutusTx.Prelude hiding (Applicative (..))
-- | These are the data script and redeemer types. We are using an integer
-- value for both, but you should define your own types.
data CkbBurn = CkbBurn {
senderAddress :: PaymentPubKeyHash,
ckbTxHash :: PaymentPubKeyHash,
asset :: BuiltinByteString,
amount :: Integer,
bridgeFee :: Integer,
recipientAddress :: PaymentPubKeyHash
} deriving (Generic, ToJSON, FromJSON, ToSchema, PlutusTx.UnsafeFromData)
data Verifiers = Verifiers {
verifiersList :: [PaymentPubKeyHash]
} deriving (Generic, ToJSON, FromJSON, ToSchema, PlutusTx.UnsafeFromData)
PlutusTx.makeLift ''CkbBurn
PlutusTx.makeLift ''Verifiers
validateSpend :: () -> Verifiers -> CkbBurn -> ScriptContext -> Bool
validateSpend () d r _ = True
contractAddress :: Address
contractAddress = Scripts.validatorAddress (typedValidator ())
data MultiSig
instance Scripts.ValidatorTypes MultiSig where
type instance RedeemerType MultiSig = CkbBurn
type instance DatumType MultiSig = Verifiers
typedValidator :: () -> Scripts.TypedValidator MultiSig
typedValidator = Scripts.mkTypedValidatorParam @MultiSig
$$(PlutusTx.compile [|| validateSpend ||])
$$(PlutusTx.compile [|| wrap ||])
where
wrap = Scripts.wrapValidator
-- | The schema of the contract, with two endpoints.
type Schema =
Endpoint "handle" (CkbBurn, [Verifiers])
contract :: AsContractError e => Contract () Schema e ()
contract = selectList [handle]
handle :: AsContractError e => Promise () Schema e ()
handle = endpoint @"handle" $ \r -> return ()
endpoints :: AsContractError e => Contract () Schema e ()
endpoints = contract
mkSchemaDefinitions ''Schema
$(mkKnownCurrencies [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment