最後更新: 2021-02-11
目錄
eth-proxy
HomePage: https://github.com/Atrides/eth-proxy
Install:
cd /opt
git clone https://github.com/Atrides/eth-proxy.git
Config:
eth-proxy.conf
COIN = "ETH" HOST = "0.0.0.0" PORT = 8080 WALLET = "XXXXXX" ENABLE_WORKER_ID = True
Run it
apt-get install python-twisted
geth
功能
- mine real ether
- transfer funds between addresses
- create contracts and send transactions
- explore block history
Source:
https://github.com/ethereum/go-ethereum
Install
apt-get install software-properties-common
add-apt-repository -y ppa:ethereum/ethereum
apt update
apt-get install ethereum
Help (-h)
opts
--datadir "/root/.ethereum" Data directory for the databases and keystore
Folder
Data directory: ~/.ethereum
Ethash DAG: ~/.ethereum/geth
console Command
geth console
Welcome to the Geth JavaScript console! instance: Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9 coinbase: 0xYOUR_ADDRESS at block: 0 (Thu, 01 Jan 1970 08:00:00 HKT) datadir: /root/.ethereum modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
Check Balances
web3.fromWei(eth.getBalance(web3.eth.accounts[0]), "ether")
Account Command:
list # Print summary of existing accounts
new # Create a new account
update # Update an existing account
import # Import a private key into a new account
ie.
geth --datadir /data/ethereum account list
Account #0: {YOUR_ADDRESS} keystore:///data/ethereum/keystore/<date>--YOUR_ADDRESS
Verify Password
# 用改 Password 去驗證 Password
geth account update 0x?
Passphrase: INFO [02-06|23:09:30] Unlocked account address=0x? Please give a new password. Do not forget this password. Passphrase:
見到入新 Password 時按 Ctrl+C
geth console
> personal.unlockAccount("address", "password")
Network
Geth continuously attempts to connect to other nodes on the network until it has peers. (UDP)
--nodiscover
To start geth without the discovery protocol
--bootnode
bootstrap nodes whose endpoints are recorded in the source code.
# In Shell
net.listening
net.peerCount
# To get more information
admin.nodeInfo
admin.peers
# NAT
Ethereum clients use a listener (TCP) port and a discovery (UDP) port, both on 30303 by default.
--nat value NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
--verbosity value Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 3)
# Example
geth --light --nat "extip:x.x.x.x" console
Light Client
# Client 的分別
# BlockVerification: No-Ancient, AvailableBlocks: Recent, AvailableStates: Recent
--no-ancient-blocks
# BlockVerification: Headers-Only, AvailableBlocks: NONE, AvailableStates: NONE
# --syncmode "fast" Blockchain sync mode ("fast", "full", or "light")
--light
# Blockchain Size
294.14GB@20180313
https://bitinfocharts.com/ethereum/
Chain is Bloated
Block
A bundle of transactions which, after proper execution, update the state.
Each transaction-bundling block gets a number, has some difficulty, and contains the most recent state.
State
The state is made up of all initialized Ethereum accounts.
At the time of writing, there are around 12 million known accounts and contracts growing at a rate of roughly 100k new accounts per day.
# Start Client
geth --syncmode "light" / geth --light
# Console
# --cache value # Megabytes of memory allocated to internal caching (min 16MB / database forced) (default: 128)
geth --light console
INFO [03-13|17:41:35] Maximum peer count ETH=0 LES=100 total=25 INFO [03-13|17:41:35] Starting peer-to-peer node instance=Geth/v1.8.1-stable-1e67410e/linux-amd64/go1.9.4 INFO [03-13|17:41:35] Allocated cache and file handles database=/root/.ethereum/geth/lightchaindata cache=768 handles=1024 INFO [03-13|17:41:35] Initialised chain configuration config="..." INFO [03-13|17:41:35] Disk storage enabled for ethash caches dir=/root/.ethereum/geth/ethash count=3 INFO [03-13|17:41:35] Disk storage enabled for ethash DAGs dir=/root/.ethash count=2 INFO [03-13|17:41:35] Added trusted checkpoint chain=mainnet block=5046271 hash=04c211…ca1d63 INFO [03-13|17:41:35] Loaded most recent local header number=5247226 hash=05d957…ebc8c3 td=3019748917866238965670 INFO [03-13|17:41:35] Starting P2P networking INFO [03-13|17:41:37] UDP listener up net=enode://... WARN [03-13|17:41:37] Light client mode is an experimental feature INFO [03-13|17:41:37] RLPx listener up self="enode://..." INFO [03-13|17:41:37] IPC endpoint opened url=/root/.ethereum/geth.ipc Welcome to the Geth JavaScript console!
# 一段時間後會開始 Headers-Only sync
# https://etherscan.io/ <== LAST BLOCK: 5247450 INFO [03-13|18:35:21] Imported new block headers count=1 elapsed=9.180ms number=5247448 hash=7dfd2b…bdc1b2 ignored=0 INFO [03-13|18:35:21] Imported new block headers count=1 elapsed=6.738ms number=5247449 hash=311b64…e0b494 ignored=0 INFO [03-13|18:35:37] Imported new block headers count=1 elapsed=8.111ms number=5247450 hash=2cbff2…bfc90b ignored=0
# 很多時都要一段時間後才開始 Sync, 因為 Full Sync Client 有以下 Default Setting
--lightserv value Maximum percentage of time allowed for serving LES requests (0-90) (default: 0)
--lightpeers value Maximum number of LES client peers (default: 20)
在未 Sync 到 Peer 的情況下行 cmd 會見到 "Error: no suitable peers available"
MyEtherWallet
HomePage: https://www.myetherwallet.com
* Open-source
* Client-side interface
* Directly with the blockchain while remaining in full control of your keys
(The handling of your keys happens entirely on your computer, inside your browser.)
-----------
To Run MyEtherWallet Offline and Locally
https://github.com/kvhnuke/etherwallet/releases/tag/v3.21.02
-----------
Send Offline
MyEtherWallet, is able to generate a valid public key (wallet address)
based on programmatic algorithms and "rules" that work on the public "online" blockchain.
The software alone generates this as a unique key.
You can generate a transaction offline using the same MyEtherWallet software,
in an offline environment, and then broadcast that transaction code using an online device.
-----------
TX Pool
TX Pool of the node you are connected to.
It is currently pending (waiting to be mined).
Checking
https://etherscan.io/txsPending
Transaction Not Found:
This transaction cannot be found in the TX Pool of the node you are connected to.
However, it could be in a different TX Pool, waiting to be mined.
Once we send a transaction to blockchain, it goes to transaction pool with other transactions.
Once the transaction is picked by any miner and included in a block, the transaction is removed from the transaction pool
Pool
較多人用的 Pool
- Nanopool (Fee is 1%) [ https://eth.nanopool.org ]
- Dwarfpool (Fee is 1%) [ http://dwarfpool.com/eth ]
Dwarfpool
TZ: -7
http://dwarfpool.com/eth
Server
# Only Stratum-Port (proxy+claymore): 8008
HK-Server: eth-hk.dwarfpool.com (Hong Kong/香港)
SG-Server: eth-sg.dwarfpool.com (Singapore)
# Port: 80 and Stratum-Port (proxy+claymore): 8008
US-Server: eth-us.dwarfpool.com
ASIA-Server: eth-asia.dwarfpool.com (Taiwan)
Calculated Hashrate
Calculated Hashrate takes the amount of valid shares your miner has submitted over a period of time and uses a formula to convert this into a readable hashrate. This number can fluctuate, sometimes being lower or higher than your actual miner's output hashrate in the console.
Reported Hashrate
Reported Hashrate is utilized by ethminer, a piece of mining software. It submits the hashrate of your actual hardware (what you see in your console) to the pool. This allows you to compare it to your calculated hashrate.
Reported Hashrate is just a convenience item and not required to mine on the Ethereum pool. However, it does allow you to compare your submitted hashrate to your calculated hashrate which can be useful to you.
Reported Hashrate does not affect payout.
json api
http://dwarfpool.com/eth/api?wallet=YOUR_WALLET&email=YOUR_EMAIL
status
http://dwarfpool.com/eth/address?wallet=YOUR_ACCOUNT_ADDRESS_WITHOUT_THE_0x
Nanopool
https://eth.nanopool.org/search?address=0xYOUR_ACCOUNT_ADDRESS
nanopool api
workers
# 600s 更新一次
https://api.nanopool.org/v1/eth/workers/0x?
{"status":true,"data":[{"uid":3060561,"id":"H1","hashrate":136,"lastShare":1528883828,"rating":141928},....
https://api.nanopool.org/v1/eth/history/0x?
https://api.nanopool.org/v1/eth/shareratehistory/0x?
Doc
https://eth.nanopool.org/api
miner not work
If you don't see your miner on the stats page, 99.9% that you have corrupted DAG file.
You must delete it and restart ethminer.
Display Memory Usage
nvidia-smi
+-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 2931 G /usr/lib/xorg/Xorg 20MiB | | 0 4559 C ethminer 4325MiB |
比實際 DAG size 大 #
Ethash is the PoW system
Ethash is the planned PoW algorithm for Ethereum 1.0
* memory hard
* requires choosing subsets of a DAG dependent on the nonce and block header
DAG(Directed Acyclic Graph)
The DAG is the huge "dataset"
It is created every epoch using a version of the "Dagger-Hashimoto Algorithm"
combining "Vitalik Buterin's Dagger algorithm" and Thaddeus Dryja's Hashimoto algorithm.
DAG size
Epoch
Block height
Sending ether
> var sender = eth.accounts[0];
> var receiver = '0x???';
# Transaction values are expressed in weis
> var amount = web3.toWei(0.01, "ether")
> eth.sendTransaction({from:sender, to:receiver, value: amount})
eth.sendTransaction({from: eth.accounts[0], to: '0x???', value: web3.toWei(0.001, "ether")})
Gas Price
預計所需 Gas 及 Price
- https://ethgasstation.info/index.php
-
https://ethereumprice.org/gas
# 有星期 時段vs價格 圖看 -
https://etherscan.io/chart/gasprice
# chart - https://ycharts.com/indicators/ethereum_average_gas_price
If you do not have the ether to cover all the gas requirements to complete running your code,
the processing aborts and all intermediate state changes roll back to the pre-transaction snapshot.
Unit
1 Ether = 10^18 Wei
1Gwei = 10^9
Sell / Convert
Binance (https://www.binance.com/) is a good way to convert ETH into other coins,
Coinbase is an easy place to sell ETH to your bank account in the USA, Europe, Australia and Singapore.
收入
208W x 24h = 4992Wh ~ 5 kWh = 5 度電 ~ HK$5
以 $9k 一粒 ETH 計, 一日掘到 0.00169068 ETH (@20MHs), 收入 $15.2
---------------------------------------------
賺 = $15 - $5 = $10
術語
Ethereum DAG Size EPOCH
rigs 鑽機
Ethash
Ethash is the PoW system. This typically takes hours to generate so we tend to memorise it.
Ethash PoW is memory hard, making it basically ASIC resistant.
Clients wishing to store the DAG in a cache should conform to this spec in order to share the cache with other clients:
Location
Linux: $(HOME)/.ethash/full-R<REVISION>-<SEEDHASH>
<REVISION> is a decimal integer
<SEEDHASH> is 16 lowercase hex digits specifying the first 8 bytes of the epoch's seed hash.
ie.
full-R23-0000000000000000 full-R23-3aa8f28cac16bdd8 full-R23-b683d2a971567602
There may be many such DAGs stored in this directory; it is up to the client and/or user to remove out of date ones.
Format
Each file should begin with an 8-byte magic number,
0xfee1deadbaddcafe, written in little-endian format (i.e., bytes fe ca dd ba ad de e1 fe).
The Ethash algorithm expects the DAG as a two-dimensional array of uint32s (4-byte unsigned ints), with dimension (n × 16) where n is a large number. (n starts at 16777186 and grows from there.) Following the magic number, the rows of the DAG should be written sequentially into the file, with no delimiter between rows and each unint32 encoded in little-endian format.
Seed hash:
The seed hash is different for every epoch.
For the first epoch it is the Keccak-256 hash of a series of 32 bytes of zeros.
For every other epoch it is always the Keccak-256 hash of the previous seed hash.
The EthHash algorithm works by defining two critical structures:
A 16 MB cache, which is generated from a seed, which is changed every epoch. Every node (including light clients) generates this cache and stores it.
A 1 GB DAG, which is generated from the cache in such a way that each part of the DAG depends on a small number of pseudo-randomly chosen elements from the cache.
Each round of the algorithm only requires 64 lookups to the DAG, however.
This means that given a nonce, a non-mining client can use the cache to generate only the small portion of the DAG that is actually used.
Next DAG Epoch
Every 30,000 blocks - where 30,000 blocks is called an epoch - a new DAG file is generated.
PoW requires choosing subsets of a fixed resource dependent on the nonce and block header.
Ethash uses a DAG (directed acyclic graph) for the proof of work algorithm,
this is generated for each epoch, i.e every 30000 blocks (100 hours).
The DAG takes a long time to generate.
https://github.com/ethereum/wiki/wiki/Mining
Ethereum DAG Size EPOCH
https://investoon.com/tools/dag_size
DAG file is locating directly in your GPU memory.
And if DAG file is bigger than your GPU memory so your GPUs become useless.
Difficulty
Difficulty does not impact your individual hash rate.
Difficulty affects productivity of a given hash rate.
More difficulty will slow down the Ether (or any other coin) production of the network.
there are several factors affecting ETH mining/profits:
- difficulty
- ice-age
- RX hashrate drop
- coming PoS
- possible reward reduction
The Ethereum Ice Age is a difficulty adjustment scheme that was put in place to ensure that everyone has an incentive to move to the new blockchain once the hard-fork is implemented.
Ethereum Wallet 與 Mist 分別
Mist is the browser for decentralized web apps.
What Mozilla Firefox or Google Chrome are for the Web 2.0,
the Mist Browser will be for the Web 3.0 (which will be decentralized).
These releases are therefore called Ethereum Wallet as it only offers a bundle of the Mist browser with a single DApp: the wallet.
Nonce
There are two types of nonce used in Ethereum:
- Account nonce
- Proof of work nonce
Account nonce
It's simply the transaction count of an account
To keep transaction related to an account in order.
This prevents replay attacks where a transaction sending
eg.
20 coins from A to B can be replayed by B over and over to continually drain A's balance.
eg.
If there is a transaction with nonce 3 related to some account in the txpool and
some transaction will nonce 4 arrived then that transaction won't be mined until and
unless transaction with nonce 3 is mined.
Proof of work nonce
The random value in a block that was used get the proof of work satisfied (depending on the difficulty at the time).
錢包
Install geth
sudo add-apt-repository -y ppa:ethereum/ethereum
apt-get install ethereum
Account
# Create
geth account new
# List
geth account list
Account #0: {x} keystore:///root/.ethereum/keystore/UTC--2018-01-28T17-07-45.633871804Z--x
OPTIONS:
--datadir "/home/bas/.ethereum" Data directory for the databases and keystore
# Chage PW
geth account update
# checking balances
geth console
> web3.fromWei(eth.getBalance(eth.coinbase), "ether")
0