Using on_notify with services

To use on notify requires the contract specifying their own custom dispatcher by replacing




}; // this line is important! closes the contract

extern "C" {
  void apply(uint64_t receiver, uint64_t code, uint64_t action) {
    // some custom logic, say an NFT transfer for on_notify
    if (code == NFT_ACCOUNT.value && action == name("transfer").value) {
      eosio::execute_action(eosio::name(receiver), eosio::name(code),
    else {
      switch (action) {
        // for dapp network service actions
        // update with you contract's actions
        EOSIO_DISPATCH_HELPER(CONTRACT_NAME(), (create)(issue)(transfer))
        // enabling dapp network signal actions

Example from atomic token peg contract here.

Read more on CONTRACT_END here.

You must ensure to include the else portion so as to handle the contracts actions and the dappservices logic.

Inside the switch (action) section there are 3 lines. The first line provides access to the dapp network service actions. The second should be your smart contracts actions, this should be the same list of actions that would appear in the CONTRACT_END macro. The final line is for xsignal, again for enabling DAPP Network service actions.

Last updated