2

Apparently, solidity creates getter functions for public variables. How does one call them using javascript? (for testing within truffle)

6

You just call them as you would any other function. The getter function has the same name as the state variable, so if you have:

uint256 public foo;

then you can read its value in JavaScript with:

contract.foo()

See https://programtheblockchain.com/posts/2018/01/02/making-smart-contracts-with-public-variables/.

3

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.