Using Ethereum Wallets (part 2 of 2)
Introduction
In the previous article we described the basic principles behind an Ethereum transaction. More specifically we illustrated the means of communication between an externally owned account (EOA) and a smart contract. We also explained the purpose and use case for Ethereum wallets and finished the article with a step-by-step instructions to setup a MetaMask wallet and use it within the Token Lounge DApp.
In this part we will present MyEtherWallet; an alternative to MetaMask wallet. We will do that by showing an example of a use case within the Token Lounge pool.
My Ether Wallet
My Ether Wallet(MEW) is a very popular web-based Ethereum wallet. It is more powerful than the MetaMask wallet, but it comes at the expense of a not very intuitive user experience.
Unlike MetaMask, MEW does not store the private keys on the machine nor on any centralised server. It does support various ways of initiating a new wallet, including creating a new wallet, reusing and existing mnemonic passphrase, uploading keystore file and some other options (you can even use MetaMask). You can also use a cold storage, such as Ledger Nano S and Trezor, to sign the transactions. In essence, it is quite flexible with regards to the key management options. However, it makes it difficult to create the transactions in the first place.
Let’s dive into a specific example and see how we can sign and send a new transaction In the previous part, we showed what a transaction data structure looks like and we briefly explained the data
attribute. In MEW the client is expected to use that encoded piece of data explicitly, when initiating a new transaction. Although, the process is well documented here, we cannot expect anyone to perform that in a manual manner. MEW does help users with that process, but it expects the knowledge of two piece of data:
- The contract address
- The Abstract Contract Interface.
- Gas Limit
Each piece of information is available via the Token Lounge DApp.
Using MEW
Let’s go step by step and show how to send a transaction to withdraw a contribution.
Step 1
Open https://www.myetherwallet.com
Step 2
Goto the Contracts Tab https://www.myetherwallet.com/#contracts
Step 3
Copy the pool address from the Token Lounge DApp and paste it in the Contract Address field
Step 4
Copy the Abstract Contract Interface and paste it into the ABI/JSON Interface and click on the Access button.
Step 5
The ABI is a JSON structure that describes the interface of the contract including the function names and parameters.
From the above dropdown select the withdrawEther.
Step 6
Select how you want to sign the transaction (check the discussion above). For the sake of simplicity let’s say you want to use MetaMask for that purpose. Select on the MetaMask option and click on the Connect to MetaMask button.
Step 7
Click on the Write button and type theGas Limit that you can see in Token Lounge DApp.
Note! the Gas Limit might be different based on the transaction you select, so make sure you copy the correct value from the Token Lounge UI.
Step 8
Confirm that you want to use MetaMask to sign the transaction.
In the above figure you can see the Raw Transaction field. If you recall from the previous article, this the transaction data structure that is signed and send to the Ethereum blockchain.
Step 9
Sign the transaction using MetaMask by clicking submit.
That’s it. The transaction is sent to the network!
Conclusion
In this article we described how to use MEW to call a specific function of a smart contract. This approach is alternative to using directly the Token Lounge DApp and sign transaction via MetaMask. However, it is a more tedious process and it needs a bit of practice to get used to. Thus, we strongly recommend users to make full use of the DApp user experience and send transactions directly from the Token Lounge Web-base interface.