-1

I am using browserify. I have node.js file as below:

const Web3 = require('web3');
const web3 = new Web3('https://kovan.infura.io');

window.onload = function () {

web3.eth.getBalance('0x9E632F36D8193a23ee76e7C14698aCF4b92869A2').then(console.log)
document.getElementById("sc_bal").innerHTML=web3.eth.getBalance('0x9E632F36D8193a23ee76e7C14698aCF4b92869A2');

};

I want to show the smart contract address in HTML div element. If I console the value it shows the output, but if I bind value with div element then it displays as

[object Promise]

Can anybody help me with this problem?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Varsh
  • 413
  • 9
  • 26

1 Answers1

-2

The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.1

document.getElementById("sc_bal").innerHTML=web3.eth.getBalance('0x9E632F36D8193a23ee76e7C14698aCF4b92869A2')
.then(val => val)
.catch(err => err.message);

This might help.

Community
  • 1
  • 1
Kunal Virk
  • 132
  • 5