eos icon indicating copy to clipboard operation
eos copied to clipboard

How to set the contract owner?

Open dksuper opened this issue 8 years ago • 7 comments

Recently , I need add permission control in my contract , that only one account can operate it , the result of require_auth() function , is not I need , does any one can tell my the right way?

dksuper avatar Sep 03 '18 09:09 dksuper

Tip: clearly stating your question would help you get better and more accurate answers

xJonathanLEI avatar Sep 03 '18 15:09 xJonathanLEI

require_auth(N(YOUR_HARDCODED_ACCOUNT));

taokayan avatar Sep 04 '18 01:09 taokayan

@xJonathanLEI More specifically is , I want set the contract owner , and the contract owner is only one who can operate this contract , but when I use require_auth() , this function only can recognize , the account which is in eosio , so in eosio every account can operate my contract.

I have some idea , that is through multi_index to record , who is owner in this contract , or set a defult owner account in contract , thet use eosio_assert in every functions to determine who can access.

Does eosio have provide the offcial function that can check the contract owner or deployer?

dksuper avatar Sep 04 '18 02:09 dksuper

@taokayan Thank for your reply , so the require_auth(N(YOUR_HARDCODED_ACCOUNT)); can use to determine who is the contract owner?

dksuper avatar Sep 04 '18 02:09 dksuper

require_auth is not just for eosio accounts. Just put your "owner" account name inside. The function throws when a valid permission from the said account is not present.

xJonathanLEI avatar Sep 04 '18 02:09 xJonathanLEI

@taokayan I try it , and it work well, thank you!

dksuper avatar Sep 05 '18 05:09 dksuper

@xJonathanLEI Thanks for reply , it is work , thank you!

dksuper avatar Sep 05 '18 05:09 dksuper