2

I've made a fresh install of go-ethereum from source on Ubuntu and Fedora, launched it and expected to find Solidity available when doing eth.getCompilers(), but I get an empty list instead.

I have then installed Solidity explicitly, as described in the tutorial here, restarted geth, but that changed nothing. I installed the package to be available globally with npm -g and I can see the package being available if I try importing it from a console node session.

I am not using the c++ client, too, so I don't have the solc exectuable installed, but I seem to understand that it is not needed if I do the npm installation.

What am I missing? Thanks.

  • Possible duplicate of Link solc with geth problem – euri10 May 23 '16 at 9:12
  • eth.compilers return an empy list even if it's installed, see the topic just above ;) – euri10 May 23 '16 at 9:12
  • just for reference solc comes with the cpp client, not geth, but your install with npm should be ok – euri10 May 23 '16 at 9:19
  • Thanks @euri10 but I believe this is a different problem. My best guess, given that the node executable can find Solidity, is that the geth executable is not using the NODE_PATH environment variable, hence can't find the npm installation of Solidity. – Gianfranco Cecconi May 23 '16 at 9:42
2

eth.getCompilers() returns an empty list even if installed.

You can try :

➜  ~ which solc
/usr/local/bin/solc

then in geth

> admin.setSolc("/usr/local/bin/solc")

Following your edit, if you just want to use the npm package you wont be able to compile in geth, but still you can use it in a script like described in the package doc :

var solc = require('solc');
var input = "contract x { function g() {} }";
var output = solc.compile(input, 1); // 1 activates the optimiser
for (var contractName in output.contracts) {
    // code and ABI that are needed by web3
    console.log(contractName + ': ' + output.contracts[contractName].bytecode);
    console.log(contractName + '; ' + JSON.parse( output.contracts[contractName].interface));
}
  • Thanks @euri10 but didn't you just write that the solc executable is part of the c++ client distribution only? Do I need to install both the go and the c++ clients if I want to use Solidity within the geth console? In addition to that, the npm installation does not give me a solc executable, just libraries I can use in node. – Gianfranco Cecconi May 23 '16 at 10:12
  • effectively if you want to try the executable within geth you'll have to install solc which comes with the c++ bundle, apologies, I wasn't clear enough – euri10 May 23 '16 at 11:21
2

So, it looks like the standalone Solidity compiler solc is only available as part of the Ethereum C++ command line tools.

This means that if you want to use solc from within geth you need to install both the Go tools - that give you geth and the C++ tools, that give you solc.

This looks very odd to me, particularly considering that the C++ tools are a secondary project that went through some hard times and is apparently being rebooted.

So, what is one supposed to use today as the leading Solidity compiler? Perhaps the NodeJS console.

  • I'm following the C++ development very closely and they are currently in a process of breaking up the C++ project in stand alone forks for eth, ethminer, solidity etc. pp. Stay tuned, will take a couple of weeks though, but you will be able to install solidity only by then. – soc1c Jun 25 '16 at 20:27

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.