Code Monkey home page Code Monkey logo

notes-on-ethereum's Introduction

Notes on Ethereum

Geth

Setup and run a Ethereum node

There are three working modes: Fast Sync: By default, the first time you run geth command is in this mode Full Sync: If the geth process has been interruped. An re-issue of geth command will be in this mode Light Sync: A less secure way with header only Download link: https://ethereum.github.io/go-ethereum/downloads/

On Mac, set the PATH for geth

echo 'export PATH=YOUR_PATH_TO_GETH_FILE:$PATH' >> ~/.bash_profile

To run the geth process in Fast Sync Mode

./geth

To run the process in Full Sync Mode Type Command-C to stop the process.

  • Delete the directory 'geth' under /Users/YOUR_USER_NAME_ON_MAC/Library/Ethereum
  • Run the geth command again

Javascript IPC Interface

Connect to the Ethereum node

./geth attach ipc:/Users/YOUR_USER_NAME_ON_MAC/Library/Ethereum/geth.ipc

Create new account

> personal.newAccount();

Example result

Passphrase: 
Repeat passphrase: 
โ€œ0x32a28e00186612638d91ce7aad6c832ae56c2a9e"

Synchronize blockchain node

> eth.syncing

Example result

{
  currentBlock: 180885,
  highestBlock: 4930769,
  knownStates: 207716,
  pulledStates: 197461,
  startingBlock: 0
}

RPC API reference

https://github.com/ethereum/go-ethereum/wiki/Management-APIs

Private Blockchain Network

Initialize with gensis.json

{
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x8000000",
  "alloc": {},
  "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    }
}
> geth init ./genesis.json --datadir my-chain-data

To start the network

> geth --datadir my-chain-data --nodiscover

Launch a Geth Javascript Console to interact with the node

> geth attach ipc:/YOUR_IPC_END_POINT/geth.ipc

In the javascript console, show current accounts by

> eth.accounts

To create new account

> personal.newAccount()

The private key of the new account is stored in keystore folder

Get ether by mining

Set the account

> miner.setEtherbase(eth.accounts[0])

Run the miner

> miner.start(1)

Checkt the ether

> eth.getBalance(eth.accounts[0])

Single command to start mining

geth --datadir my-chain-data/ --nodiscover --unlock 0 --mine 1

notes-on-ethereum's People

Contributors

m41highway avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.