Solidity, “hello world” with the Blockchain language

Solidity

The main and most commonly known language to write smart contract in Ethereum is Solidity. It was designed in 2014, a few months before the official launch of the Ethereum Blockchain, and is now used for the Ethereum public Blockchain, as well as for private Blockchain such as Hyperledger. As we said in the first article of this series, it’s a statistically-typed programming language that runs smart contract on the EVM, Ethereum Virtual Machine.

The Ethereum Virtual Machine

On the Ethereum Blockchain, a smart contract is a simple Ethereum address with the special capability of running EVM bytecode when receiving a transaction, allowing them to perform calculations and further transactions.

  • Call Data: the data associated with a transaction. It usually contains a 4-byte method identifier followed by serialized arguments;
  • Stack: the EVM maintains a stack of uint256 used to hold local variables, function call arguments and return addresses;
  • Memory: an array of uint8s used to hold processing data while the contract is being executed — this data does not persist across consequent transactions
  • Storage: a persistevi associative map, with uint256s as keys and values, the contains all contract fields and mappings.

Choosing the IDE

To write code and test smart contracts, a plethora of IDEs is available, both as online and offline applications. We will provide a complete list of all known IDEs to develop Solidity as of today, and then we will dive into the most simple to use.

Online

  • Remix: Built-in static analysis and test Blockchain VM;
  • Ethereum Studio: Built-in browser Blockchain VM, Metamask integration (one-click deployments to Testnet/Mainnet), transaction logger and live coding;

Offline

  • Atom: editor with Atom Solidity Linter, Etheratom, autocomplete-solidity, and language-solidity packages;
  • VIM Solidity: VIM syntax file for Solidity
  • Visual Studio Code: Visual Studio Code extension that adds support for Solidity
  • IntelliJ Solidity Plugin: open-source plug-in for JetBrains IntelliJ Idea IDE (free/commercial) with syntax highlighting, formatting, code completion;
  • YAKINDU Solidity Tools: Eclipse-based IDE, featuring context-sensitive code completion and help, code navigation, syntax coloring, build in compiler, quick fixes and templates;
  • Eth Fiddle: allows you to write, compile and debug the smart contract. Features sharing and search of code snippets.

First steps with Ethereum Studio

Ethereum Studio is available on studio.ethereum.org. Visiting the website will pop-up a banner that instructs the user to choose from a set of smart contract templates: for now, we will choose the ‘Hello World’ smart contract template, that allows us to understand the basics of development without writing specialized code.

An ‘Hello World’ template on Ethereum Studio — studio.ethereum.org,
  • Explorer: in the first pane, one can view the usual file hierarchy. At the top of the explorer, one can view the blockchain network on which the contract will run (the default is the Browser blockchain, that is a fake blockchain to run tests on) and the contract address that’s associated with it. Notice that it’s only possible to deploy one smart contract per address.
  • Text: where it’s possible to write the actual code
  • Simulator: a visual simulation of the functions of the smart contract or, in the case of smart contracts running at the core of an app, the rendering of the app (much like Xcode).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Codemotion

Codemotion

63 Followers

We help tech communities to grow worldwide, providing top-notch tools and unparalleled networking opportunities.