您好,登錄后才能下訂單哦!
打開控制臺
$ geth --datadir=path/to/custom/data/folder attach --datadir“~/.ethereum”數(shù)據(jù)庫和密鑰庫的數(shù)據(jù)目錄
創(chuàng)建賬戶,參數(shù)是密碼
在控制臺輸入下面命令:
personal.newAccount("Write here a good, randomly generated, passphrase!")
"0x0fec688d601909d28faf6fe18cf6230d08b698b6"默認(rèn)第一個創(chuàng)建的用戶為主用戶
查看用戶:
eth.accounts
["0x0fec688d601909d28faf6fe18cf6230d08b698b6"]賬戶的排序反映了他們創(chuàng)建的時間。 密鑰文件存儲在DATADIR / keystore下,可以通過復(fù)制其中包含的文件在客戶端之間傳輸。 這些文件使用密碼加密,如果它們包含任何數(shù)量的以太網(wǎng),則應(yīng)備份。 但是,請注意,如果您傳輸個別密鑰文件,則提交的帳戶順序可能會發(fā)生變化,您可能無法在同一位置結(jié)束同一帳戶。 因此請注意,只要您不將外部密鑰文件復(fù)制到您的密鑰存儲區(qū),只依賴帳戶索引即可。
personal.unlockAccount("0xf9ab190a9c56fd0d945eac9659c0c9519b13c64e")
或者
這里是給第一個賬戶解鎖
user1=eth.accounts[0]
personal.unlockAccount(user1)
開始挖礦
miner.start()
挖到一個區(qū)塊會獎勵5個以太幣,挖礦所得的獎勵會進(jìn)入礦工的賬戶,這個賬戶叫做coinbase,默認(rèn)情況下coinbase是本地賬戶中的第一個賬戶:
查看挖礦進(jìn)賬用戶
eth.coinbase
"0xf9ab190a9c56fd0d945eac9659c0c9519b13c64e"
現(xiàn)在的coinbase是賬戶0,要想使挖礦獎勵進(jìn)入其他賬戶,通過miner.setEtherbase()將其他賬戶設(shè)置成coinbase即可
設(shè)置挖礦用戶
miner.setEtherbase(eth.accounts[1])
true
eth.coinbase
"0xb89bf2a212484ef9f1bd09efcd57cf37dbb1e52f"
停止挖礦
miner.stop()
true
eth.mining
false
查看帳號余額
eth.getBalance(eth.accounts[0])
getBalance()返回值的單位是wei,wei是以太幣的最小單位,1個以太幣=10的18次方個wei。要查看有多少個以太幣,可以用web3.fromWei()將返回值換算成以太幣:
web3.fromWei(eth.getBalance(eth.accounts[0]),'ether')
340
單位轉(zhuǎn)換: Ether–> Wei
web3.toWei(1)
單位轉(zhuǎn)換: Wei –> Ether
web3.fromWei(10000000000000000)
轉(zhuǎn)賬
轉(zhuǎn)賬前需要解鎖帳號,就像輸入銀行卡號密碼
eth.sendTransaction({"from":"0x67128734480a0741595538d9d726f33addf83978", "to":"0x29a9a6bcf1ce7101ab93a029e2692298fc15e076", "gas":31000,"gasPrice":web3.toWei(300,'gwei'),"value":"1"})
"0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941"
eth.sendTransaction({"from":"0x67128734480a0741595538d9d726f33addf83978", "to":"0x29a9a6bcf1ce7101ab93a029e2692298fc15e076", "value":"10000000000000000000000"})
"0x533d3c770aed09ede826c92e7460fd38d78a101752a7b3b25e4470d8594e77bb"
查看當(dāng)前區(qū)塊總數(shù):
eth.blockNumber
69
通過區(qū)塊號查看區(qū)塊里打包的交易信息
eth.getBlock(6)
{
difficulty: 2,
extraData: "0xd783010803846765746887676f312e392e32856c696e75780000000000000000cff7302b0c5515614e52f1584ff3f6aceb10dfa6e2facb347bfe3c023878d3857fa48774a98c721bcc1fb2419a177d577a0926e9f51d037095ba53257f7f307701",
gasLimit: 6246618,
gasUsed: 21000,
hash: "0x5e2506ce385e38bbe23765a24ec25f9742e4a3a5af7cd071088081535a6a0dd2",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
nonce: "0x0000000000000000",
number: 6,
parentHash: "0x716da23fef7103042762025aabc83f7075fca516ab9dc6d436daa58b8350953b",
receiptsRoot: "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 713,
stateRoot: "0x7c93a037c0750ddca8330d9c84912c622cd355c6978fc4267ffe2c8517a32469",
timestamp: 1520398599,
totalDifficulty: 13,
transactions: ["0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941"],
transactionsRoot: "0x712b5bba767dd0ecaeebbbeefdf097647a0f219f11f16e4a8a3d768b59ae442e",
uncles: []
}
通過交易hash查看交易
eth.getTransaction("0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941")
{
blockHash: "0x5e2506ce385e38bbe23765a24ec25f9742e4a3a5af7cd071088081535a6a0dd2",
blockNumber: 6,
from: "0x67128734480a0741595538d9d726f33addf83978",
gas: 31000,
gasPrice: 300000000000,
hash: "0x54325698db1fbc85799b2f72070cddc457932abf0eef0d30d4fb2710ddafa941",
input: "0x",
nonce: 5,
r: "0xe14faca3d11a47ec4617927c84a04936dbaf783cc2187794e04299ce04352404",
s: "0x6da16b4e07a4fc721273d3b09da1c8b29ad4ce8022a99eb3f8317247cf7f5386",
to: "0x29a9a6bcf1ce7101ab93a029e2692298fc15e076",
transactionIndex: 0,
v: "0xa95",
value: 1
}
txpool.status
{
pending: 0,
queued: 0
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。