Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_compilers, eth_compileSolidity are gone in go-ethereum 1.6.0 #3793

Closed
beatrizsanchez opened this issue Mar 17, 2017 · 96 comments
Closed

Comments

@beatrizsanchez
Copy link

System information

Geth version: v1.6.0-unstable-6d038e76/linux/go1.7.3
OS & Version: Linux/Ubuntu 16.04.1 LTS (x86_64)
Commit hash : 6d038e7

Expected behaviour

Running eth.getCompilers() in the geth console should return an array of compilers ['solidity'] that could even be empty ( [] )

Actual behaviour

The command returns Error: The method eth_getCompilers does not exist/is not available but I have started the node with --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" and I am able to run other eth commands. I was actually trying to execute the command via RPC with web3j and was getting an error then realized it didn't work in the console either.

> eth.compile
{
  lll: function(),
  serpent: function(),
  solidity: function()
}

Steps to reproduce the behaviour

  1. Attach the console to a running node with -ipc enabled
  2. Run eth.getCompilers()
  3. If no compilers are installed you should get [], not an error message
@fjl
Copy link
Contributor

fjl commented Mar 17, 2017

Compiling via RPC has been removed in #3740 (see ethereum/EIPs#209 for why). We will bring it back under a different method name if there is sufficient user demand. You're the second person to complain about it within 2 days, so it looks like there is demand.

@fjl fjl changed the title "Method does not exist/is not available" eth.getCompilers(), in geth console eth_compilers, eth_compileSolidity are gone in go-ethereum 1.6.0 Mar 17, 2017
@fjl
Copy link
Contributor

fjl commented Mar 17, 2017

Leaving this open so other people can find this issue and raise their voice here.

@beatrizsanchez
Copy link
Author

@fjl, Thanks for the info. It would be convenient to have it on RPC but I have the issue as well on IPC, any idea why?

@fjl
Copy link
Contributor

fjl commented Mar 17, 2017

When I say RPC I mean the IPC endpoint too. The methods have been removed by the linked PR. There is no way to invoke solc through geth at this time.

@ghost
Copy link

ghost commented Mar 23, 2017

This feature is really useful. Can we please have the compilers available?

@mavstronaut
Copy link

Eth.compile is a great feature!

@islandBilly
Copy link

I too think eth.compile is a great feature, and it was an important part of my Dapp, so that people could generate a simple contract from a web form, compile and deploy it, all without knowledge of Solididty or the need to use Mist.

@kunalbansal92
Copy link

Updated my project due to this issue ethereum/solidity#1708, And now :/

@vyorkin
Copy link

vyorkin commented Apr 11, 2017

Also voting for bringing it back, otherwise at least we should update the official docs and tutorials to not confuse a newcomers (like me)

@RomanKrakowiak
Copy link

Living exactly the same situation as the comment above from vyorkin. Newcomer, confused by outdated official tutorial.
also, please update the private network genesis block specifications in the official documentation please :p

@michiels
Copy link

Either way, the docs/website should reflect the latest state I think :) On this page https://www.ethereum.org/greeter it still assumes you're using solc.

@ropod7
Copy link

ropod7 commented Apr 17, 2017

eth_compileSolidity, or analogue should be available over RPC . Please.

@ghost
Copy link

ghost commented Apr 17, 2017

If the old console command has to go, can we not just replace it with a similarly named function that calls a solidity compiler? It just seems sensible that it's there. Or at least, make a tutorial for writing and making solidity apps that people can follow.

I was trying to hard to learn how to use geth or ethereum or anything. All the introductions I can find use Solidity [1]. This system is hard enough to follow or install as it is without all the documentation leading us down dead ends after DAYS AND DAYS of trying to install compilers that apparently don't exist now. So how are we meant to make or deploy smart contracts? This crypto tool has amazing potential but the impossibility of learning how to use or interact with it is terrible.

I can run geth as a fast node on my windows 10 machine, and I have a command-line solc compiler on my MacBook. But I don't seem to be able to get both at once!

Windows10: For example chocolaty now doesn't work, despite tutorials telling me its by far the easiest way to get solc on Windows. If instead I run ">npm install -g solc" ([2]) it seems to work but then when I run ">solc" it just says it's not recognised as a command, program or batch file.
Running ">npm install solc" I get a series of warnings, starting with "npm WARN enoent ENOENT: no such file or directory, open 'LocalDir/package.json'".

MacBook: I think solc is working in Terminal, but without a tutorial I'm stuck with rookie errors in even compiling the "Hello World" of [1]. I describe this issue below.

[1] https://ethereum.org/greeter#getting-other-people-to-interact-with-your-code
[2] https://solidity.readthedocs.io/en/develop/installing-solidity.html


/* Rookie error with compiling my first solidity program. */
SolidityProjects$ cat helloWorld.sol
pragma solidity ^0.4.1

contract mortal {    
    /* Define variable owner of the type address*/
    address owner;

    /* this function is executed at initialization and sets the owner of the contract */
    function mortal() { owner = msg.sender; }

    /* Function to recover the funds on the contract */
    function kill() { if (msg.sender == owner) selfdestruct(owner); }
}

contract greeter is mortal {
    /* define variable greeting of the type string */
    string greeting;

    /* this runs when the contract is executed */
    function greeter(string _greeting) public {
        greeting = _greeting;
    }

    /* main function */
    function greet() constant returns (string) {
        return greeting;
    }
}

SolidityProjects$ solc helloWorld.sol 
helloWorld.sol:8:5: Error: Expected import directive or contract definition.
    function mortal() { owner = msg.sender; }
    ^
SolidityProjects$ 

@alphaqiu
Copy link

alphaqiu commented Apr 19, 2017

Sorry, but how to adding my contract into the gethereum in version of geth 1.6.0?

Okey, web3.eth.contract([]).new() just still can be used.

@jw122
Copy link

jw122 commented Apr 20, 2017

The greeter tutorial (and the token, crowdfunding ones) is not yet updated for the changes in 1.6.0.

It makes it harder for people who are trying to learn Ethereum to compile and run contracts. Please fix/advise

@KGutierrezTome
Copy link

Please bring back the old command line-compilers, they were very useful for testing

@dkhatter
Copy link

I too think eth.compile is a great feature, please bring it back to the latest version.

@temores
Copy link

temores commented Apr 25, 2017

many documents tutoriaIs, etc. point to command line compilers this change breaks them,I too spent DAYS trying to make this work. Please bring it back

@nakkapeddi
Copy link

nakkapeddi commented Apr 26, 2017

Hi all,

Perhaps the following will help you.

To get a feeling of Solidity (not sure how up to date it is, but will give you an idea of syntax):
https://learnxinyminutes.com/docs/solidity/

In order to get the "Hello World" smart contract to work, you need to compile it with solc like so:
solc -o output --bin --ast --asm test.sol

where test.sol contains

pragma solidity ^0.4.1;
contract mortal {
    /* Define variable owner of the type address*/
        address owner;

            /* this function is executed at initialization and sets the owner of the contract */
                function mortal() { owner = msg.sender; }

                    /* Function to recover the funds on the contract */
                        function kill() { if (msg.sender == owner) selfdestruct(owner); }
                        }

                        contract greeter is mortal {
                            /* define variable greeting of the type string */
                                string greeting;

                                    /* this runs when the contract is executed */
                                        function greeter(string _greeting) public {
                                                greeting = _greeting;
                                                    }

                                                        /* main function */
                                                            function greet() constant returns (string) {
                                                                    return greeting;
                                                                        }
                                                                        }

"output" can be an arbitrary directory on your machine. For more info, go here:

http://solidity.readthedocs.io/en/develop/using-the-compiler.html

