0

I created a publish permission, and I want to this permission can only execute the publish action in my tweet contract. How to link the permission to the action?

1

I think, you have an incorrect idea regarding permissions in eos. A permission in itself does not have any authority to do anything, but an account with a certain permission can be used to authorise actions.

Now, if that is clear, what you may do for your problem is, in your action (member function's definition), you can check that only accounts with the "publish" permissions are allowed to execute this action.

This may be done by using the following eoslib function for an account

eosio::require_auth2(<account_name>, N(publish);
|improve this answer|||||
  • If the action use eosio::require_auth2(<account_name>, N(publish), can I use the active permission to authorize the action? – Jimmy Guo Jul 15 '18 at 6:48
  • sure you can; user it as eosio::require_auth2(acct_nm, N(active)). – Akhil Tiwari Jul 15 '18 at 7:32
  • I just want to the publish permission and its parent permission to call the publish action, and the publish permission can only call this action. – Jimmy Guo Jul 16 '18 at 9:51

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.