Solidity Development: Setting up environment
Nowadays, everything related to crypto-world is becoming more and more popular. Bet you also thought about launching your own successful ICO with million’s investments. Then, as we know, there is no gain without pain. But let’s make development of smart contracts not as painful as it could be. Choosing the right development kit and setting up environment— is a first step to success. In this article we’ll consider the most popular solutions for starting up your decentralized app, such as:
- Remix IDE
- Intellij-Solidity Plugin + Truffle + Ganache
- Solidity Extension for Visual Studio + Blockapps-bloc
New to trading? Try crypto trading bots or copy trading
Remix IDE
Remix — is a web-based IDE for writing, deploying and running Solidity smart contracts. For now, it’s one of the most featured IDE for smart contracts. After opening the Remix website you’ll see something like this:
Remix offers you out-of-the-box ready solution for decentralized app development. You don’t have to install any plugins or modules, just open the browser and start coding. Everything else is already done for you.
Pros:
- Code highlighting and analysis
- Terminal with integrated JavaScript interpreter and the
web3
object - Running locally stored files
- Ability to run transactions, deploy and compile smart contracts
Cons:
- Works only in web browser
- Clearing of LocalStorage will remove all of your files (there is workaround with using RemixD
Intellij-Solidity Plugin + Truffle + Ganache
Intellij-Solidity — is a plugin for Itnellij-based IDEs such as Webstorm, PhpStorm, PyCharm etc. This plugin offers syntax highlighting, code formatting and autocomplete for Solidity files. Although, it doesn’t provide any solutions for compiling and deploying contracts.
For compiling and deploying we could use Truffle Framework with Ganache CLI.
Truffle Setup
Firstly, you have to install Truffle globally using npm package manager:
npm install -g truffle
Then you have to create a new directory for your project and go into it (directory has to be empty):
mkdir MyFirstSolidityProject
cd MyFirstSolidityProject/
And the last thing that we have to do for now is to init truffle in our project directory:
truffle init
After initializing truffle in our project directory, we’ll get such files generated:
We will discover why do we need these files in the next chapter. For now, we’ll just add some code to our truffle.js
file to make it looks like this:
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
}
}
};
Here we specified environment, called development
and running on 127.0.0.1:7545
. We’ll use it for deploying our contracts to the local Ethereum network.
Ganache CLI Setup
Now we have to install Ganache CLI package globally with npm package manager:
npm install -g ganache-cli
Ganache will run the local instance of Ethereum network on your machine, what may be useful in development and debugging. We have to run ganache on the port specified for our development environment (7545). This could be done by the next command:
ganache-cli -p 7545
After that you’ll see the list of generated test accounts addresses, their private keys and mnemonic phrases for the wallet
Wrap Up
Now we have local network up and running, so we can compile and migrate our project to that network. For doing this, we have to run the following commands:
truffle compile
It’ll generate json file for our contracts under ./build/contracts
directory. Then we will migrate this data to the network using development
environment:
truffle migrate --network development
Pros:
- Can be used in many modern IDE’s without breaking previous settings
- Supports goto declarations, code completion, syntax highlighting
- Provide file templates for new generated contracts and libraries
- Truffle and Ganache provides a big variety of project setups with React, Redux, Authentication etc
Cons:
- Intellij-Solidity plugin is in alpha stage yet, so it could have some bugs
- A lot of actions has to be done manually for setting up compiling and deployment process
Solidity extension for Visual Studio + Blockapps-bloc
Solidity extension enables smart contract development in Visual Studio IDE. It allows you to start a new project for your decentralized app with everything set up.
Furthermore, this extension requires installing of blockapps-bloc
package. This package allow you to run local Ethereum network (like ganache-cli).
Blockapps-bloc Setup
Firstly, we have to go to our project directory and install blockapps-bloc
package using npm package manager:
npm install blockapps-bloc
Then we have to initalize this module with name
, username
and apiUrl
on your choice. You’ll be prompted to fill that info after running the following command:
bloc init
After that, let’s install required npm packages and start bloc
package:
npm install
bloc start
Now we have server running on default 8000 port. VS extension will use this server by default. You can check or change extension properties in Visual Studio under project properties section:
Pros:
- Ability to setup multi-project applications with ASP.NET or Node.js
- Ready-to-use application templates
- Provides compiling and deploying of smart contracts
Cons:
- Needs some additional packages installation (blockapps-bloc)
- A lot of issues from users, related to expired certificates that could make extension unavailable for some time
Conclusion
All in all, we’ve discovered the most popular solutions for setting up your environment and starting developing smart contracts on Solidity with ease. I hope you’ve found something appropriate to your needs. In the next chapter we’ll write our first smart contract and will deploy it to the local network.
Join Coinmonks Telegram Channel and Youtube Channel get daily Crypto News
Also, Read
- Copy Trading | Crypto Tax Software
- Grid Trading | Crypto Hardware Wallet
- Crypto Telegram Signals | Crypto Trading Bot
- Best Crypto Exchange | Best Crypto Exchange in India
- Best Crypto APIs for Developers
- Best Crypto Lending Platform
- An ultimate guide to Leveraged Token