playground

The world is a playground.

Web3.js でEthereum の残高を取得

web3.eth.getBalance を使用します。

サンプルコード

web3.eth.getBalance(walletAddress, (error, balance) => {
  console.log(balance);
);

ここで取得できる balance の単位は wei なので、ether 単位で表示したい場合は、次のようにします。 var ethBalance = web3.fromWei(balance, 'ether');

デモ

参考