3

I'm trying to convert a V1 contract to V2, and I have offchain code that mints a token with a OneShotCurrency, and then pays the token plus 1 ada to my script.

It worked with Plutus libraries from Feb. 2022, but I'm trying to upgrade it to match the upcoming Vasil HF, so I'm using plutus-apps v1.0.0-alpha1

In the emulator it is currently giving me this error:

TxnValidationFail Phase1 d6dddf483108cdd66915dac9c81d5c41263de34272366f11517debd1597ba3fc:
    CardanoLedgerValidationError "ApplyTxError [UtxowFailure (UtxoFailure
                                 (BabbageOutputTooSmallUTxO [((Addr Testnet ...

It appears that the min Ada amount is higher than 1 Ada, because if I change it to 10 Ada, it works.

Does anyone know if there's Plutus code for checking for the minAda required for a tx, without using the cardano-cli?

2 Answers 2

2

This was just answered here. The min UTxO output value calculation has changed for the Babbage era. Make sure you're using the latest version of whatever library/ sdk you're using to construct transactions.

1
  • 1
    Yes, you're correct, the Babbage era has changed the calculations. You can no longer submit a tx that pays an NFT to a script, such as an oracle script, without including an amount of Ada with it. This might have already been the rule on the testnet and mainnet, but the Emulator used to let it go. I've upgraded to the V2 libraries, so now the Emulator enforces this rule.
    – marcel_g
    Commented Sep 15, 2022 at 3:46
1

I unfortunately asked 2 questions in one, and since @william answered one of them he should get the credit for the answer.

To answer the second question for future reference, there is indeed a Plutus function that does get the min amount of Ada so you can add that to your Tx Constraints: maxMinAdaTxOut

    let c = Constraints.mustPayToOtherScript (oracleValidatorHash oupOracle) 
                    (V1LedgerScripts.Datum $ PlutusTx.toBuiltinData oupNewFee) 
                       $ ((assetClassValue (oracleAsset oupOracle) 1) <>
                          (Ada.toValue maxMinAdaTxOut))

I've tested this within the Emulator and it does indeed work.

2
  • 1
    Good point! I forgot to mention that. Great that you've found out yourself.
    – Will
    Commented Sep 15, 2022 at 8:52
  • 1
    18.5 is a lot of ada to be passing around just to satisfy minUtxo. You'll probably find that most outputs only need a little more than 1 ada when they hold a few tokens and some datum. It would be best to calculate the realistic maximum for your application, see evaluateMinLovelaceOutput.
    – james
    Commented Sep 15, 2022 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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