0
pragma solidity ^0.8.0;
contract C {
   string internal secret= "secret data";

   function x() internal returns (uint) {
      return 10;
   }
}

Accessing Internal Variable:

web3.eth.getStorageAt('0x6260319bcbcbf33f84397ae0000e49b0f50ee075', 0, (e, v) => console.log(web3.toAscii(v)));

So far what i understand is we can access Internal Variables through storage, What i want to know is if there is a way to also access Internal Functions, by layout i understand that they dont exist in storage section of EVM. so if we can access them, how ?

zOthix
  • 121
  • 5
  • Where do you want to access the internal functions? In your frontend? – Paul Razvan Berg Jul 16 '22 at 10:13
  • @PaulRazvanBerg in frontend, or any script, basically just wanna invoke the internal function. – zOthix Jul 16 '22 at 10:15
  • well "any script" is a bit vague. There are development contexts in which you can access the internal functions, but I will assume that you're not referring to those. – Paul Razvan Berg Jul 16 '22 at 10:33
  • 1
    Basically it is not possible to call internal or private functions from any frontend context. – Paul Razvan Berg Jul 16 '22 at 10:34
  • @PaulRazvanBerg can you give a elaborate reason why private/internal variables are accessible but functions are not? – zOthix Jul 18 '22 at 05:50
  • private/ internal variables are not accessible either. – Paul Razvan Berg Jul 18 '22 at 08:15
  • @PaulRazvanBerg you can try this code ```web3.eth.getStorageAt('0x6260319bcbcbf33f84397ae0000e49b0f50ee075', 0, (e, v) => console.log(web3.toAscii(v)));
    
    
    – zOthix Jul 18 '22 at 11:00
  • what I meant is that private/ internal variables are not accessible via a getter because Solidity doesn't create getters for them. Of course you can read anything manually from the contract's storage - everything stored on Ethereum is public. – Paul Razvan Berg Jul 18 '22 at 12:42
  • @PaulRazvanBerg so is there a way to also call internal function? in such a manner ? – zOthix Jul 19 '22 at 19:06

0 Answers0