5

I'm using Geth 1.4.5-stable along with Solc version 0.3.5-0 both on Linux. It is run on a Digital Ocean server. I have a fully synced testnet chain and I'm trying to compile contracts from within the Javascript console.

Steps I've taken:

A. I added Solidity to PATH with export PATH=$PATH:/usr/bin/solc

B. I connected to the console in an another shell window with the following command:

geth --rpc --rpcaddr localhost --rpcapi "eth,net,web3,admin" \
  --solc /usr/bin/solc attach ipc:/home/physes/.ethereum/testnet/geth.ipc

This seems to work fine, and I can use other RPI API commands.

C. I was testing out a Greeter contract.

i)

var greeterSource = 'contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }'

ii)

var greeterCompiled = web3.eth.compile.solidity(greeterSource)

At this point it fails, and I get:

solc: exit status 1
Unknown exception during compilation.
at web3.js:3119:20
at web3.js:6023:15
at web3.js:4995:36
at <anonymous>:1:23

What am I doing wrong?

  • You should not directly /usr/bin/solc to PATH, but that should not cause your error – Ismael Jun 23 '16 at 20:34
  • Ok, I don't think that's what caused it (also tried without the --solc flag). Possibly important context: this is being run on a Digital Ocean server. It works fine on my local Geth instance. – Physes Jun 23 '16 at 20:45
  • Are you using the same version in both (local and remote)? The last version I worked with no problemes was geth 1.3.6. Probably you should report the issue in github. – Ismael Jun 23 '16 at 20:57
  • I've just tested the new version of solc and it is working. – The Officious BokkyPooBah Jul 10 '16 at 7:42
3

This is a bug in the Solidity compiler.

Here is a quick test:

user@Kumquat:~$ echo '' | solc
Unknown exception during compilation.

See eth.compile.solidity fails with solc version 0.3.5 #2703, which links to Exception on compilation from stdin #651.

And the issue Fix crash for input from stdin. #652 has been fixed, but will take an unknown (hopefully short) amount of time to make it into the repository packages.

This is the code change for the fix - Fix crash for input from stdin. #652 - Files changed.

You can try installing the previous version of solc.

Or one workaround offered in the first link above:

For anyone who wants a temporary workaround, you can clone this repo: https://github.com/mattdf/solidity-static and do a build in docker, then copy the solc file to your install. It makes a statically compiled build of solc so it should work on most distros.


Update 10/07/2016

I have installed the latest version of solc and it is now working correctly:

user@Kumquat:~$ solc --version
solc, the solidity compiler commandline interface
Version: 0.3.5-0/RelWithDebInfo-Linux/g++/Interpreter

And testing for the exception in the previous version:

user@Kumquat:~$ echo '' | solc
user@Kumquat:~$ 
  • Great answer. One similar issue- on my local machine with the older version of Solidity that works, a problem I'm having is that there is no feedback. I'm using geth attach etc. etc. with the blockchain in another window, and while it accepts the javascript input, there is no response and I get no contract mined! at the end. Is this an issue with attach? – Physes Jun 25 '16 at 19:25
  • Just confirming - is your account is unlocked using --unlock 0? See ethereum.stackexchange.com/a/6028/1268 . – The Officious BokkyPooBah Jun 26 '16 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.