To compile our Solidity smart contract, we need a compiler. The main solidity compiler is
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
# 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
We can compile our contract by typing this:
solcjs --bin counter.sol
And let’s take a look at the output:
ls cat counter_sol_Counter.bin
Well, that’s not exactly enlightening, but this is a hex encoded version of the bytecode of our script. There are other ways of viewing the opcodes that are clearer, but we don’t need them right now.
Deploying in Geth
Start geth like did in the earlier video:
./bin/geth --datadir=./datadir console
The first thing that we need to do is assign our contract hex code to a variable. It will help if you have two tabs open. I have geth console in one, and a shell in the other.