3

I cant seem to figure out whats going on? Ive been trying to create a transaction which sends ADA to a specified wallet address and can't seem to get it to work.

type Schema =
        Endpoint "storeFront" PaymentPubKeyHash

payPubHash :: PaymentPubKeyHash
payPubHash = "3f7846896a48c59359746ff096d63606ceb82e65900d20a9fd2b8a93"

storeFront :: AsContractError e => Promise () Schema e ()
storeFront = endpoint @"storeFront" $ \(payPubHash) -> do
    unspentOutputs <-  utxosAt contractAddress
    
    let 
        tx       = Constraints.mustPayToPubKey payPubHash (singleton adaSymbol adaToken 30000000) 
    void $ submitTxConstraintsSpending storeContract unspentOutputs tx
        
contract :: AsContractError e => Contract () Schema e ()
contract = storeFront

endpoints :: AsContractError e => Contract () Schema e ()
endpoints = contract

mkSchemaDefinitions ''Schema

$(mkKnownCurrencies [])

here's the error

Compilation Error, Line 93, Column 12 (jump)

 error:
    • Couldn't match expected type ‘Contract () Schema e ()’
                  with actual type ‘Promise () Schema e0 ()’
    • In the expression: storeFront
      In an equation for ‘contract’: contract = storeFront
    • Relevant bindings include
        contract :: Contract () Schema e ()
          (bound at /tmp/web-ghc-work-c17f548fe0e3f9c3/Main.hs:93:1)
   |
93 | contract = storeFront
   |            ^^^^^^^^^^

1 Answer 1

2

It appears you are trying to assign a type of Promise to a type of Contract

contract :: AsContractError e => Contract () Schema e ()
contract = storeFront

Why not try this, instead:

contract :: AsContractError e => Contract () Schema e ()
contract = awaitPromise storeFront

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.