Skip to content

Web3 Provider

Connecting using a Web3 Provider actually establishes a connection to a software outside of the browser. Like you'd connect to a database. Or to any other API. It's either a RESTful interface or a WebSocket interface. And behind that interface sits a blockchain. This can be Go-Ethereum, Hyperledger Besu, Nethereum - or - Ganache for Development.

Let's start with Ganache!

Download and Install Ganache

Go to https://www.trufflesuite.com/ganache and download Ganache for your Operating System. I am downloading it for Windows for this Lab. But there are also versions for MacOS and Linux. There's a UI Version and also a CLI (Command Line Interface) Version.

Run through the Setup Wizard and install it for your operating system.

Start Ganache

If you start ganache, it will ask you if you want to do a quickstart or actually start with a workspace. For now it's safe to say: We do a quickstart.

This will create 10 accounts and assign each 100 ether. The accounts are unlocked. All is ready! 🧑‍🚀

Ganache is now a Blockchain and a Wallet. Two in one. Anyone can connect to it using a Web3 Provider Method either via http RPC or WebSockets.

Pay attention to the RPC Endpoint:

Connect Remix

From the Environment Dropdown select now "Web3 Provider":

A new Popup will appear, and enter the RPC Server URL from Ganache. Pay attention to the Port number:

Your Accounts from Ganache should popup in the Accounts-Dropdown:

Deploy to Ganache

Now let's see what happens if we hit the Deploy Button:

Have you seen how fast that was? 🏎️

Now you have the benefit of two things: An actual blockchain node, but fast like a development network.

Going forward it’s probably best to use either the JavaScript VM or Web3 Provider with Ganache. The choice is yours, whatever you prefer. For ease of use, I'll use the JavaScript VM throughout the rest of the Solidity explanations.


Last update: April 17, 2021