Skip to content

Instantly share code, notes, and snippets.

@laalaguer
Created March 5, 2019 09:25
Show Gist options
  • Save laalaguer/f347c14925584d1ad7ea4a284a7e5097 to your computer and use it in GitHub Desktop.
Save laalaguer/f347c14925584d1ad7ea4a284a7e5097 to your computer and use it in GitHub Desktop.
Operations to query balance of VTHO
/**
* Get token amount of holder from a contract.
* @param {String} addressContract 0x started address.
* @param {String} addressHolder 0x started address.
*/
async function getTokenBalance (addressContract, addressHolder) {
const balanceOfABI = {
'constant': true,
'inputs': [
{
'name': '_owner',
'type': 'address'
}
],
'name': 'balanceOf',
'outputs': [
{
'name': 'balance',
'type': 'uint256'
}
],
'payable': false,
'stateMutability': 'view',
'type': 'function'
}
// eslint-disable-next-line
const balanceOfMethod = connex.thor.account(addressContract).method(balanceOfABI)
const balanceInfo = await balanceOfMethod.call(addressHolder)
return balanceInfo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment