Creating a Usable DApp from Ethereum Without a Full Node Wallet
In order to use a DApp that works in Ethereum, you need a wallet software. Through the wallet software, you can manage your account and call the Smart Contract’s function. In a public blockchain such as Ethereum and Bitcoin, you cannot trust any other user but yourself. Thus, users of a DApp must have the entire history of the blockchain and be able to personally verify the Smart Contract.
However, these type of models are not used for normal users’ DApp. To require a download of that exceeds 100GB just to use DApp’s services is overkill. Even the most demanding movies or games currently do not exceed 100GB. Requiring 100GB of data just to use a simple DApp is unquestionably inefficient.
CryptoKitties and MetaMask
This is why DApps such as CryptoKitties recommend the usage of MetaMask. It is a lightweight wallet that can be installed as a web browser’s plugin. However, this wallet is not really a proper Ethereum wallet. MetaMask does not hold the block’s history. It trusts other Ethereum nodes that exists externally. What MetaMask itself does is to manage the private key locally, and sign the transaction and send it to a trustworthy Ethereum node.
Just as the example discussed above, CryptoKitties utilizes the MetaMask, and shows us that a DApp for the typical user does not need to hold onto the entire history. All it needs is a private key management system and a functionality that allows it to sign and send the transactions that it calls.
Hardships in the Development Environment
However, if you were to look up methods on how to make a DApp for Ethereum, most introduce ways that depend on the user’s wallet. Even Web3’s library’s basic functions(send transaction, using Smart Contract) can be only used in situations where the wallet manages the private key.
DApp developers prefer a situation where the developer operates the full node wallet, and the users hold onto their private key only and connect to the developer’s wallet. However, Ethereum wallets Geth and Parity do not offer this kind of functionality. When it comes to Geth or Parity, the program itself handles the private key.
This does not, however, mean that there is no other way. In the web3 or JSON RPC standard, there exists a function called sendRawTransaction. This function is an API that accepts a signed transaction and processes it. With this function, the user can send transactions without having to reveal his/her private key while using a wallet, such as Geth or Parity.
If Working With JavaScript
There is a library called eth-lightwallet created by Consensys. With this library, it is possible to personally manage the private keys through a web browser. Furthermore, it is possible to use those private keys for creating signed transactions.
With transactions created this way can be sent to the full node using web3.eth.sendRawTransaction. This method allows users to use DApp without having to download large amounts of data.
If Working with C#
Nethereum is the C# version of web3 library. The unique part of this is that it uses sendRawTransaction by default. When using the Account class and either sendTransaction or the Smart Contract’s function is called, it automatically uses sendRawTransaction. If ManagedAccount is used, it is possible to access the connecting account’s wallet, just like web3’s default behavior.
How About Security?
This method where the DApp’s user does not operate the full node has weaker security than if the user does operate the full node. This is because the user cannot tell whether the full node that he/she is connected to is giving false information or not. However, I believe this is not a very big problem. Even the most successful DApp, CryptoKitties, supports MetaMask as their recommended Ethereum wallet. There is always a bit of a tradeoff for comfort.
Conclusion
Every Dapp tutorials assume that all data was stored in the user’s full node wallet. However, with sendRawTransaction, the user does not have to carry such a heavy wallet, and still make an exceptionally functional DApp. (For the Korean version of this article, click here).
Last but not the least! Now it’s time to enjoy GoCryptobot.
Download from here :)
- App Store: https://apple.co/2KbMipn
- Google Play: https://bit.ly/2K5tYhx