title_body: Where is the returning Contract Monad in the handleError function of Contract Monad? The type of handleError function is
  :: (e -&gt; Contract w s e' a)-&gt; Contract w s e a -&gt; Contract w s e' a
  
  It takes two arguments
  
  a function which takes error and returns a Contract monad (Contract w s e' a) without error
  Contract Monad with error
  
  and returns a Contract Monad without error (Contract w s e a). This is what I could understand. However when this is used in the following code
  payContract = do
     pp &lt;- endpoint @&quot;pay&quot;
     let tx = mustPayToPubKey (ppRecipient pp) $ lovelaceValueOf $ ppLovelace pp
     handleError (\err -&gt; Contract.logInfo $ &quot;caught error: &quot; ++ unpack err) $ void $ submitTx tx
     payContract
  
  In this function call submitTx Tx gives the Contract Monad with error and the lambda function \err -&gt; Contract.logInfo $ &quot;caught error: &quot; ++ unpack err may be the first argument. What is happening to the returned Monad without error? and why void is used?
upvoted_answer: Definitions:
  submitTx :: forall w s e. (HasWriteTx s, AsContractError e) =&gt; TxConstraints Void Void -&gt; Contract w s e Tx
  void :: Functor f =&gt; f a -&gt; f ()
  handleError :: (e -&gt; Contract w s e' a)-&gt; Contract w s e a -&gt; Contract w s e' a
  Explaination:
  submitTx tx is of type Contract w s e Tx, i.e. a Contract Monad with return type Tx.
  void takes any Monad and maps it to a Monad with return type (). This is useful if you don't care for the returned value: void $ submitTx tx :: Contract w s e ()
  handleError then takes the Monad and handles any errors with the specified error handler (e -&gt; Contract w s e' a). However, it doesn't change the return type of the Contract Monad. In case there is no error on runtime the return value is just passed through.
  payContract calls itself recursively on the last line of the do block in order to listen to the pay-endpoint indefinitely. Let's assume you'd leave out handleError and only use void $ submitTx tx your contract would crash on the first submission error.
  If you wouldn't use void, your program would still be valid, but your compiler would output a warning, because you didn't use the return value of submitTx tx.