Ethereum Light client with React – Ko – Medium

Ethereum Light client with React  #react #ethereum #reactjs

  • { ssl_fc }frontend wwws mode http bind :443 ssl crt /etc/haproxy/certs/You Cert.pem timeout client 1h tcp-request inspect-delay 500ms tcp-request content accept if HTTP default_backend privatenetwork_backend acl is_privatenetwork hdr_end(host) -i Your domain use_backend privatenetwork_backend if is_privatenetworkbackend privatenetwork_backend mode http option forwardfor option http-server-close option forceclose no option httpclose balance roundrobin option…
  • web3 is official Javascript library for ethereum.npm install –save eth-lightwalletnpm install –save hooked-web3-providernpm install –save web3# Or you may do just npm installA bit of hackIn your Javascript file,// step 1: import web3, eth-lightwallet, and hooked-web3-providerimport Web3 from ‘web3’import lightwallet from ‘eth-lightwallet’import HookedWeb3Provider from ‘hooked-web3-provider’// step 2: you may need to…
  • It’s a bit troublesome though because every time I add new module, I need to do “npm install” at eth-lightwallet directory.Now you are ready to create UIFirst step is creating keystore or wallet with keystore.
  • # I pick the name wallet because in the original document, the term keystore is used both medhod name and generated wallet with keystore and bit confusing.let wallet# get pwDerivedKey password, (err, pwDerivedKey) = { if (err){ console.log(“err 1:”, err) } # goto step.2Step 2 is generate address.
  • # step.2: add new 3 connect to our node (rpc server) with hooked-web3-provider# step.3: prepare providervar web3Provider = new HookedWeb3Provider({ host: “https://your rpc server”, transaction_signer: wallet});const web3 = new Web3(web3Provider);Here you need hooked-web3-provider.

Light client is an ethereum client which keeps only keys. You can check accurate definition here. Traditionally in blockchain world, everyone keep same databases. That’s why we can trust entire…

Ethereum Light client with React

This is a basic way to setup Ethereum light client with private network. I will talk about 3 things.

What is light client?

Light client is an ethereum client which keeps only keys. You can check accurate definition here. Traditionally in blockchain world, everyone keep same databases. That’s why we can trust entire system. I mean we can trust at least our own data. But light client don’t keep data.

Why do light client matter?

But problem is keeping entire database is tough. When I created an ethereum wallet first time I needed to download entire ethereum database. That syncing process took almost whole day and the file size was huge. A web site said the storage size was more than 75GB in 2016 and was growing 1GB per month. This is insane and only blockchain enthusiast can keep it.

You can not run ethereum full node on mobile devices. Or normal users don’t want to keep full node on their devices anyway.

That’s why we need light clients. With light clients, user don’t need to keep ethereum node. They can just enjoy decentralized services. This is pretty cool.

How do we setup light client?

I experimented light client with my private network. Because we can develop dapps for mobile, this has a huge potential.

1. Prepare private network

You need at least 1 ethereum node. Since light client…

Ethereum Light client with React – Ko – Medium