Skip to content

Examples for getting started as an Ethereum web developer

Notifications You must be signed in to change notification settings

acoravos/eth-dev-101

 
 

Repository files navigation

eth-dev-101

Playing around with Alex Miller's Getting Started as an Ethereum Web Developer.

Cryptography Independent Project @ Harvard University, Spring 2017.

Guide to manually execute transactions using testrpc and truffle

Step 1: Get a blockchain set up on our computers

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.

Step 2: Set up the other frameworks and infrastructure

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.

Step 3: Execute & Play.

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.

testrpc_accounts

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

list_accounts

Now we're ready to test out a few activities using Web3.

Sending Ether

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")});

send_transaction

We sent 1 wei from account[0] to account[1].

Check Balance

We could then check the balance of the two accounts to see if our transaction was successful.

get_balance

Yay.

Checking receipts.

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).

check_receipt

Cryptography Independent Project @ Harvard University, Spring 2017.

About

Examples for getting started as an Ethereum web developer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%