how to calculate ABI to call some variable in contract?

for example

 contract X {
   uint data;
   function Y(uint a) {}

How to calculate signature to call variable "data" ? I know to call function we should do something like that keccak256("Y(uint)") but if we want to call variable ?


All public variables generate a getter with the same name as the variable. So a variable with name data will result in a function with signature function data().

Therefore, if you want, you can calculate the call signature with the formula you provided.


solc will generate the ABI for you (as will remix and truffle)

Just run solc --abi yourfile.sol.

You can see a list of compiler options here.

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.