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?

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, privacy policy and cookie policy

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