Recently I encountered some unpleasant lags and outages with some of the publicly available RPCs for xDai. So I looked up how to run my own node on a local machine and connect Metamask directly to this node.
Now I interface smoothly with the xDai chain. With some help from now you too can become a noderunner!
According to xDai docs, it needs to be
Get it done.
It may look like this one:
Find the little guy.
./openethereum --chain xdai --no-periodic-snapshot --jsonrpc-port=8545 --jsonrpc-cors=all --jsonrpc-interface=all --jsonrpc-hosts=all --jsonrpc-apis=web3,eth,net,parity --ws-interface=all --ws-apis=web3,eth,net,parity,pubsub --ws-origins=all --ws-hosts=all --ws-max-connections=10 --max-peers=100
If you’re on Windows your binary will be called
Now wait for the ~28 GB of blockchain data to be downloaded.
The program may throw some errors, especially in the beginning, but these are mainly related to running a real validator node which we’re not doing here.
Once it starts syncing, it’ll look like this:
Syncing #14889406 0x6a10…e8d8 42.97 blk/s 204.1 tx/s 34.6 Mgas/s 76+ 2566 Qed #14892053 4/25 peers 5 MiB chain 132 MiB db 41 MiB queue 8 MiB sync RPC: 0 conn, 3 req/s, 327 µs`
And once you’re completely sync, it’ll look like this:
Imported #14892107 0x7963…1c14 (7 txs, 2.59 Mgas, 48 ms, 3.73 KiB) 4/25 peers 6 MiB chain 131 MiB db 0 bytes queue 7 MiB sync RPC: 0 conn, 2 req/s, 278 µs```
Now you’re ready to switch over to your brand new RPC. Fire up Metamask, go to Settings Networks, then Add Network.
Your next transaction will pass through your node looking something like this:
Transaction mined (hash 0x0000000000000000000000000000000000000000000000000000000000000000)
- Exit the openethereum process by pressing Ctrl+C.
- Keep your node synced before using it. The main drawback of running it on your own machine is that the chain state needs resyncing after, for example, system hibernation. The RPC will still work, but it will only show the last synced state.