1

This question already has an answer here:

I have tried to develop a javascript function with web3.js to compile a solidity contract. In html/javascript code, I have prepared the following.

var contract_code = "pragma solidity ^0.4.....[omit the content here])"; var compiled_contract = web3.eth.compile.solidity(contract_code);

By reference of google chrome broswser developer tools, I found the following error.

web3.min.js:1 Uncaught Error: The method eth_compileSolidity does not exist/is not available at Object.InvalidResponse (web3.min.js:1) at s.send (web3.min.js:2) at Object.e [as solidity] (web3.min.js:2) at deployContract ((index):53) at HTMLButtonElement.onclick ((index):114)

I checked again the Ubuntu 16.04 server and confirmed the installation of solc.

ubuntu@ip:~/node$ which solc /usr/bin/solc

I have search on Internet and someone have suggested to add --solc on geth command. My Geth version is v1.6.0.

geth --datadir ethfolder --solc /usr/bin/solc

However, it shows the following error message.

flag provided but not defined: -solc

I tried the eth.getCompilers() command.

eth.getCompilers();

Error: The method eth_getCompilers does not exist/is not available at web3.js:3104:20 at web3.js:6191:15 at web3.js:5004:36 at :1:1

I tried admin.setSolc function which is mentioned in the official wiki.

admin.setSolc('/usr/bin/solc');

TypeError: 'setSolc' is not a function at :1:1

Would anyone can advise hint on how to implement the compiling job on web3.js?

marked as duplicate by eth May 4 '17 at 5:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.