Are you interested in blockchain development but you don’t know where to begin? In this series we will get started with developing smart contracts on the Ethereum blockchain. Your first step in becoming a Ethereum developer.
The goal of this first post is to get started with a local blockchain that we can make transactions too. There are a lot of ways we could proceed but we choose specific tools to get started fast. Read more about these trufflesuite tools here.
We will assume basic knowledge on blockchain technologies, Ethereum in particular. If you are totally new to the subject start on the basic concepts first. Like on the Ethereum beginners resources page here.
Ganache is a local ethereum blockchain so we can test our smart contracts. To install it go to the ganache site here and follow the installation instructions. Create your workspace or do the quickstart and you see this:
We see that we got 10 addresses with all 100 ETH in them. We can also see blocks, transactions and contracts but of course they are all empty.
We now want to do transactions between the accounts. We do this in the same way we would in the Main Ethereum network. Let’s install the Metamask chrome extension from here. With Metamask you can connect to the blockchain with a specific account and sign transactions.
The fist time you sign in to Metamask you are given a seed phrase that you have to remember yourself. It can be used to open all your metamask accounts in another browser or if Metamask is somehow uninstalled from your current browser.
After you signed in your setup is to choose the network you want to connect to in the network dropdown:
You probably don’t see Ganache as a possible network. To add your local network just choose Custom RPC and fill in the location you can find in the Ganache home screen:
Now you can choose the account you want to use from the account menu (the colourful circle in the top right).
Or add a new one with Import Account. You will be asked for the private key of the account:
For our local Ganache accounts the private key can be found by clicking on the key icon on the right side of the screen. A popup will show the information.
Note that this is a test account and already deleted. Never show your private key to anyone!
You are now ready to make transactions on your local Ethereum network. In Metamask, logged in as a local account press Send. Paste in the address of the account you want to send the ethereum too. Now fill out the amount you want to send and the transaction fee (more on transaction fees and gas watch this video).
Click Next and Confirm the transaction. The account balances will be updated in your local network.
Click around in Ganache and see that more things have changed or are created lik Blocks and Transactions in those specific tabs. We have covered a lot and we met our goal of creating a local Ethereum setup.
Hopefully you can now run a local Ethereum blockchain using Ganache and make transactions using Metamask like a real Ethereum developer. Happy blocking!