Running an Ethereum node on a phone
Whenever you are using a cryptocurrency to transact with someone, you are trusting the node to provide you with correct details and properly executing the trade. When using Metamask, by default you use the Ethereum node provided by infura. In general they are not rogue and will not 'scam' you, but for several reasons you might want to run your own node.
These reasons:
- Infura (or some other provider) might be legally asked to not server users in your region. This supposedly happened with users in Venezuela. But this yields massive power, where you could just not be able to send your Ethereum or make it a hassle.
- Nodes might be hacked and exploited, reporting you wrong details and so forth.
- There is a massive trust you need to keep with these node providers (be it Coinbase wallet, Metamask, etc.) kinda defeating purpose of not relying on a third party.
'Solution'
Just run your own node. This unfortunately is quite difficult for most people. Ethereum requires 500 GB+ in storage, good internet connection and a decent machine. People don't have that nor do they carry it with them. Ethereum hence provides an option with its geth client called “light” sync mode. A light node basically, stores the headers of all blocks. It can verify the validity all of the data against the roots in the chain. For everything else (like requesting data, sending a transaction, executing a smart contract, signing a transaction, etc) it contacts a full node and asks the node to do it for you. If a node goes rogue, then based on the changes of Merkle tree, it will invalidate the chain.
This basically provides you with ability to personally verify whatever these node providers are saying, with several sources of information and use the chain. With zK-SNARKS this could be taken to a whole new trustless model, which is already being researched on.
You can simply run a light node on your PC, without a lot of problem. But, what if you run it on your phone...
Running Ethereum light node on an android phone
- Install termux from fdroid on your Android phone. If you are using a closed platform iOS, well get an open one.
- To make your life easier, you could access your phone via SSH from your laptop and run from there. (This is mostly for my reference though, could be useful) details
# Installing openSSH
pkg install openssh
# Get the username
whoami
# Setup a password
passwd
# Get IP address of your phone
ifconfig
# Run openSSH server
sshd
# It will be running and accessible on <ip-address>:8022 by default
Install geth Termux maintains a latest packaged copy of geth, which you can install simply by
pkg install geth
Run the light node
geth --syncmode "light" --http
details for CLI options
geth will start syncing the node, although it won't take time and will consume way less space. You can now add http://127.0.0.1:8545 as a new RPC endpoint on your Metamask app on phone. One could also use something like fast reverse proxy to access it remotely by tunneling it via a VPS.
ummm...
Here you are still trusting the nodes from where your light node is syncing data from to provide you with correct data. Very often then not only a few nodes will be shown connected and those which you are syncing with. So verifying the state is still important, but this reduces the chances of any of above mentioned problems.
#crypto #tutorial Thanks to Krish and Aryan for helping with this post.
If you found any typo, wanna reach out, or get in touch – Please email me at hi@vimarsh.info