• The example code below listens to Ether balance changes.
  • It gets Ether balance when a new block mined.
  • Strictly speaking, a fork can be happened. So you will need to count confirmation numbers depending on your application.
const ethers = require('ethers')const network = 'rinkeby'
const provider = ethers.getDefaultProvider(network)
const address = '0xF02c1c8e6114b1Dbe8937a39260b5b0a374432bB'// Listen Ether balance changes
let lastBalance = ethers.constants.Zero
provider.on('block', () => {
provider.getBalance(address).then((balance) => {
if (!balance.eq(lastBalance)) {
lastBalance = balance
// convert a currency unit from wei to ether
const balanceInEth = ethers.utils.formatEther(balance)
console.log(`balance: ${balanceInEth} ETH`)
}
})
})

Support

If you find this article is helpful, it would be greatly appreciated if you could tip Ether to the address below. Thank you!

0x0089d53F703f7E0843953D48133f74cE247184c2

--

--

const ethers = require('ethers')const network = 'rinkeby' // use rinkeby testnet
const provider = ethers.getDefaultProvider(network)
const address = '0xF02c1c8e6114b1Dbe8937a39260b5b0a374432bB'
provider.getBalance(address).then((balance) => {
// convert a currency unit from wei to ether
const balanceInEth = ethers.utils.formatEther(balance)
console.log(`balance: ${balanceInEth} ETH`)
})

Support

If you find this article is helpful, it would be greatly appreciated if you could tip Ether to the address below. Thank you!

0x0089d53F703f7E0843953D48133f74cE247184c2

--

--

With the ethers.js library, you can generate Ethereum wallet by writing the code below:

Code (Node.js)

const ethers = require('ethers')
const wallet = ethers.Wallet.createRandom()
console.log('address:', wallet.address)
console.log('mnemonic:', wallet.mnemonic.phrase)
console.log('privateKey:', wallet.privateKey)

Result

address: 0xb985d345c4bb8121cE2d18583b2a28e98D56d04b
mnemonic: produce alley citizen bone enact settle hedgehog common plate dwarf lady someone
privateKey: 0x49723865a8ab41e5e8081839e33dff15ab6b0125ba3acc82c25df64e8a8668f5…

--

--

Recent NFT/Crypto art excitement reminds me my old crypto art project on Ethereum.

Let me introduce the crypto art project which is called Pixereum (https://pixereum.io/) because it’s a good opportunity:P

There are 10000 pixels (x=100, y=100) on the Pixereum. Each pixel is managed on the Ethereum smart contract and pixels can be bought and sold in Ether. Additionally, pixel holders can set arbitrary color and message to pixels they own.

If you are interested, please try it here: https://pixereum.io/.

Thanks!

--

--