以太坊常用命令總結(jié)

geth 指令及智能合約操作見:http://www.reibang.com/p/9fa31e4cdf4d

一、怎么使用命令
終端命令啟動以太坊私鏈:
#./geth --datadir "./chain" --nodiscover console 2>>eth_output.log //輸出日志到文件
//ethere js console 中的命令
> eth.coinbase
> miner.setEtherbase(eth.coinbase)
> eth.blockNumber
> miner.start(1) //啟動挖礦

啟動以太坊節(jié)點全命令:

geth --identity "TestNode" --rpc --rpcport "8545" --datadir data0 --port "30303" --nodiscover console

各選項含義如下:
–identity:指定節(jié)點 ID;
–rpc:表示開啟 HTTP-RPC 服務(wù)怨愤;
–rpcport:指定 HTTP-RPC 服務(wù)監(jiān)聽端口號(默認(rèn)為 8545)若河;
–datadir:指定區(qū)塊鏈數(shù)據(jù)的存儲位置催烘;
–port:指定和其他節(jié)點連接所用的端口號(默認(rèn)為 30303)辅髓;
–nodiscover:關(guān)閉節(jié)點發(fā)現(xiàn)機制,防止加入有同樣初始配置的陌生節(jié)點更卒。

如下命令注意使用方法:
進(jìn)入到可執(zhí)行文件geth的所在目錄才去執(zhí)行命令等孵,或者環(huán)境變量(我目前還不熟悉,暫時使用目錄的情況)
例如:

./geth --rpcport 8545   //設(shè)定rpc端口
常用的命令對象:

eth:包含一些跟操作區(qū)塊鏈相關(guān)的方法蹂空;
net:包含一些查看p2p網(wǎng)絡(luò)狀態(tài)的方法俯萌;
admin:包含一些與管理節(jié)點相關(guān)的方法;
miner:包含啟動&停止挖礦的一些方法上枕;
personal:主要包含一些管理賬戶的方法咐熙;
txpool:包含一些查看交易內(nèi)存池的方法;
web3:包含了以上對象辨萍,還包含一些單位換算的方法棋恼。

常用命令有(以太坊控制臺下使用,支持 Tab 鍵自動補全):
personal.newAccount():創(chuàng)建賬戶锈玉;
personal.unlockAccount():解鎖賬戶爪飘;
eth.accounts:枚舉系統(tǒng)中的賬戶;
eth.getBalance():查看賬戶余額拉背,返回值的單位是 Wei(Wei 是以太坊中最小貨幣面額單位师崎,類似比特幣中的聰,1 ether = 10^18 Wei)去团;
eth.blockNumber:列出區(qū)塊總數(shù)抡诞;
eth.getTransaction():獲取交易;
eth.getBlock():獲取區(qū)塊土陪;
miner.start():開始挖礦;
miner.stop():停止挖礦肴熏;
web3.fromWei():Wei 換算成以太幣鬼雀;
web3.toWei():以太幣換算成 Wei;
txpool.status:交易池中的狀態(tài)蛙吏;
admin.addPeer():連接到其他節(jié)點源哩;
二、以太坊常用命令
NAME:
   geth - go-ethereum命令行接口

USAGE:
   geth [options] command [command options] [arguments...]
   例如:啟動以太坊

VERSION:
   1.4.11-stable

COMMANDS:
   import   引入一個區(qū)塊鏈文件
   export   導(dǎo)出區(qū)塊鏈到文件
   upgradedb    更新區(qū)塊鏈數(shù)據(jù)庫
   removedb 移除區(qū)塊鏈和正式數(shù)據(jù)庫
   dump     dump a specific block from storage
   monitor  Geth Monitor: node metrics monitoring and visualization
   account  管理賬戶
   wallet   ethereum presale wallet
   console  Geth控制臺: JavaScript交互環(huán)境
   attach   Geth控制臺: JavaScript交互環(huán)境(連接node)
   js       在Geth JavaScript VM執(zhí)行JavaScript文件
   makedag  generate ethash dag (for testing)
   gpuinfo  gpuinfo
   gpubench benchmark GPU
   version  打印ethereum版本號
   init     引導(dǎo)初始化一個創(chuàng)世塊(JSON)
   help, h  顯示命令列表或一個命令的幫助

