I am trying to get the value of a variable in a Smart Contract using solidity, geth and web3j.
The contract HelloWorld is very simple:
pragma solidity ^0.6.10;
contract HelloWorld {
uint256 public counter = 5;
function add() public { //increases counter by 1
counter++;
}
function subtract() public { //decreases counter by 1
counter--;
}
function getCounter() public view returns (uint256) {
return counter;
}
}
web3j does not have a call() function, just only send() which is surprising.
when I try get counter following the web3j instructions:
contract.getCounter().send()
I get a transaction receipt rather than the value uint256.
Can anybody help?
Thank you
Will
contract.methods.getCounter().call()...
– Emmanuel Collin