So the end goal is to create our own Android/iOS Ethereum ERC20 wallet. This will eventually become a tri purpose wallet storing Ethereum, Fusion, and Wanchain RC20 tokens repsectively.
Step 1 in creating a wallet is to actually generate the private/public key pair and storing these safely. This quick article will demonstrate how to accomplish this task.
Libraries used include ethereumjs-wallet, bip39, and ethereumjs-wallet/hdkey.
Line #6: First we generate the mnemonic phase from bip39 (this is just a string of 12 different words. At this point, ask the user to save these 12 words on a paper wallet.
#9: We create our hd wallet from the mnemonic seed.
#12: We set the standard hd path to /0, so as to be compatable with Metamask.
#13: We create the actual wallet.
#16: We create the V3 compatible JSON keystore file that is password protected (this file we will store locally and access via the password).
And that’s it, it is that simplistic to create your own Ethereum based wallet. With just the few lines above we already have our own Ethereum compatable wallet.
Next, we want to be able to create and verify a transaction
#24: Retreive the private key from the JSON keystore we created.
#26–31: Create the transaction object using ethereumjs-tx
#33: Sign the transaction.
#43–49: Validate the just created transaction to ensure it matches the transaction payload we are expecting.
Again, it’s that simplistic. So in less than 50 lines of code, you can create your own wallet, create a transaction and sign it, and then using infura you can post it to Ethereum.
This was supposed to be the hard part, so I’m not exactly sure why some mobile app cryptocurrencies out there are valued at $350m and $60m USD respectively. Throwing a UI ontop of the above won’t take more than a week to do.
Next step, sending the transaction, polling for transactions, and possibly implementing a light client in mobile. For phase 1 development I think I will go the Metamask route.
That easy people, hope the above helped.