Open in app

Sign In

Write

Sign In

Hideyoshi Moriya
Hideyoshi Moriya

174 Followers

Home

About

Jul 4, 2021

How to watch Ether balance changes

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`) } }) })

Ethereum

1 min read

Ethereum

1 min read


Jul 3, 2021

How to get a balance of Ether with ethers.js

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

Ethereum

1 min read

Ethereum

1 min read


Jul 2, 2021

How to send Ether with ethers.js

An example code to send Ether from one wallet to another wallet with ethers.js. In this example code, 0.01 ether is send from 0xb985d345c4bb8121cE2d18583b2a28e98D56d04b to 0xF02c1c8e6114b1Dbe8937a39260b5b0a374432bB. // import ethers.js const ethers = require('ethers') // network: using the Rinkeby testnet let network = 'rinkeby' // provider: Infura or Etherscan will be…

Ethereum

1 min read

Ethereum

1 min read


Jul 1, 2021

How to generate Ethereum wallet with ethers.js

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

Ethereum

1 min read

Ethereum

1 min read


Mar 9, 2021

Pixereum — Experimental crypto art project

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.

Cryptoart

1 min read

Pixereum — Experimental crypto art project
Pixereum — Experimental crypto art project
Cryptoart

1 min read


Aug 24, 2018

How to send Ripple XRP with JavaScript

In this article, I’m going to explain how to send XRP with JavaScript (Node.js). Install ripple-lib First of all, install the ripple-lib library by using following code: npm install ripple-lib Instantiate Ripple API When Instantiating Ripple API, you can specify a server to connect. const RippleAPI = require('ripple-lib').RippleAPI const api = new RippleAPI({…

JavaScript

2 min read

JavaScript

2 min read


Aug 23, 2018

How to use Infura.io with Web3.js 1.0

HTTP provider is deprecated in Web3.js 1.0. Websocket provider needs to be used instead of HTTP provider. Infura HTTP provider URL: https://mainnet.infura.io Infura Websocket URL: wss://mainnet.infura.io/ws In Web3.js 1.0, Web3 needs to be initialized as below. var web3 = new Web3('wss://mainnet.infura.io/ws'); Support If you find this article is helpful, it would be greatly appreciated if you could tip Ether to the address below. Thank you!

Ethereum

1 min read

Ethereum

1 min read


Aug 23, 2018

List of Ethereum’s Major Network and Chain IDs

Ethereum network uses different IDs in its main network and several test networks. By the combination of Network ID and Chain ID, Ethereum nodes can choose nodes to be connected and generate different signed transactions. Chain ID was introduced as EIP155 when Ethereum Classic was forked from Ethereum to prevent…

Blockchain

1 min read

Blockchain

1 min read


Aug 23, 2018

How to get Ethereum’s transaction details from its transaction hash

Install Web3 (version 1.0) $ npm install web3 Example code const Web3 = require('web3'); console.log(Web3.version); // => 1.0.0-beta.34 var web3 = new Web3('wss://mainnet.infura.io/ws'); const transactionHash = '0x6d365aa4dda50738ae9b63d0ec634d9163c814a1f257b88ed383bd3dae33bbb2'; web3.eth.getTransaction(transactionHash, function (error, result){ console.log(result); }); // result => // { blockHash: '0x767636dfb822296c23222714a0136a938d6436de5293ae59282b3ce266e7c04e', // blockNumber: 5526818, // from: '0x5baeB16048431F0F6f366788d0c1B381280c3f81', // gas: 21000, // gasPrice: '50000000000', // hash: '0x6d365aa4dda50738ae9b63d0ec634d9163c814a1f257b88ed383bd3dae33bbb2', // input: '0x', // nonce: 0, // to: '0xF02c1c8e6114b1Dbe8937a39260b5b0a374432bB', // transactionIndex: 55, // value: '4290000000000000', // v: '0x26', // r: '0x7340afd3e9c3bb3159443af772fd50cb0720fa0d1a82bfe3bcf9b7b539c1ce60', // s: '0x4951b17a78169233a0ee24651eff54265fd6dbb6cbaa2fc5c55cffcf78743123' }

Ethereum

1 min read

Ethereum

1 min read


Aug 23, 2018

How to create Ripple (XRP) address with JavaScript?

Install ripple-lib $ npm install ripple-lib Example code This example code works in offline. const RippleAPI = require('ripple-lib').RippleAPI; const api = new RippleAPI(); const address = api.generateAddress(); console.log('address', address.address); console.log('secret', address.secret); Support If you find this article is helpful, it would be greatly appreciated if you could tip XRP to the address below. Thank you!

JavaScript

1 min read

JavaScript

1 min read

Hideyoshi Moriya

Hideyoshi Moriya

174 Followers

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech