3

I have web3 and truffle running. I am able to execute the following commands:

> node
> Web3 = require('web3')
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
> web3.eth.accounts
> code = fs.readFileSync('contracts/Voting.sol').toString()

Then I want to compile the Voting.sol contract with the following command:

> contract =  web3.eth.compile.solidity(code)

This fails with the following error:

Error: Error: Method eth_compileSolidity not supported. at GethApiDouble.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:85608:16) at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18) at VmSubprovider.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113829:12) at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18) at GethDefaults.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:85935:12) at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18) at FilterSubprovider.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113388:7) at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18) at DelayedBlockFilter.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:85448:3) at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18) at Object.InvalidResponse (C:\Users\abc\truffletest\node_modules\web3\lib\web3\errors.js:38:16) at RequestManager.send (C:\Users\abc\truffletest\node_modules\web3\lib\web3\requestmanager.js:61:22) at Object.send [as solidity] (C:\Users\abc\truffletest\node_modules\web3\lib\web3\method.js:145:58) at repl:1:30 at sigintHandlersWrap (vm.js:22:35) at sigintHandlersWrap (vm.js:73:12) at ContextifyScript.Script.runInThisContext (vm.js:21:12) at REPLServer.defaultEval (repl.js:340:29) at bound (domain.js:280:14) at REPLServer.runBound [as eval] (domain.js:293:12)

I am going off this tutorial https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2

  • Is the code you are trying to compile copy/pasted from the tutorial? If no I can recommend you Remix - the development engine of the Ethereum foundation which provides you with better error messages. – larsl Jun 26 '17 at 12:15
  • yes, the Voting.sol in my project is copied exactly from the tutorial – ZhouW Jun 26 '17 at 12:24
  • Following the same tutorial and had the same error. Anyone? – theartofbeing Jun 28 '17 at 16:45
  • I have updated the tutorial now to use solc compiler. Thanks! – maheshmurthy Jun 30 '17 at 14:34
3

So essentially, the developers decided that making a node compile a contract like this to be out of scope. So this functionality has been deprecated. There were many reasons behind this, but the main ones are that RPC calls are beyond the responsibilities of the eth API, and node compilation like this is not sufficient. You can use an online compiler like Remix, or a compiler like solc to get the bytecode and go from there.

2

Include solc when you do a "npm install"

npm install ethereumjs-testrpc web3 solc

then, re-try the steps in your tutorial.

This is occurring because eth_compile was deprecated earlier this year.

1

Apart from using Truffle, you can try writing a nodejs script to deploy the contract and interact with it. I've given an answer to a similar question here - compiling solidity code using solc@0.4.10 on node.js

Hope it will help you.

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.