ETHEREUM OPTIONS:
  --datadir "/home/karalabe/.ethereum"  數(shù)據(jù)庫和keystore的文件目錄
  --keystore        keystore的文件目錄 (default = inside the datadir)
  --networkid value         Network identifier (integer, 0=Olympic, 1=Frontier, 2=Morden) (default: 1)
  --olympic             Olympic network: pre-configured pre-release test network
  --testnet             Morden network: pre-configured test network with modified starting nonces (replay protection)
  --dev                 Developer mode: pre-configured private network with several debugging flags
  --identity value          Custom node name
  --fast                Enable fast syncing through state downloads
  --lightkdf                Reduce key-derivation RAM & CPU usage at some expense of KDF strength
  --cache value             Megabytes of memory allocated to internal caching (min 16MB / database forced) (default: 128)
  --blockchainversion value     Blockchain version (integer) (default: 3)

賬戶選項:
  --unlock value    通過逗號分隔一個列表賬戶來進(jìn)行解鎖
  --password value  Password file to use for non-inteactive password input

API AND CONSOLE OPTIONS:
  --rpc             支持HTTP-RPC服務(wù)
  --rpcaddr value   HTTP-RPC服務(wù)監(jiān)聽地址(默認(rèn): "localhost")
  --rpcport value   HTTP-RPC服務(wù)監(jiān)聽端口(默認(rèn): 8545)
  --rpcapi value    HTTP-RPC提供的API支持(默認(rèn): "eth,net,web3")
  --ws          Enable the WS-RPC server
  --wsaddr value    WS-RPC server listening interface (default: "localhost")
  --wsport value    WS-RPC server listening port (default: 8546)
  --wsapi value     API's offered over the WS-RPC interface (default: "eth,net,web3")
  --wsorigins value Origins from which to accept websockets requests
  --ipcdisable      Disable the IPC-RPC server
  --ipcapi value    API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3")
  --ipcpath "geth.ipc"  Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  --rpccorsdomain value Comma separated list of domains from which to accept cross origin requests (browser enforced)
  --jspath loadScript   JavaScript root path for loadScript and document root for `admin.httpGet` (default: ".")
  --exec value      Execute JavaScript statement (only in combination with console/attach)
  --preload value   Comma separated list of JavaScript files to preload into the console

NETWORKING OPTIONS:
  --bootnodes value Comma separated enode URLs for P2P discovery bootstrap
  --port value      Network listening port (default: 30303)
  --maxpeers value  Maximum number of network peers (network disabled if set to 0) (default: 25)
  --maxpendpeers value  Maximum number of pending connection attempts (defaults used if set to 0) (default: 0)
  --nat value       NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
  --nodiscover      Disables the peer discovery mechanism (manual peer addition)
  --nodekey value   P2P node key file
  --nodekeyhex value    P2P node key as hex (for testing)

MINER OPTIONS:
  --mine            Enable mining
  --minerthreads value      Number of CPU threads to use for mining (default: 8)
  --minergpus value     List of GPUs to use for mining (e.g. '0,1' will use the first two GPUs found)
  --autodag         Enable automatic DAG pregeneration
  --etherbase value     Public address for block mining rewards (default = first account created) (default: "0")
  --targetgaslimit value    Target gas limit sets the artificial target gas floor for the blocks to mine (default: "4712388")
  --gasprice value      Minimal gas price to accept for mining a transactions (default: "20000000000")
  --extradata value     Block extra data set by the miner (default = client version)

GAS PRICE ORACLE OPTIONS:
  --gpomin value    Minimum suggested gas price (default: "20000000000")
  --gpomax value    Maximum suggested gas price (default: "500000000000")
  --gpofull value   Full block threshold for gas price calculation (%) (default: 80)
  --gpobasedown value   Suggested gas price base step down ratio (1/1000) (default: 10)
  --gpobaseup value Suggested gas price base step up ratio (1/1000) (default: 100)
  --gpobasecf value Suggested gas price base correction factor (%) (default: 110)

