0

I would like to check in my contract the incomming amount.

I tried these:

void mycontract(name from, name to, eosio::asset quantity, std::string memo){

    check( quantity.amount > 50, "must transfer only maximum 50 tokens/transaction" );

or

if(quantity.amount > 50) { }

But these not working.

2
  • I don't get error mesagess, but the if (...) always running...
    – Efraim
    Commented Jan 14, 2020 at 5:49
  • yes used transfers.
    – Efraim
    Commented Jan 14, 2020 at 7:19

1 Answer 1

0

Well, you're expecting this check to ensure that the amount is over 50.0 tokens, but the thing is that asset.amount is an integer, so let's say your token has 6 decimals, then you'd want this assertion to be:

check( quantity.amount > 50000000, "must transfer only maximum 50 tokens/transaction" );

more examples:

  • 5.1234 EOS's amount will be 51234
  • 20.0000000000 BNT's amount will be 200000000000
1
  • Thank You It is works fine.
    – Efraim
    Commented Jan 14, 2020 at 12:03

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.