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.
https://github.com/ethereum/solidity
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 lesson preview is part of the Intro to Programming Ethereum ĐApps course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to Intro to Programming Ethereum ĐApps, plus 90+ \newline books, guides and courses with the \newline Pro subscription.
