States & View-Functions
A state is a variable or view that can change over time. A state is always the same at the same block height.
Example Conditions
Source Code
The VTHO contract's source code is available on GitHub:
https://github.com/vechain/thor/blob/f58c17ae50f1ec8698d9daf6e05076d17dcafeaf/builtin/gen/energy.sol (opens in a new tab)
Contract address
The public VTHO contract is used. Address is identical on Test and MainNet.
0x0000000000000000000000000000456E65726779
ABI
Definition of the balanceOf
that returns the VTHO balance for a given address.
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
Function definition
function balanceOf(address _owner) public view returns(uint256 balance) {}
Connex Example
const result = await connex.thor
.account(CONTRACT_ADDRESS)
.method(abi)
.call(address);
console.log(result.decoded.balance)