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.

  • I don't get error mesagess, but the if (...) always running... – Efraim Jan 14 at 5:49
  • yes used transfers. – Efraim Jan 14 at 7:19
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
| improve this answer | |
  • Thank You It is works fine. – Efraim Jan 14 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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