1

I am using a very simple example:

mycontract.hpp:

[[eosio::on_notify("eosio.token::transfer")]] 
void depos(name from, name to, asset quantity, string memo);

mycontract.cpp:

[[eosio::on_notify("eosio.token::transfer")]] 
void depos(name from, name to, asset quantity, string memo) {
  check(false, "notification handler triggered successfully");
}

By calling eosio.token::transfer, the transaction happens successfully, but my function depos does not get called.

3 Answers 3

1

It seems that the contract containing the on_notify attribute should be either the sender or reciever of the transfer. This is not clearly mentioned in the manual

1

Notification is delivered by require_recipient. eosio.token::transfer calls require_recipient for from (sender of token) and to (recipient of token) account. As @towi_parallelism mentioned, only sender and recipient can get notification.

https://github.com/EOSIO/eosio.contracts/blob/d7bc0a5c/contracts/eosio.token/src/eosio.token.cpp#L89-L90

0

If you are using EOSIO_DISPATCH with ACTION keyword, then replace ACTION keyword with [[eosio::action]] void from your .hpp file and remove EOSIO_DISPATCH from your .cpp file of smart contract.

As EOSIO_DISPATCH blocks eosio::on_notify.

Also check: [[eosio::on_notify("VALID_EOSIO_ACCOUNT_NAME::VALID_EOSIO_ACTION_NAME")]] Ref: https://developers.eos.io/manuals/eosio.cdt/v1.6/guides/generator-attributes

Please closely check eosio.token contract you will get how use. https://github.com/EOSIO/eosio.contracts/tree/master/contracts/eosio.token

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.