Make sure to have the latest version of solc
. Install documentation.
Here's how to install on macOS:
brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
brew linkapps solidity
Run solc
command to compile and save results to an output directory:
solc --bin --asm Example.sol -o build/
Generated files:
.
├── Example.sol
├── build
│ ├── Example.bin
│ └── Example.evm
Version tested with:
$ solc --version
solc, the solidity compiler commandline interface
Version: 0.4.18+commit.9cf6e910.Darwin.appleclang
Here are instruction for installing and using solcjs
:
npm install -g solc@latest
Call the solcjs
command with flags and smart contract filename:
solcjs --bin --abi Example.sol
It'll generate the corresponding files based on the flags you passed:
.
├── Example.sol
├── Example_sol_Example.abi
├── Example_sol_Example.bin
Version tested with:
$ solcjs --version
0.4.18+commit.9cf6e910.Emscripten.clang
Example solidity file used in all examples:
pragma solidity ^0.4.6;
contract Example {
function add(uint a, uint b) returns (uint) {
return a + b;
}
}