import "@openzeppelin/contracts/access/Ownable.sol";

function _addStudentAddr(address addr) private onlyOwner {

I am creating a smart contract to add frictional students ETH address on-chain ( goerli testnet ), doing this as a personal development project. Now, I am curious if it makes sense to add access modified ( onlyOwner ) to a private function. From a security perspective it is already a private function so I am assuming it is secure, can someone explain more about access modifiers and contract visibility in this case.

1 Answer 1


In general practice, people use access control only on public or external because these functions can be called by anyone (external accounts, contracts, ...). For internal and private functions, you don't have to do so because it's only be called by other functions of your own contract and it's redundant if you already have checks on other public functions. In you code, to access _addStudentAddr you have to declare another public function and can place access control on that. Without that public function, nobody can access _addStudentAddr therefore the check for private function is redundant:

function addStudent(address addr) public onlyOwner {
function _addStudentAddr(address addr) private {

Your Answer

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

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