After loads of research, it seems the Ethereum.org Greeter example code no longer works. Here's the GitHub issues thread: https://github.com/ethereum/go-ethereum/issues/3793. There are some suggestions, one I will mention below, though, as a noob, it's still unclear.
This is a likely first place to land when starting to develop Ethereum, so I (and many others out there) are looking for a clear workaround.
Greeter example: https://www.ethereum.org/greeter
Running in geth console, here's the broken code with errors:
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 <anonymous>:1:1
var greeterSource = 'contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) selfdestruct(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }' <-- obviously no error here
var greeterCompiled = web3.eth.compile.solidity(greeterSource)*
Error: The method eth_compileSolidity does not exist/is not available
at web3.js:3104:20
at web3.js:6191:15
at web3.js:5004:36
at <anonymous>:1:23
I HAVE been able to compile greeterSource with 'solc', and I tried this suggestion on the GitHub thread above, though I'm not sure this will work within geth console:
var fs = require('fs');
var exec = require('child_process').execSync;
exec('solc --bin --abi --optimize -o bin greeterSource.sol');
var abi = fs.readFileSync('bin/Greeter.abi');
var compiled = '0x' + fs.readFileSync('bin/Greeter.bin');
Even after npm install fs
, I still get this:
Error: Cannot find module 'fs'
at s (web3.js:1:160)
at s (web3.js:1:122)
at <anonymous>:1:10
This should handle the next step in the Greeter example:
var greeterContract = web3.eth.contract(greeterCompiled.greeter.info.abiDefinition);
Again, new to Ethereum development, Im sure after a bit I will have a better grasp on the fundamentals, though considering this example is coming from Ethereum.org, this should be easier! Thanks!
P.S.> Also open for advice on an overall better dev path. I do like starting with command line to learn, though once I get it, what tools would you recommend?