Compiling your contract with the solc compiler
Solidity is a high-level language and has to be compiled before being deployed to Ethereum. In this recipe, you will learn how to use the solc
command-line compiler to compile your smart contract to its binary and ABI.
Getting ready
You need to have a working installation of the solc
compiler to step through this recipe. You can also make use of the JavaScript-based solcjs
to compile solidity. These commands may not work in solcjs
and you have to follow its documentation.
How to do it...
- Consider the following smart contract,
HelloWorld.sol
, as an example:
pragma solidity ^0.4.22; contract HelloWorld { string public greeting = "Hello World"; event greetingChanged(address by, string greeting); function changeGreeting(string _newGreeting) public { greeting = _newGreeting; emit greetingChanged(msg.sender, _newGreeting); } }
- Verify your
solc
installation with the following command. It will show you all the parameters...