I’m sure many people have wondered when looking at any distributed app code or project, how do I run this?
If you get lucky, you have instructions on what to do included, you follow them and its all good..or is it? Do you know what any of those tools you just setup actually do and how they tie into the function of the app?
We’ll be looking at a few of such tools and how they help in running or developing distributed applications.
Assuming beginner knowledge in developing distributed apps, we will not be going through what a distributed app is and what it tries to accomplish. Lets go section by section and look at what goes into this workflow.
Smart Contract Programming Languages
A smart contract is deployed on the blockchain in its bytecode form, generated by an EVM compiler. Any language that provides an EVM compiler can be used to write smart contracts.
Everyone knows what this is. The most widely used language for smart contract development.
Vyper is a pythonic programming language. Also, it has a heavier focus on security along with other perks that come from pythonic languages namely simplicity and auditability. Their docs also mention that its aim is to make it ‘maximally difficult to write misleading code’ which is great.
Comparing Vyper and Solidity, in their own words, ‘It never strives to be a 100% replacement for everything that can be done in Solidity; it will deliberately forbid things or make things harder if it deems fit to do so for the goal of increasing security.’
There’s a few other languages, but these are the popular ones with the most support available. There’s also an option to write bytecode directly, if you wish to do that. If you don’t, Use Remix IDE. It supports both Solidity and Vyper.
Assuming you clicked on the link and opened up the Remix IDE, it mentions a Web3 provider. We’ll now see what that is.
Web3.js is a collection of libraries that lets you connect to ethereum nodes (participants of the network) either local or over the internet. This makes sense, as you need to test and deploy your smart contracts over networks after you write them. This enables you to use clients and test your smart contract over a network.
This is also what allows the transfer of ether and do much more on the network.
It talks to the blockchain using the JSON RPC, or ‘Remote Procedure Call’. It contacts one node of the blockchain in order to transfer data to and from the network.
But how do we get access to an ethereum node to connect to and create, edit, deploy and manage our smart contracts? We’ll look at that now.
The simpler solution that comes to mind to solve access to a network is to run your own node. This can be accomplished by something like Geth but basic blockchain knowledge tells us that to become a node, you need all the data with you, that means it carries the responsibility of downloading, storing and syncing all of the network, which might be something you would want to avoid if you just want to test your smart contract.
That is where Ganache comes in, It can be used to create a personal blockchain, without having to worry about any of the issues listed above. This is what it looks like.
As can be seen here, you have a lot of accounts at your disposal here with an initial balance in each. These can be used for deploying smart contracts and transactions among these accounts is also possible. There’s also a command line version available, if that’s more your thing.
Now you have an ethereum network at your disposal. But, what if this as well is too much work for you?
You can use Infura to access an ethereum node without having to run it yourself, and MetaMask lets you do just that.
It is a browser extension, that lets you run your distributed apps without being a part of the ethereum network. As a bonus, it lets you manage and create your ethereum wallets, and manage multiple accounts from your browser.
Another problem it addressed is of sharing your distributed apps. If you deploy your apps on a local blockchain, you need to make sure your user creates it on their end and then uses your apps. But that is not viable. For example, if your blockchain shares file links via transactions, the links created on your local blockchain would only be available to you. If you wish to connect MetaMask to a local network, it is very easy to do.
One solution is to deploy the app on the main ethereum network, but that costs real money. This cost is associated with each and every transaction. MetaMask lets you connect to test networks. These exist to provide a platform for developers to deploy their apps and provide service to the customers without having to exchange real value, making them free of cost. And if you are not a large corporation, this is probably where you want to deploy your apps.
The same apps can later be hosted on any platform and be accessed by users having MetaMask connected to their wallets in their browsers. Using faucets, the ethers used in the transaction can be easily replenished (MetaMask can also link you to the faucets).
We went through a lot of tools commonly used for the development of distributed apps and learned about their place in the ecosystem. This was supposed to be an introduction to the large amount of tools and I hope it was able to deliver some basic understanding. Each title links to either the website or the documentation of the concerning tool.
Another thing I would like to bring attention to is the Truffle Suite, it is a development environment for distributed apps. This is where Ganache comes from and it has other tools as well that might be useful.
The number of tools and resources are increasing everyday, so don’t feel limited and keep exploring, there are lots of tools out there that tackle the same problems in different ways this blog is in no way the definitive way of choosing a program, you might like some more than the others!