Created
October 27, 2020 20:53
-
-
Save TrevorBenson/98159784aa643098325e5858cb44169d to your computer and use it in GitHub Desktop.
Plutus Playground Smart Contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[0,[]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generic contribution. Error on 30 Ada.toValue, possibly since import is not of Ledger.Ada.TH as that generated error for helloWorld.