Playing around with Alex Miller's Getting Started as an Ethereum Web Developer.
Cryptography Independent Project @ Harvard University, Spring 2017.
There are lots of clients to choose from (e.g., geth, parity, and many others). We went with testprc, because it's perhaps the fastest Ethereum RPC client for testing and development. We also didn't have to download any parts of the existing blockchain.
We used Truffle, one of the most popular Ethereum development frameworks. We also used Web3, an Ethereum JavaScript API.
If you haven't already, install testprc, Truffle and Web3.
We wanted to do some simple transactions to get familar with the Ethereum protocol. Here's a short guide on how we did it.
Activate the testprc
$testrpc
This gave us nine available accounts and private keys to play with.
Next, deploy the contracts using Truffle, which has access to the Web3 API. Open a new terminal, cd into the Truffle app, type $truffle deploy
and then $ node
. We then set up our config:
var config = require('../config.js');
And we can check our existing accounts using config.web3.eth.accounts
Now we're ready to test out a few activities using Web3.
For reference in our screenshots, we set eth = config.web3.eth
.
To send a transacton from one account to another
eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(1, "ether")});
We sent 1 wei from account[0] to account[1].
We could then check the balance of the two accounts to see if our transaction was successful.
Yay.
Given that we have the transactionHash, we can find out how much gas was used and other details about the transaction by typing eth.getTransactionReceipt(transactionHash)
.
Cryptography Independent Project @ Harvard University, Spring 2017.