This video is available to students only

How to Write and Compile a Solidity Smart Contract

In this video, we'll write our first Solidity smart contract

Creating .bin

To compile our Solidity smart contract, we need a compiler. The main solidity compiler is solc.

It's written in C++ and it's a good idea to use a formal release build for your production smart contracts.

That said, getting the C++ version of solc installed can sometimes be a pain. My recommendation is that you install solc before you deploy your first contracts on the production network, but for now, we can use the JavaScript version solcjs.

# this installs solcjs (not the c++ version of solc)
npm install -g solc

Solcjs's core code is generated using Emscripten to convert the C++ version of solc to JavaScript. This means it will work just fine, but know that the command-line options are different.

We can compile our contract by typing this:

solcjs --bin counter.sol

And let's take a look at the output:


This page is a preview of Intro to Programming Ethereum ĐApps

Start a new discussion. All notification go to the author.

Chat with your educational course! Ask any question about course material.