Closed beatrizsanchez closed 6 years ago
Compiling via RPC has been removed in #3740 (see https://github.com/ethereum/EIPs/issues/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.
Leaving this open so other people can find this issue and raise their voice here.
@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?
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.
This feature is really useful. Can we please have the compilers available?
Eth.compile is a great feature!
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.
Updated my project due to this issue https://github.com/ethereum/solidity/issues/1708, And now :/
Also voting for bringing it back, otherwise at least we should update the official docs and tutorials to not confuse a newcomers (like me)
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
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.
eth_compileSolidity, or analogue should be available over RPC . Please.
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$
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.
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
Please bring back the old command line-compilers, they were very useful for testing
I too think eth.compile is a great feature, please bring it back to the latest version.
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
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.
I use eth.compile.solidity for a custom deploy script, it was very useful, please bring back.
Some useful workaround for the moment: https://ethereum.stackexchange.com/questions/15435/how-to-compile-solidity-contracts-with-geth-v1-6
We're having downstream issues now because of this. Can you put those functions back, please?
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
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...
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.
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~
Correct, my script is for server-side compilation via Node, it will not work client side.
My script works completely client-side :) Totally standalone and no solc install required. Works against testrpc or against mainnet via metamask plugin.
Also see: www.github.com/tectract/ethereum-demo-tools, and www.enledger.io/ethereum-demo-tools, www.enledger.io/EthDeployer
Note I'm linking against this minified, browserified version of browser-solc.min.js:
https://github.com/ericxtang/browser-solc
Cheers~
Whether or not the compiler functionality is added back to geth
, please update the documentation to reflect something that actually works.
As it stands right now, all of the documentation most important to newcomers is horribly broken, and the path to getting a "hello world" smart contract up and running currently goes through this github thread complaining that nothing works. That's not a way to attract more users.
Specifically this - http://ethdocs.org/en/latest/contracts-and-transactions/contracts.html#writing-a-contract is all wrong now.
Been writing C/C++ for 20 years, Node.JS for about a year, ended up here because all of the "write your first ethereum contract" tutorials don't work. Nice one guys. Guess I'll just waste a ton of time figuring it out.
Hi there. This might help you along your way :)
@Tectract thank you!
I also use eth.compile for different projects and would like to have the feature back...
I find it very unprofessional that after two months, no one on the Ethereum team bothered to update the greeter-sample.
I was angry about this at first, but then I realized that browser-solc usage is a fundamentally better solution for compilation, because it requires neither server-side nor client-side solc installation.
The docs could be updated though, for sure.
This is stupid, bring it back or fix the tutorial.
If an important feature like this is changed, all relevant documents, tutorials, tests etc MUST be updated. One must address, "What is the work around for this?". Otherwise, few can use this. I prefer this approach. Multiple choices must be given for users.
We would like to have the compile function back too! A colleague and I spend two complete days just to figure out that the function doesn’t work. @parunach I completely agree with you. What is the alternative to compile now?
Developer here who is interested in learning about creating applications with ethereum. Every tutorial I've walked through is broken in some way, ended up here after following https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 which seemed like a solid tutorial until it threw an error on eth_compileSolidity
It's going to be hard for the ethereum community to continue to gain support if there aren't any solid tutorials and if the org's own tutorials are borked...
My tutorial works, I use client-side compilation.
https://blockgeeks.com/guides/how-to-learn-solidity/
You can also simply use the EthDeployer with Metamask plugin:
I don't know if the changes compiling "with testrpc" makes compatibility problems with the Metamask Extension.
I'm following a course on Pluralsight called Blockchain Fundamentals, and I'm having problems on the last two videos. A user posted a comment saying that something broke the compatibility of the course in some way. That's at least how I interpreted it.
I'm trying to run the files that my instructor provided in the course, and everything compiles, migrates, and npm dev's through. But I get a spinning wheel in metamask when I'm trying to create a new smart contract in the course.
I don't know if this is anything related to this, but I know for a fact that being a Smart Contract / Blockchain developer is a select field right now. So saying I'm waiting for the demand of developers to come, is kind of weird. While there is so little content on these subjects of developing a Cryptocurrency and Smart Contract. It's not like mainstream C++.
related issue, they introduced a BUG this week in the solidity compiler...
@2cool4games Did you actually connect Metamask to the mainnet? If you are running a localhost node / testrpc node, you can just turn metamask off and the EthDeployer should connect to your local node and run just fine without metamask.
@Tectract Thanks a lot! You really helped me. It works with truffle on the TestRPC. However it migrates for ages on my own private network, unfortunately I had to cancel it. Is it normal that it takes so long?
Thanks for this response. As noted above, right now there is a bug in the solidity compiler which throws erroneous warnings, and can prevent EthDeployer from working, temporarily until that bug is fixed either upstream or in EthDeployer itself (downstream). Are you seeing compiler warnings?
Otherwise, can you open the web console and report back on whether any errors are being kicked in the javascript console?
cheers~
@KellerL you can alos try connecting to your localhost node VIA metamask, that might help you compile / deploy on your localhost node :)
@Tectract I am really happy that you have responded to my post. I really really appreciate it! ( ̄▽ ̄)ノ
Yea, I am using testrpc with metamask. In my "Blockchain Fundamentals Course" I also used Ethereum Blockchain Deployments too. I don't know whether to consider it a private or a public Blockchain. I think it's a Private Blockchain accessible to the internet.
I ran my Ethereum Smart contract with testrpc on localhost 8080. I ran both the instructor's and my code, and both didn't work. I just had a spinning wheel in both of them, and it says in Metamask "Contract Published (Failed)"... Everything went correctly in his video, when he used Metamask in the video. Maybe the update did break something, or I'm doing something wrong.
I just seen a spinning circle in Metamask that never ended.
Thanks again :)
Sebastian.
The default port should be 8545, not 8080... Did you see any errors in the console? Those would be really helpful.
@Tectract
My testRPC is on port 8545. And when I truffle compile, migrate, and npm run dev it runs the instructor's code on port 8080 (localhost:8080).
Do you want the error messages from Metamask or Powershell? I would like to provide you the error messages, but I don't know where to look for them / which ones to share.
Also if you want to take a look at my instructors code here's a link: https://drive.google.com/open?id=0B_-lAAL1mo__U0lHM2V3cGgtSzA ... I am looking particularly at folder FoodSafe_WithCreateContract Folder.
Thank you! Have a awesome day!
Sebastian
please open the browser "developer console", you should see some stuff going through there in the javascript console. Possibly useful error messages :)
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 : 6d038e76
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 othereth
commands. I was actually trying to execute the command via RPC withweb3j
and was getting an error then realized it didn't work in the console either.Steps to reproduce the behaviour
eth.getCompilers()
[]
, not an error message