VIRTUAL MACHINE OPTIONS:
  --jitvm       Enable the JIT VM
  --forcejit        Force the JIT VM to take precedence
  --jitcache value  Amount of cached JIT VM programs (default: 64)

LOGGING AND DEBUGGING OPTIONS:
  --metrics         Enable metrics collection and reporting
  --fakepow         Disables proof-of-work verification
  --verbosity value     Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=detail (default: 3)
  --vmodule value       Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=6,p2p=5)
  --backtrace value     Request a stack trace at a specific logging statement (e.g. "block.go:271") (default: :0)
  --pprof           Enable the pprof HTTP server
  --pprofport value     pprof HTTP server listening port (default: 6060)
  --memprofilerate value    Turn on memory profiling with the given rate (default: 524288)
  --blockprofilerate value  Turn on block profiling with the given rate (default: 0)
  --cpuprofile value        Write CPU profile to the given file
  --trace value         Write execution trace to the given file

EXPERIMENTAL OPTIONS:
  --shh     Enable Whisper
  --natspec Enable NatSpec confirmation notice

MISCELLANEOUS OPTIONS:
  --solc value      Solidity compiler command to be used (default: "solc")
  --support-dao-fork    Updates the chain rules to support the DAO hard-fork
  --oppose-dao-fork Updates the chain rules to oppose the DAO hard-fork
  --help, -h        顯示幫助
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末鸦做,一起剝皮案震驚了整個濱河市励烦,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌泼诱,老刑警劉巖坛掠,帶你破解...
    沈念sama閱讀 218,546評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡屉栓,警方通過查閱死者的電腦和手機舷蒲,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,224評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來友多,“玉大人牲平,你說我怎么就攤上這事∮蚶模” “怎么了纵柿?”我有些...
    開封第一講書人閱讀 164,911評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長启绰。 經(jīng)常有香客問我藐窄,道長,這世上最難降的妖魔是什么酬土? 我笑而不...
    開封第一講書人閱讀 58,737評論 1 294
  • 正文 為了忘掉前任荆忍,我火速辦了婚禮,結(jié)果婚禮上撤缴,老公的妹妹穿的比我還像新娘刹枉。我一直安慰自己,他們只是感情好屈呕,可當(dāng)我...
    茶點故事閱讀 67,753評論 6 392
  • 文/花漫 我一把揭開白布微宝。 她就那樣靜靜地躺著,像睡著了一般虎眨。 火紅的嫁衣襯著肌膚如雪蟋软。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,598評論 1 305
  • 那天嗽桩,我揣著相機與錄音岳守,去河邊找鬼。 笑死碌冶,一個胖子當(dāng)著我的面吹牛湿痢,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播扑庞,決...
    沈念sama閱讀 40,338評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼譬重,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了罐氨?” 一聲冷哼從身側(cè)響起臀规,我...
    開封第一講書人閱讀 39,249評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎栅隐,沒想到半個月后塔嬉,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體玩徊,經(jīng)...
    沈念sama閱讀 45,696評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,888評論 3 336
  • 正文 我和宋清朗相戀三年邑遏,在試婚紗的時候發(fā)現(xiàn)自己被綠了佣赖。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,013評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡记盒,死狀恐怖憎蛤,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情纪吮,我是刑警寧澤俩檬,帶...
    沈念sama閱讀 35,731評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站碾盟,受9級特大地震影響棚辽,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜冰肴,卻給世界環(huán)境...
    茶點故事閱讀 41,348評論 3 330
  • 文/蒙蒙 一屈藐、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧熙尉,春花似錦联逻、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,929評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至铅歼,卻和暖如春公壤,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背椎椰。 一陣腳步聲響...
    開封第一講書人閱讀 33,048評論 1 270
  • 我被黑心中介騙來泰國打工厦幅, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人俭识。 一個月前我還...
    沈念sama閱讀 48,203評論 3 370
  • 正文 我出身青樓慨削,卻偏偏與公主長得像,于是被迫代替她去往敵國和親套媚。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,960評論 2 355