Skip to content

Instantly share code, notes, and snippets.

@laalaguer
Last active March 5, 2019 10:13
Show Gist options
  • Select an option

  • Save laalaguer/6af6cd3cdee7980557b6b7dd555de2f8 to your computer and use it in GitHub Desktop.

Select an option

Save laalaguer/6af6cd3cdee7980557b6b7dd555de2f8 to your computer and use it in GitHub Desktop.
Add query balance function
<!-- Continue with the App.vue -->
<script>
const operations = require('./operations.js')
const utils = require('./utils.js')
export default {
data() {
return {
myaddress: '0xa7a609b928c4eac077d0e5640f3fa650746c4fcf',
myamount: 0,
contract: '0x0000000000000000000000000000456e65726779'
}
},
beforeMount () {
this.refreshTokenBalance()
},
methods: {
refreshTokenBalance () {
operations.getTokenBalance(this.contract, this.myaddress)
.then(result => {
this.myamount = utils.evmToPrintable(result['decoded']['balance'], this.decimals)
})
.then(() => {
// eslint-disable-next-line
const ticker = connex.thor.ticker()
ticker.next().then(() => { this.refreshTokenBalance() })
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment