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?
EOS.IO Stack Exchange is a question and answer site for users and developers of distributed applications built on top of the blockchain operating system, EOS.IO. It only takes a minute to sign up.
Sign up to join this communityContracts 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.