Skip to content

Instantly share code, notes, and snippets.

@tomahock
Last active May 17, 2017 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomahock/8f64fa512a8a1817c3c0ed0eb55c838c to your computer and use it in GitHub Desktop.
Save tomahock/8f64fa512a8a1817c3c0ed0eb55c838c to your computer and use it in GitHub Desktop.
Install and running Eth Testnet for example purposes only

Install and running Eth Testnet

Geth

Install

  • $ sudo apt-get install software-properties-common
  • $ sudo add-apt-repository -y ppa:ethereum/ethereum
  • $ sudo apt-get update
  • $ sudo apt-get install ethereum

Prepare

  • $ geth account new
  • $ vi genesis.json Get genesis.json
  • $ geth --datadir "/tmp/dev-geth/" init genesis.json
  • $ geth --identity "PixelsFire" --rpc --rpcport "8545" --rpccorsdomain "*" --datadir "/tmp/dev-geth/" --port "30303" --nodiscover --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --networkid 15 --nat "any" --rpcaddr "<your-servers-ip>" --wsaddr "<your-servers-ip>"

Blockchain Explorer

Clone

  • $ git clone https://github.com/etherparty/explorer
  • $ cd explorer
  • $ apt-get install npm
  • $ npm install -g bower
  • $ bower install
  • $ cd app
  • $ vi app.js search for localhost and change to your server's ip
  • $ python -m SimpleHTTPServer 8001

Explore

Connect

$ geth attach http://<your-servers-ip>:8545

Create a new account

> personal.newAccount()

Start mining

> miner.start(10)

Send Ether

Unlock an Account

> personal.unlockAccount("<insert-address-here>")

Send the Ether

> eth.sendTransaction({from: '<insert-address-here>', to: '<insert-address-here>', value: web3.toWei(1, "ether")})

Contracts

Publish

> var storageContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"}]);

var storage = simplestorageContract.new(
   {
     from: web3.eth.accounts[0], 
     data: '0x6060604052341561000c57fe5b5b60c68061001b6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a72305820253ea8bd608383c96778b7f7b5dd88b8d4847320a64d31778e905180013baa200029', 
     gas: '400000'
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })
 

Interact

  • Set:
> storage.set(45,{from:eth.accounts[0]})
  • Get:
> storage.get()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment