Technical Guide | Ethereum Wallet Development: Generate Account Address, Private Key, Keystore, mnemonic

First, use web3 to connect to the Ethereum network (test network, main network)

1. What is web3

Web3 is a module provided by Ethereum to connect to the Ethereum blockchain, allowing you to interact with local or remote Ethereum nodes using HTTP or IPC, which includes almost all the features of the Ethereum ecosystem. The web3 module is primarily connected to the RPC layer exposed by Ethereum. Developers use web3 to connect to the RPC layer and can connect to any node that exposes the RPC interface to interact with the blockchain. Web3 is a collection library that supports multiple development languages ​​using wbe3. The JavaScript API is called web3.js, and web3.py, web3j, web3.js will be the focus of our wallet development project.

  • Web3.eth: Used to interact with the Ethereum blockchain and smart contracts. Web3.utils: Contains some helper methods.
  • Web3.shh: P2P and broadcast for protocol communication.
  • Web3.bzz: Bzz module for interacting with the group network.
  • Github address: web3.js
  • Web3.js development documentation::web3.js

2. Instantiate the web3 object

Web3 needs to interact with the node, you need to create a web3 object, let's see how to create it.

According to the API, we need to specify the node address, we will ws://some.local-or-remote.node:8546

The network of the connected Ethereum is determined by replacing the address of another node connected to the Ethereum network. So what is the address of the node connected to the Ethereum network? Here we need to use infura.

3. Get the node address connected to the Ethereum network

Infura provides the public Ethereum main network and test network nodes. After registering on the infura.io website, you can get the addresses of each network. Please follow the steps below to get the address.

The first step : open the infura website address: https://infura.io/dashboard, use the email to register and log in as follows:

Step 2 : Click on the “create new project” button labeled above to create a new project. Then pop up the following box, enter the project name in the input box, such as "MyEtherWallet", and then click the "create project" button to create.

Step 3 : Then the following interface will be displayed. Click the checkbox in the figure below to see the node addresses of the main network, Kovan test network, Ropsten test network, and Rinkeby test network.

Step 4 : Select Kovan to test the network, then copy the address and you will get an address like this:

Https://kovan.infura.io/v3/d93f…cd67, as follows.

4. Connect to the Ethereum Kovan Test Network

Now replace the copied address with the address of the instantiated web object, as follows

Connect to the Ethereum main network and the Kovan test network, just copy the address of the main network node to instantiate web3. Since the transaction on the main network requires cost, we develop based on the Kovan test network, and then switch to the main network after the completion of the development. In the project source code we developed, I encapsulated the code for the web3 instance into the getweb3() method of the myUtils.js file for unified calling of the entire project.

Second, get the address, private key, keystore, mnemonic

1. Create an account using web3

To create an account, you need to use the following API of web3.js.

API

Web3.eth.accounts.create([entropy]);

Image.png

Image.png

Image.png

Image.png

2. router.js

Bind the page that created the account to the interface submitted by the form to the route.

Image.png

Image.png

Image.png

Project source code Github address

Copyright statement: The copyright of the article in the blog belongs to the blogger. It is forbidden to reprint without authorization. Please contact the author (WeChat: lixu1770105) to obtain the consent and indicate the source.

This article address: https://chaindesk.cn/witbook/1/12


Wish code (ChianDesk.CN) – the story of connecting each programmer

Technology upgrade, rapid transformation, please pay attention to WeChat public number: wish code

We will continue to update Blocking; if you have any questions or suggestions, please contact us!

Share:

Was this article helpful?

93 out of 132 found this helpful

Discover more

Blockchain

EOS daily support appears, but it also needs to pay attention to the market dynamics

Author | Hash sent analysis team 🚀 Bitcoin Price Correction: Will BTC Bounce Back?JPMorgan Analysts Doubt Bitcoin’s F...

Blockchain

Getting started with blockchain | Can Google's latest quantum computer crack bitcoin? Is the wallet safe?

Recently, “ Google’s claim that it has achieved quantum hegemony ” has been screened in various ...

Bitcoin

💥 Bitcoin ETFs See $2.2 Billion Inflows, BlackRock Dominates 💪

Bitcoin ETFs saw a significant increase in investment with net inflows of $2.2 billion from February 12-16. BlackRock...

Blockchain

If the Indian encryption ban is approved, 40,000 BTCs will enter the market.

Zebpay, once the largest cryptocurrency exchange in India, was forced to migrate overseas in the country last year in...

Blockchain

Amazon, Tesla and Bitcoin

Author: Edward Iftody Translator: Hirakawa Source: Blockchain Outpost Introduction: If I made a reasonable-scale inve...