0

In contract we have two way to call another action:

  1. Use 'action'
      action(permission_level{get_self(), eosio::name{"active"}},
             eosio::name{"eosio"},
             eosio::name{"buyrambytes"},
             std::make_tuple(get_self(), name, 512)
             )
          .send();
  1. Use 'action_wrapper':
      eosiosystem::system_contract::buyrambytes_action buyram{"eosio"_n, {get_self(), "active"_n}};
      buyram.send(get_self(), name, 512);

Please explain the difference between them.

Thank you!

1

The results of both cases are identical, but action_wrapper provides compile-time type check. If you pass invalid parameters, you will fail to build your contract.

You don't need to include the header file of the target contract where you send an inline action with the 1st way (Use 'action'), but to declare action_wrapper, you need the header file or declare function signature of inline action in your contract. (Use 'action_wrapper')

The second way is recommended, but you will not have any issues with the first way if you know what you do exactly.

1
  • That is great explanation! Thank you! – Teresa Oct 21 '20 at 10:00

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.