Some of my action require a special role "admin". What is the best way to handle set some user as admin and some action require the users with admin role? (In solidity, I can have a setAdmin() function and modifier requireAdmin().)
1 Answer
You can use the require_auth2()
function, which can check a custom permission
Verifies that name exists in the set of provided auths on a action. Throws if not found
Parameters
name
- name of the account to be verified
permission
- permission level to be verified
The official docs have an article explaining permissions in EOSIO, and you can create and manage new permissions using $ cleos set account permission