My working steps: Go-ethereum CLI + JSON-RPC + Chrome browser + etherum.js + solidity

drcodedrcode Member Posts: 62 ✭✭
edited February 2015 in Geth - Go Implementation
Hi, just want to put these up here in case someone else is confused by these things. Here's the steps I got working as of today (Feb 3, 2015)

1. Clone go-ethereum via github repo, but check out the "develop" branch (which is required for the necessary synchronous rpc support)... build the "ethereum" app in the cmd/ethereum directory (this is the go ethereum CLI client, the only client I think that is planned to be production-quality by the genesis block launch)

2. Run it with "ethereum -mine -rpc" to start mining and start the rpc server, so you can connect to it from chrome.

3. Set up a web server that can serve up html files, make it serve up the following to files: 4. Open the balance.html page from the Chrome web browser and press the "watch balance" button. If you see a balance other than zero, it means your ethereum client has successfully mined some ether on the testnet (and your JSON-RPC connection is working) and you are ready to proceed with the next steps.

5. Take the solidity example contract from the top of contract.html (which simply multiplies a number by 7) and compile it with the online solidity compiler found here:

6. Take the raw hex data output (shown about half way down the output side, indicated by the label "Hex:") and put it into contract.html as the "data" for the transaction that generates the contract. (Note that it needs to be prepended with "0x" to indicate a hex value) Note also that a "gas" and "gasprice" need to be also specified, which are also missing from the version of contract.html in the ethereumjs repo. So what we're doing is compiling solidity code with the online compiler, then manually publishing the contract as bytecode with the go ethereum client (go-ethereum does NOT currently have solidity support, so this is the only way to do it.)

7. Load contract.html in Chrome and press the "create example contract" button. Look over at the ethereum client output and make sure no errors were generated.

8. Type in a number in the text you wish to multiply by, then press "call contract".

If all went well, your number will have been multiplied by seven. Note by the way that the creation of the contract was a true ethereum transaction that ended up on the blockchain. The call to the contract, however, is an off-chain "call" to the contract handled by the go-ethereum client but NOT broadcast to other peers. However, if you wanted to make the multiplication call a true transaction you could do so by changing "call()" in contract.html to "transact()" and also providing "gas" and "gasprice" parameters, as we did when we created the contract.

Good luck everyone creating your first dapps!
Conrad Barski


Sign In or Register to comment.