1

In the validator, I have defined:

txInfo :: TxInfo
txInfo = scriptContextTxInfo ctx

feePaid :: Integer
feePaid = Ada.getLovelace (Ada.fromValue (txInfoFee txInfo))

the strange thing is, when I do:

traceIfFalse "fee test" (feePaid >= 0)

, it evaluates to True, but

traceIfFalse "fee test" (feePaid == 0)

and

traceIfFalse "fee test" (feePaid > 0)

evaluates to False! How is this possible? Am I doing something wrong?

The very same thing happens when using Plutus.V1.Ledger.Contexts functions.

For example valueProduced (of ADA, using valueOf, so getting Integer) - valueSpent (same, Integer) equates to true if using >= or <= operator, but is neither >, < or ==.

Evaluating using Emulator Trace.

valueProduced, valueSpent example:

test :: TxInfo -> Order -> Integer
test info ord = subtractInteger (valueOf (valueProduced info) (quoteAssetSymbol ord) (quoteAssetName ord)) (valueOf (valueSpent info) (quoteAssetSymbol ord) (quoteAssetName ord))

Order has quoteAssetSymbol which is of type CurrencySymbol and is ADA (""), quoteAssetSymbol is of type TokenName, and is also ADA ("").

Tried using greaterThanEqualsInteger, equalsInteger, etc.. Same result

1 Answer 1

1

I think you're not using the correct comparison operators. Make sure you import PlutusTx.Prelude and use == function from there, like described here:

https://cardano.stackexchange.com/a/8323/5085

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.