Ignore the formatting, as I copied it from @GregoryFenn; the solidity lexer ignores whitespace so it doesn't matter. This will compile your contract.

@k26dr
Copy link

k26dr commented May 2, 2017

I use eth.compile.solidity for a custom deploy script, it was very useful, please bring back.

@bl4ck5un
Copy link

bl4ck5un commented May 5, 2017

@Tectract
Copy link

We're having downstream issues now because of this. Can you put those functions back, please?

@brobits
Copy link

brobits commented May 25, 2017

Ethereum.org's own greeter example is out of date now, should update the docs to demonstrate the steps to compiling if these functions aren't restored

@Tectract
Copy link

This cost me two days of work to work-around. I don't understand why you guys would intentionally make it harder to compile smart-contracts. We're compiling client-side now...

@k26dr
Copy link

k26dr commented May 26, 2017

Since a lot of people are saying they're having a hard time finding a workaround. Here's a code snippet that will get you the same result without eth.compile.solidity

var fs = require('fs');
var exec = require('child_process').execSync;

exec(`solc --bin --abi --optimize -o bin contract.sol`);

var abi = fs.readFileSync('bin/contract.sol:Contract.abi');
var compiled = '0x' + fs.readFileSync("bin/Contract.bin");

Replace all instances of contract.sol with your source filename and all instances of Contract with the name of your contract.

@Tectract
Copy link

Tectract commented May 26, 2017

This solution won't work under react, and it also requires you to have solc installed locally. It won't work with metamask against ethereum mainnet, either.

Here's my solution, see the full code at: www.github.com/tectract/ethdeployer

in the top-level .html file of my create-react-app:

    <script src="./browser-solc.min.js" type="text/javascript"></script>

and then in the code:

function loadWeb3() {
   let web3Injected = window.web3;
   if(typeof web3Injected !== 'undefined'){
     console.log("saw injected web3!");
     web3 = new Web3(web3Injected.currentProvider);
   } else {
     console.log("did not see web3 injected!");
     web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
     //console.debug(web3.eth.accounts);
   }
}

the above snippet detects either the local web3 object or switches to the metamask-provided web3 object, if that exists...

  var compiler;
  setupCompiler(){
    var outerThis = this;
    setTimeout(function(){
      // console.debug(window.BrowserSolc);
      window.BrowserSolc.getVersions(function(soljsonSources, soljsonReleases) {
        var compilerVersion = soljsonReleases[_.keys(soljsonReleases)[0]];
        console.log("Browser-solc compiler version : " + compilerVersion);
        window.BrowserSolc.loadVersion(compilerVersion, function(c) {
          compiler = c;
          outerThis.setState({statusMessage:"ready!"},function(){
            console.log("Solc Version Loaded: " + compilerVersion);
          });
        });
      });
    },1000);
  }

Note, I had to wait for the window.BrowserSolc object to load, which is the reason for the setTimeout there. note also I'm using the lodash lib as "_" here.

Cheers~

@k26dr
Copy link

k26dr commented May 26, 2017

Correct, my script is for server-side compilation via Node, it will not work client side.

@temirov
Copy link

temirov commented Dec 3, 2017

Anyone knows where is the source code of this page: https://www.ethereum.org/greeter and who can fix the glaring error? cc: @vbuterin

@princefishthrower
Copy link

princefishthrower commented Dec 4, 2017

Working update as of 4th December 2017:

Alright everyone... let's calm down... languages like C++ (and respective communities) have been around for decades, Solidity has been around for years... the newest version at that, for just months. Plus, the Ethereum Foundation team, which is probably in charge of changes like this, is literally 3 people. Sheesh, give 'em a break.

With that said, all you need for the greeter example to compile is the solc command line tool:

npm install -g solc

Then, you can use the command line tool from solc to compile to binary:

***NOTE: on the command line, the command is solcjs NOT solc!!!

