Skip to content

Instantly share code, notes, and snippets.

@TrevorBenson
Created October 27, 2020 20:53
Show Gist options
  • Save TrevorBenson/98159784aa643098325e5858cb44169d to your computer and use it in GitHub Desktop.
Save TrevorBenson/98159784aa643098325e5858cb44169d to your computer and use it in GitHub Desktop.
Plutus Playground Smart Contract
import qualified Language.PlutusTx as PlutusTx
import qualified Ledger.Interval as Interval
import Ledger.Slot (SlotRange)
import qualified Ledger.Slot as Slot
import Language.PlutusTx.Prelude as P
import Ledger
import qualified Ledger.Ada as Ada
import Ledger.Ada (Ada)
import Ledger.Validation
import Playground.Contract
import Wallet as Wallet
myValidatorScript :: ValidatorScript
myValidatorScript = ValidatorScript $$(Ledger.compileScript [||
\(ds :: ()) (rs :: ()) (_ :: PendingTx) -> ()
||])
helloAction :: MonadWallet m => m ()
helloAction = Wallet.logMsg "Hello World!"
contractAddress :: Address
contractAddress = Ledger.scriptAddress myValidatorScript
contribute :: MonadWallet m => Ada -> m ()
contribute value = do
ownPK <- ownPubKey
let dataScript = DataScript $ Ledger.lifted ownPK -- Create a data script with oenPK
range = Wallet.defaultSlotRange -- Range when transaction is ValidatorScript
amount = $$(Ada.toValue) value -- Vlaue amount to send
payToScript_ range contractAddress amount dataScript --Create and send transaction to contractAddress
logMsg "Submitted contribution" -- Output a message to the logMsg
$(mkFunctions ['helloAction, 'contribute])
@TrevorBenson
Copy link
Author

Generic contribution. Error on 30 Ada.toValue, possibly since import is not of Ledger.Ada.TH as that generated error for helloWorld.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment