[Ethereum] How to compile .sol file from the command-line


How do I compile a solidity file (e.g. 05_greeter.sol) from the command-line into bytecode?

Without using IDE such as Mix.

Best Answer

Instructions are well documented here, the steps would be

  1. Make sure solidity is recognised by your geth installation eth.compile.solidity("")
  2. Let us take this simple contract source: source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
  3. Compile it contract = eth.compile.solidity(source).test
  4. Deploy it

Compile .sol files directly

See How to load Solidity source file into geth. Or you can use tools like Truffle to deploy it. In truffle you can create a contract and deploy it via commands.

Related Topic