0

How can I make a solidity function to be only callable by other functions in the same contract? and it doesn't visible in etherscan or remix as a normal function.

Eg:

contract Calc {
      function add(uint a, uint b) public returns(uint) {
                return adder(a,b);
             }
      function adder(uint a, uint b) public returns(uint) {
                return (a+b);
          }

}

here I need to make the function 'adder' is only accessible to other function like 'add'. but i can't be accessed by the user through remix or etherscan

1 Answer 1

1
function adder(uint a, uint b) public returns(uint) {
                return (a+b);
          }

simply change the visibility of your adder function from public to internal or private

public means the function is accessible from the inside and outside.

internal means the function is accessible only from within the contract himself and contracts inheriting from that contract.

private means the function is only callable within the very smart 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.