8

I have seen in numerous places that the following is coded -

require_auth (_self);

Aside from the intuitive meaning that it requires a user to be authorised, what exactly does it do and how?

1 Answer 1

7

Contracts inherit from eosio::contract, and, if we look in eosiolib/contract.hpp for the base class, we see that the constructor for eosio::contract is as follows:

contract( account_name n ):_self(n){}

Therefore, the account that creates the contract and calls the constructor becomes _self. Thus, require_auth(_self) ensures that the account executing the function has the authority of the account that created the contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.