This video is available to students only
Using Websockets with Web3
Web3 can connect to our Ethereum node using Websockets. Websockets will let us keep a two-way connection open between our browser and our client. This means that our geth node will be able to push real-time updates to our browser.
We'll use this on our page to instantly draw any pixels that are purchased.
In order to use Websockets with geth
, we need to add some parameters to our geth
command. They look like the flags we used for rpc
only they begin with ws
. Here's the command, which you can copy and paste from the video notes:
1
./bin/geth --datadir=./datadir --nodiscover --rpc --rpcapi "db,personal,eth,net,web3,debug" --rpccorsdomain='*' --rpcaddr="localhost" --rpcport 8545 --ws --wsapi "db,personal,eth,net,web3,debug" --wsorigins='*' --wsaddr="localhost" --wsport 8546 console
This page is a preview of Million Ether Homepage