-
Notifications
You must be signed in to change notification settings - Fork 0
Wallet
Ethereum Wallet to understand how does a transaction occur, how does mnemonic work, and how do accounts get created.
- git clone https://github.com/bansaltushar014/Ethereum_Wallet.git
- npm install
- npm start
- Web3
- React
Application starts from the app.js file where it loads a navbar having "Import Private", "Import Seed" & "Create Account".
-
Import Private This is for where the user can import the account with the help of the private key. Users need to enter private keys and the account will get imported.
-
Import Seed This is for where the user can import the accounts by giving the mnemonic. As the mnemonic is given in Ganache and after entering the same mnemonic in Metamask, the user can import all the accounts.
-
Create Account Users can create a random account as we get in ganache.
This file has the setup of web3 where it is done with ganache. Before running the application, the developer should have ganache to be running at port 7545
. In this file, web3 can be configured with the ropsten infura. Developer needs to visit here and create new project and get the project id.
This file is to import the account with the help of the private key. web3.eth.accounts.privateKeyToAccount
is used to get the account and web3.eth.getBalance
to get the balance of the account. Transaction are happening with the help of the sendEth
file.
Here accounts are imported from the entered seed and the function generateAddressesFromSeed
shows how it is done. In this function the entered mnemonic is from Ganache and its wallet HDpath is m/44'/60'/0'/0/
. For more understanding about the path visit this. Transaction are happening with the help of the sendEth
file.
In this file, createAccounts
creates the accounts. It generated the mnemonic with the help of bip39.generateMnemonic()
and then follow the same process as generateAddressesFromSeed
inside importSeed.js
This file has sendTransaction
which helps to create transactions. It takes the sender's address, sender's private key, receiver's address, and the amount that needs to be sent. Transactions happen in few steps.
- Build the transaction
- Sign the transaction
- Broadcast the transaction
- Do the setup in your local machine
- Got any enhancement idea? Create issue :)