solcjs --bin --abi --optimize -o bin hello_world.sol

(I named my solidity file hello_world.sol)

And pit pat piffy wing wong wang just like that1, you've got your compiled binaries and contract ABIs in the folder bin/:

hello_world_sol_greeter.bin
hello_world_sol_greeter.abi
hello_world_sol_mortal.bin
hello_world_sol_mortal.abi

BONUS: to get perfect linting for the code (the original example will compile just fine, but with warnings), add public to the top two functions and the last function, and pragma on the first line. The final code then looks like this:

pragma solidity ^0.4.19;

contract mortal {
  /* Define variable owner of the type address */
  address owner;

  /* This function is executed at initilization and sets the owner of the contract */
  function mortal() public { owner = msg.sender; }

  /* Function to recover the funds on the contract */
  function kill() public { if (msg.sender == owner) selfdestruct(owner); }
}

contract greeter is mortal {
  /* Define variable gretting of the type string */
  string greeting;

  /* This runs when the contract is executed */
  function greeter(string _greeting) public {
    greeting = _greeting;
  }

  /* Main function */
  function greet() public constant returns (string) {
    return greeting;
  }
}
  1. 😂 Anyone get the reference?

@nfrankel
Copy link

Note that the official site still documents the method, though.

@hamzadiaz
Copy link

Please bring back the feature, it's very useful for any kind of projects

@n00b21337
Copy link

n00b21337 commented Mar 23, 2018

Internet is full of examples with eth_compileSolidity used in compile function, so now every newbie trying to learn from examples on the web is failing. Some people just think its all about the code and can't think outside the box, it's not about the code but its about the people so whoever orchestrated this change has failed. You should first find out how people are using something you are about to change and how much are they using it and then carefully plan how to change it and also inform people where change is about to happen to change the code. This is not a way how to treat an open source project of this importance or maybe people o charge think it is but I think it just sucks for community.

@VoR0220
Copy link
Member

VoR0220 commented Mar 24, 2018

These are from the days when the compiler was coupled to the RPC layer...which imho is a big no no. But we had a big EIP discussion about this...someone feel free to take up the charge on the EIP.

@ghost
Copy link

ghost commented Mar 24, 2018

I'm giving up entirely on Ethereum. It was a nice idea but it's become just another cryptocurrency like bitcoin and wasted its chance to be a great distrubuted computing language due to infuriating barriers to entry. I'm a moderaderly good python, C++ and C# programmer and have a PhD in Cyber Security, but for the life of me I can't get to grips with this ruddy software. Come back when you've got a working and accessible API to write and deploy DAPPs, add funds, check balances and search and use other DAPPs.

@Tectract
Copy link

please see how I compile solidity code CLIENT-SIDE, using web3 and browser-solc, here:

https://blockgeeks.com/guides/how-to-learn-solidity/

relevant source code is here:

https://github.com/Tectract/EthDeployer/blob/master/src/Deploy.js

This should be the standard until solc is added back into GETH, if ever, imho. My article was recently translated to Chinese too :)

@Tectract
Copy link

If you just need to compile and deploy a contract, you can use the tool I wrote, running here:

https://www.enledger.io/EthDeployer/

Using Metamask and Chrome. It's not flawless, but I did recently updated it to handle deployment of ERC20 contracts.

@Gallaecio
Copy link

If the method is not supposed to exist, it should probably not be mentioned at https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial

@avatar-lavventura
Copy link

Is this normal:

> eth.getCompilers()
Error: The method eth_getCompilers does not exist/is not available
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at <anonymous>:1:1

@ibigbug
Copy link

ibigbug commented Apr 25, 2018

If the method is not supposed to exist, it should probably not be mentioned at https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial

And probably the official doc: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilesolidity ?
a little bit frastrated :(

@karalabe
Copy link
Member

karalabe commented Oct 4, 2018

ethereum/EIPs#209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests