user2631: In the onchain validator I used Integer type for Datum and everything was fine
but when I want to use mustPayToOtherScript tx constraint in the offchain code I get the following error:
 • Couldn't match expected type ‘Datum’ with actual type ‘Integer’
 • In the second argument of ‘mustPayToOtherScript’

Edit: offchain code
start :: AsContractError e => Promise () OwnerSchema e ()
start = endpoint @"start" $ \const -> do
    pkh <- pubKeyHash <$> ownPubKey
    let 
        tokenAAmount = 10000000000 
        tokenBAmount = 1000000000000
        lt = 100000000000
        value = (V.assetClassValue poolNFT 1) <>
                (V.assetClassValue tokenA tokenAAmount) <>
                (V.assetClassValue tokenB tokenBAmount)
        tx   = mustPayToTheScript (lt) value 
    ledgerTx <- submitTxConstraints poolInst' tx
    void $ awaitTxConfirmed $ txId ledgerTx
    void $ waitNSlots 1
    logInfo @String $ printf "created pool UTXO %s at validator hash %s" (show poolParams) (show $ orderBoxVH')
    return ()



user2248: Your off-chain code is using mustPayToTheScript and not mustPayToOtherScript. It's important to note the difference, since mustPayToTheScript will require a datum with the type you defined in poolInst', while mustPayToOtherScript will require a datum of type Datum.
So, I will assume you want to use the latter. In this case, you need to convert your variable of type Integer to a variable of type Datum. This can be easily done with (Datum $ PlutusTx.toBuiltinData lt).
Assuming your logic and other components are working, your code would look like the following:
start :: AsContractError e => Promise () OwnerSchema e ()
start = endpoint @"start" $ \const -> do
    pkh <- pubKeyHash <$> ownPubKey
    let 
        tokenAAmount = 10000000000 
        tokenBAmount = 1000000000000
        lt = 100000000000
        value = (V.assetClassValue poolNFT 1) <>
                (V.assetClassValue tokenA tokenAAmount) <>
                (V.assetClassValue tokenB tokenBAmount)
        tx   = mustPayToOtherScript (Datum $ PlutusTx.toBuiltinData lt) value 
    ledgerTx <- submitTxConstraints poolInst' tx
    void $ awaitTxConfirmed $ txId ledgerTx
    void $ waitNSlots 1
    logInfo @String $ printf "created pool UTXO %s at validator hash %s" (show poolParams) (show $ orderBoxVH')
    return ()

Just so it gets easy to debug in the future, I would suggest you to create a function focused specifically in the contract and another function for handling endpoints.

2631: <p>In the onchain validator I used Integer type for Datum and everything was fine
but when I want to use mustPayToOtherScript tx constraint in the offchain code I get the following error:</p>
<pre><code> • Couldn't match expected type ‘Datum’ with actual type ‘Integer’
 • In the second argument of ‘mustPayToOtherScript’
</code></pre>
<p>Edit: offchain code</p>
<pre><code>start :: AsContractError e =&gt; Promise () OwnerSchema e ()
start = endpoint @&quot;start&quot; $ \const -&gt; do
    pkh &lt;- pubKeyHash &lt;$&gt; ownPubKey
    let 
        tokenAAmount = 10000000000 
        tokenBAmount = 1000000000000
        lt = 100000000000
        value = (V.assetClassValue poolNFT 1) &lt;&gt;
                (V.assetClassValue tokenA tokenAAmount) &lt;&gt;
                (V.assetClassValue tokenB tokenBAmount)
        tx   = mustPayToTheScript (lt) value 
    ledgerTx &lt;- submitTxConstraints poolInst' tx
    void $ awaitTxConfirmed $ txId ledgerTx
    void $ waitNSlots 1
    logInfo @String $ printf &quot;created pool UTXO %s at validator hash %s&quot; (show poolParams) (show $ orderBoxVH')
    return ()

</code></pre>
 2248: <p>Your off-chain code is using <code>mustPayToTheScript</code> and not <code>mustPayToOtherScript</code>. It's important to note the difference, since <code>mustPayToTheScript</code> will require a datum with the type you defined in <code>poolInst'</code>, while <code>mustPayToOtherScript</code> will require a datum of type <code>Datum</code>.</p>
<p>So, I will assume you want to use the latter. In this case, you need to convert your variable of type <code>Integer</code> to a variable of type <code>Datum</code>. This can be easily done with <code>(Datum $ PlutusTx.toBuiltinData lt)</code>.</p>
<p>Assuming your logic and other components are working, your code would look like the following:</p>
<pre><code>start :: AsContractError e =&gt; Promise () OwnerSchema e ()
start = endpoint @&quot;start&quot; $ \const -&gt; do
    pkh &lt;- pubKeyHash &lt;$&gt; ownPubKey
    let 
        tokenAAmount = 10000000000 
        tokenBAmount = 1000000000000
        lt = 100000000000
        value = (V.assetClassValue poolNFT 1) &lt;&gt;
                (V.assetClassValue tokenA tokenAAmount) &lt;&gt;
                (V.assetClassValue tokenB tokenBAmount)
        tx   = mustPayToOtherScript (Datum $ PlutusTx.toBuiltinData lt) value 
    ledgerTx &lt;- submitTxConstraints poolInst' tx
    void $ awaitTxConfirmed $ txId ledgerTx
    void $ waitNSlots 1
    logInfo @String $ printf &quot;created pool UTXO %s at validator hash %s&quot; (show poolParams) (show $ orderBoxVH')
    return ()
</code></pre>
<p>Just so it gets easy to debug in the future, I would suggest you to create a function focused specifically in the contract and another function for handling endpoints.</p>
