Hi,
I'm trying to run through the examples on the ethereum site and am not able to compile using Solidity. I am running Geth on a Windows machine and receive the following error when trying to build.
> var greeterCompiled = web3.eth.compile.solidity(greeterSource)
solc:
no build results found at InvalidResponse (:-81662:-63)
at send (:-156322:-63)
at solidity (:-133322:-63)
at :1:23
In case it helps here is my full log:
C:\>geth --networkid 1313 --genesis ./ProgramData/chocolatey/lib/geth-stable.1.2
.1.0/tools/test/genesis.json --datadir ~/.ethereum_experiment --solc "C:\Program
Files\Ethereum 0.9.41\Release\solc.exe" console
I1028 17:41:26.927645 10016 database.go:71] Alloted 16MB cache to C:\Users\tot
manst\.ethereum_experiment\chaindata
I1028 17:41:26.980688 10016 database.go:71] Alloted 16MB cache to C:\Users\tot
manst\.ethereum_experiment\dapp
I1028 17:41:26.988694 10016 backend.go:291] Protocol Versions: [62 61], Networ
k Id: 1313
I1028 17:41:27.533143 10016 genesis.go:88] Genesis block already in chain. Wri
ting canonical number
I1028 17:41:27.533143 10016 backend.go:303] Successfully wrote genesis block.
New genesis hash = 48b9a92b57094e56c4fe66168f4d23b4143caee2f8f4aaf46d9e422a97b58
635
I1028 17:41:27.533143 10016 backend.go:333] Blockchain DB Version: 3
I1028 17:41:27.537147 10016 chain_manager.go:248] Last block (#469) c960801110
92c0da68bab9fc73f04ba5bbd1604389b676dc560d8c678021eff0 TD=69027325
I1028 17:41:27.542149 10016 cmd.go:125] Starting Geth/v1.2.1/windows/go1.4.2
I1028 17:41:27.542149 10016 server.go:311] Starting Server
I1028 17:41:29.053822 10016 udp.go:204] Listening, enode://e11b6e9962a191cc158
cd439d329e082153d377f3bdebc37b77aa187f422411ad65f3f4e2b4f0ee5b8ba2cfb1f7dcd92f8b
[email protected][::]:30303
I1028 17:41:29.054821 10016 backend.go:559] Server started
I1028 17:41:29.054821 10016 server.go:552] Listening on [::]:30303
I1028 17:41:29.056823 10016 ipc_windows.go:724] IPC service started (\\.\pipe\
geth.ipc)
instance: Geth/v1.2.1/windows/go1.4.2
datadir: C:\Users\stuser/.ethereum_experiment
coinbase: 0xd8057d991503667b485d8337a8cb20e476ef539c
at block: 469 (Wed, 28 Oct 2015 13:19:12 EST)
modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1
.0 txpool:1.0 web3:1.0
> eth.getCompilers()
I1028 17:41:32.570593 10016 solidity.go:114] solc, the solidity compiler comma
ndline interface
Version: 0.1.1-9d118e62/Release-Windows/msvc/JIT
path: C:\Program Files\Ethereum 0.9.41\Release\solc.exe
["Solidity"]
> {eeting; } function greet() constant returns (string) { return greeting; } }'
undefined
> greeterSource
"contract mortal { address owner; function mortal() { owner = msg.sender; } func
tion kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is m
ortal { string greeting; function greeter(string _greeting) public { greeting =
_greeting; } function greet() constant returns (string) { return greeting; } }"
> var greeterCompiled = web3.eth.compile.solidity(greeterSource)
solc: no build results found
at InvalidResponse (:-81662:-63)
at send (:-156322:-63)
at solidity (:-133322:-63)
at :1:23
Hopefully this is a setup issue where I have done something incorrectly. Any help is greatly appreciated!
Answers
At least solidity 0.1.1 should work with any geth version...
C:\windows\system32>geth --networkid 1313 --genesis "D:\geth\geth-stable.1.2.1.0
\tools\test\genesis.json" --datadir "D:\geth\.ethereum_experiment" --solc "C:\Pr
ogram Files\Ethereum 0.9.41\Release\solc.exe" console
I1104 17:38:39.144428 55520 database.go:71] Alloted 16MB cache to
ereum_experiment\chaindata
I1104 17:38:39.295536 55520 database.go:71] Alloted 16MB cache to
ereum_experiment\dapp
I1104 17:38:39.308545 55520 backend.go:291] Protocol Versions: [62 61], Networ
k Id: 1313
I1104 17:38:40.267226 55520 genesis.go:88] Genesis block already in chain. Wri
ting canonical number
I1104 17:38:40.268226 55520 backend.go:303] Successfully wrote genesis block.
New genesis hash = 48b9a92b57094e56c4fe66168f4d23b4143caee2f8f4aaf46d9e422a97b58
635
I1104 17:38:40.269230 55520 backend.go:333] Blockchain DB Version: 3
I1104 17:38:40.270228 55520 chain_manager.go:248] Last block (#7434) 5ce24bf28
1e06d00d04e157517b90dc76c9b19746069ebb9c61743ad13fb889a TD=4046194010
I1104 17:38:40.278233 55520 cmd.go:125] Starting Geth/v1.2.3/windows/go1.4.2
I1104 17:38:40.278233 55520 server.go:311] Starting Server
I1104 17:38:41.418225 55520 udp.go:204] Listening, enode://e11b6e9962a191cc158
cd439d329e082153d377f3bdebc37b77aa187f422411ad65f3f4e2b4f0ee5b8ba2cfb1f7dcd92f8b
[email protected][::]:30303
I1104 17:38:41.418225 55520 backend.go:559] Server started
I1104 17:38:41.418225 55520 server.go:552] Listening on [::]:30303
I1104 17:38:41.419224 55520 ipc_windows.go:724] IPC service started (\\.\pipe\
geth.ipc)
instance: Geth/v1.2.3/windows/go1.4.2
datadir:
coinbase: 0xd8057d991503667b485d8337a8cb20e476ef539c
at block: 7434 (Wed, 04 Nov 2015 16:02:07 EST)
modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1
.0 txpool:1.0 web3:1.0
> admin.setSolc("C:\\Program Files\\Ethereum 0.9.41\\Release\\solc.exe")
I1104 17:39:32.199461 55520 solidity.go:114] solc, the solidity compiler comma
ndline interface
Version: 0.1.1-ed7a8a35/Release-Windows/msvc/JIT
path: C:\Program Files\Ethereum 0.9.41\Release\solc.exe
"solc, the solidity compiler commandline interface\r\nVersion: 0.1.1-ed7a8a35/Re
lease-Windows/msvc/JIT\r\n\npath: C:\\Program Files\\Ethereum 0.9.41\\Release\\s
olc.exe"
>
These are the instructions I followed for my Windows compiler, which did not work:
https://www.ethereum.org/greeter
Running geth on windows when I did the following:
eth.getCompilers()
["solidity"]
..cool
Time to compile the test contract!
In geth console type:
source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
then:
contract = eth.compile.solidity(source)
Returned:
solc: no build results found
at InvalidResponse (:-81662:-45)
at send (:-156322:-45)
at solidity (:-133322:-45)
at :1:12
Does anyone know why the above would be happening?
I did find this relevant page, apparently there is a bug in upgrading solc from 0.1.1 to 0.1.2:
https://github.com/ethereum/solidity/issues/43
https://github.com/ethereum/go-ethereum/issues/1770
In any case this is how I did it on my ec2 Ubuntu instance which I can now successfully (after much hair pulling) compile using Solidity.
Assuming you have Geth already installed.
Step 1):
You should have a solidity compiler built in on your geth console. To test it, use this command:
eth.getCompilers()
If you have it installed, it should output something like this:
['Solidity' ]
Great, skip to step 3.
If you do not get Solidity above, then you need to install it. Press control+c to exit the console and go back to the command line and go to step 2.
Step 2):
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
which solc
Take note of the path given by the last line, you'll need it soon.
Now go back to the console and type this command to install solC, replacing path/to/solc to the path that you got on the last command you did:
admin.setSolc("path/to/solc")
then
//this should output ["Solidity"] if it has installed correctly.
eth.getCompilers()
Step 3):
Time to compile the test contract!
In geth console type:
source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
enter, then:
contract = eth.compile.solidity(source)
Since our contract's name is test now you can type the following line to confirm how your contract looks.
eth.compile.solidity(source).test
This should give you the contract object for the test contract containing the following fields:
code: the compiled EVM code
info: the rest of the metainfo the compiler outputs
source: the source code
language: contract language (Solidity, Serpent, LLL)
languageVersion: contract language version
compilerVersion: compiler version
abiDefinition: Application Binary Interface Definition
userDoc: NatSpec user Doc
developerDoc: NatSpec developer Doc Cool!
Now you can deploy:
https://ethereum.gitbooks.io/frontier-guide/content/creating_contract.html
I got most of this just from here:
https://ethereum.gitbooks.io/frontier-guide/content/compiling_contract.html
If it helps someone great, because it has been a headache for me. But then again I am stupid.
If anyone has any questions feel free to ask and I will try to answer but I am a n00b.