web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19k stars 4.89k forks source link

Connecting ethereum.js and go-ethereum -- MagicToken mismatch? #45

Closed tinybike closed 9 years ago

tinybike commented 9 years ago

(I'm cross-posting this to go-ethereum, since it seems to pertain to both, from my limited vantage point.)

I've been tinkering with the JS API, trying to figure out how to compile contracts (and actually load them into the blockchain). The example here is using Serpent code, but I get the same error when using Solidity instead.

I'm running go-ethereum, started as ethereum -rpc -loglevel=4 -y. If I define a variable w/ some simple serpent code:

var serp = "def double(v):\n" +
"   return(v*2)"

Then from my browser (Chrome) console:

> web3.eth.serpent(serp)
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

But, it just stays in "pending" forever. On the backend, I get the following message:

2015/01/26 23:48:58 [PEER] MagicToken mismatch. Received [80 79 83 84]

I'm not clear what this means -- what is a MagicToken? I googled and found https://gogs.io/github.com/eris-ltd/go-ethereum/wire, which says:

var MagicToken = []byte{34, 64, 8, 145}

"The magic token which should be the first 4 bytes of every message and can be used as separator between messages." I tried using this in Solidity:

var source = "[]byte{34, 64, 8, 145};" + 
"contract test {\n" +
"   function multiply(uint a) returns(uint d) {\n" +
"       return a * 7;\n" +
"   }\n" +
"}\n";
web3.eth.solidity(source);

but I get the same MagicToken error. What am I doing wrong?

drcode commented 9 years ago

I'm getting the same problems...

kumavis commented 9 years ago

This issue has become fairly outdated -- if this is still an issue for you we can reopen it. Try things out on the newer versions. a lot has changed :smile_cat:

drcode commented 9 years ago

Yes, this is long resolved I think.