Json-Rpc

除了 Geth 和 Mist 之外,還有其他提供 Javascript 控制台的軟體嗎?我想使用控制台,但我不想進行所有同步

  • April 2, 2017

除了 Geth 和 Mist 之外,還有其他提供 Javascript 控制台的軟體嗎?我想使用控制台,但我不想進行所有同步。

據我所知,Parity 沒有控制台,MetaMask 也沒有。還有其他軟體嗎?

Try geth --light console,自 v1.5.2 起可用,但列在“實驗功能”下。即使不是幾秒鐘,也可以在幾分鐘內同步。

更新- 初始同步耗時 11 分鐘。隨後,同步 7 小時的塊花費了 8 秒。

我將在下面記錄一些輕客戶端統計資訊。

以下是一些統計數據(目前塊是2972​​534

Iota:geth user$ geth --light console
...
I0111 08:34:43.034258 eth/downloader/downloader.go:326] Block synchronisation started
I0111 08:34:48.181285 core/headerchain.go:331] imported 192 headers in    2.083s. #2609343 [20a7f505… / f422ad5d…]
...
0111 08:37:30.529558 core/headerchain.go:331] imported 384 headers in  68.146ms. #2695167 [eeb0e8b4… / b3e90f82…]
I0111 08:37:30.750613 core/headerchain.go:331] imported 192 headers in  36.462ms. #2695359 [f19dec17… / 2d39932d…]
...
I0111 08:42:07.574887 core/headerchain.go:331] imported 768 headers in 145.734ms. #2854143 [3878698c… / a6998900…]
I0111 08:42:07.643398 core/headerchain.go:331] imported 192 headers in  57.545ms. #2854335 [6a726c3c… / 96647a62…]
...
I0111 08:43:32.513446 core/headerchain.go:331] imported 384 headers in  70.834ms. #2900991 [db81a3ae… / 2da617ae…]
I0111 08:43:34.986411 core/headerchain.go:331] imported 1344 headers in 295.133ms. #2902335 [49e9082a… / a59aa59f…]
...
I0111 08:45:47.420502 core/headerchain.go:331] imported 143 headers in 240.806ms. #2972558 [ab60d4f7… / 86202d19…]
I0111 08:45:52.135652 core/headerchain.go:331] imported 1 headers in   5.174ms. #2972559 [0a53cdc5… / 0a53cdc5…]
I0111 08:45:58.738955 core/headerchain.go:331] imported 1 headers in   5.570ms. #2972560 [1a98b864… / 1a98b864…]

檢查佔用的磁碟空間量:

Iota:geth user$ pwd
/Users/user/Library/Ethereum/geth
Iota:geth user$ ls -al
total 0
drwx------      5 user staff      170 11 Jan 08:34 .
drwxr-xr-x     10 user staff      340 11 Jan 08:46 ..
-rw-r--r--      1 user staff        0 19 Nov 00:30 LOCK
drwxr-xr-x  61204 user staff  2080936 11 Jan 08:28 chaindata
drwxr-xr-x     69 user staff     2346 11 Jan 08:45 lightchaindata
Iota:geth user$ du -hs *
 0B      LOCK
109G      chaindata
139M  lightchaindata

檢查隨機賬戶0x5d03a3e0ab0fd3b00f1c3654b0765d923960c464餘額,目前是來自 EtherScan 的 4.03604217 ETH。

Iota:geth user$ geth --light console
...
> eth.syncing
{
 currentBlock: 2972561,
 highestBlock: 2972575,
 knownStates: 0,
 pulledStates: 0,
 startingBlock: 2972561
}
I0111 08:50:26.838756 core/headerchain.go:331] imported 0 headers (1 ignored) in  92.695µs. #2972578 [0da2ff52… / 0da2ff52…]
> web3.fromWei(eth.getBalance("0x5d03a3e0ab0fd3b00f1c3654b0765d923960c464"), "ether")
4.03604217

使用How do I retrieve the Voted events from The DAO中的程式碼檢查 DAO 事件的檢索,但僅 10 個塊,需要 12 秒:

I0111 08:59:06.052210 core/headerchain.go:331] imported 0 headers (1 ignored) in  73.395µs. #2972619 [952243d6… / 952243d6…]
> var theDAOInterfaceABI = [{ "constant": true, "inputs": [{ "name": "", "type": "uint256" }], "name": "proposals", "outputs": [{ "name": "recipient", "type": "address" }, { "name": "amount", "type": "uint256" }, { "name": "description", "type": "string" }, { "name": "votingDeadline", "type": "uint256" }, { "name": "open", "type": "bool" }, { "name": "proposalPassed", "type": "bool" }, { "name": "proposalHash", "type": "bytes32" }, { "name": "proposalDeposit", "type": "uint256" }, { "name": "newCurator", "type": "bool" }, { "name": "yea", "type": "uint256" }, { "name": "nay", "type": "uint256" }, { "name": "creator", "type": "address" }], "type": "function" }, { "constant": true, "inputs": [], "name": "rewardAccount", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": true, "inputs": [], "name": "daoCreator", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_proposalID", "type": "uint256" }, { "name": "_transactionData", "type": "bytes" }], "name": "executeProposal", "outputs": [{ "name": "_success", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [], "name": "unblockMe", "outputs": [{ "name": "", "type": "bool" }], "type": "function" }, { "constant": true, "inputs": [], "name": "totalRewardToken", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "allowedRecipients", "outputs": [{ "name": "", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_to", "type": "address" }, { "name": "_amount", "type": "uint256" }], "name": "transferWithoutReward", "outputs": [{ "name": "success", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_recipient", "type": "address" }, { "name": "_amount", "type": "uint256" }, { "name": "_description", "type": "string" }, { "name": "_transactionData", "type": "bytes" }, { "name": "_debatingPeriod", "type": "uint256" }, { "name": "_newCurator", "type": "bool" }], "name": "newProposal", "outputs": [{ "name": "_proposalID", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "DAOpaidOut", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [], "name": "minQuorumDivisor", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_newContract", "type": "address" }], "name": "newContract", "outputs": [], "type": "function" }, { "constant": false, "inputs": [{ "name": "_recipient", "type": "address" }, { "name": "_allowed", "type": "bool" }], "name": "changeAllowedRecipients", "outputs": [{ "name": "_success", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [], "name": "halveMinQuorum", "outputs": [{ "name": "_success", "type": "bool" }], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "paidOut", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_proposalID", "type": "uint256" }, { "name": "_newCurator", "type": "address" }], "name": "splitDAO", "outputs": [{ "name": "_success", "type": "bool" }], "type": "function" }, { "constant": true, "inputs": [], "name": "DAOrewardAccount", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": true, "inputs": [], "name": "proposalDeposit", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [], "name": "numberOfProposals", "outputs": [{ "name": "_numberOfProposals", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [], "name": "lastTimeMinQuorumMet", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_toMembers", "type": "bool" }], "name": "retrieveDAOReward", "outputs": [{ "name": "_success", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [], "name": "receiveEther", "outputs": [{ "name": "", "type": "bool" }], "type": "function" }, { "constant": true, "inputs": [{ "name": "_proposalID", "type": "uint256" }], "name": "getNewDAOAddress", "outputs": [{ "name": "_newDAO", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_proposalID", "type": "uint256" }, { "name": "_supportsProposal", "type": "bool" }], "name": "vote", "outputs": [{ "name": "_voteID", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [], "name": "getMyReward", "outputs": [{ "name": "_success", "type": "bool" }], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "rewardToken", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_from", "type": "address" }, { "name": "_to", "type": "address" }, { "name": "_amount", "type": "uint256" }], "name": "transferFromWithoutReward", "outputs": [{ "name": "success", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_proposalDeposit", "type": "uint256" }], "name": "changeProposalDeposit", "outputs": [], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "blocked", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [], "name": "curator", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": true, "inputs": [{ "name": "_proposalID", "type": "uint256" }, { "name": "_recipient", "type": "address" }, { "name": "_amount", "type": "uint256" }, { "name": "_transactionData", "type": "bytes" }], "name": "checkProposalCode", "outputs": [{ "name": "_codeChecksOut", "type": "bool" }], "type": "function" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "recipient", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "newCurator", "type": "bool" }, { "indexed": false, "name": "description", "type": "string" }], "name": "ProposalAdded", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "position", "type": "bool" }, { "indexed": true, "name": "voter", "type": "address" }], "name": "Voted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "result", "type": "bool" }, { "indexed": false, "name": "quorum", "type": "uint256" }], "name": "ProposalTallied", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "_newCurator", "type": "address" }], "name": "NewCurator", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "_recipient", "type": "address" }, { "indexed": false, "name": "_allowed", "type": "bool" }], "name": "AllowedRecipientChanged", "type": "event" }];
undefined
> var theDAOAddress = "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413";
undefined
> var theDAOInterface = web3.eth.contract(theDAOInterfaceABI).at(theDAOAddress);
undefined
> var theDAOVotedEvent = theDAOInterface.Voted({}, { fromBlock: 1630418, toBlock: 1630428 });
undefined
> var i = 0;
undefined
> theDAOVotedEvent.watch(function (error, result) {
   console.log(i++ + ": " + JSON.stringify(result));
});
...
0: {"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":false,"proposalID":"3","voter":"0x89dbadfc48054057b6c9c378f6edf9d15d8b1d68"},"blockHash":null,"blockNumber":null,"event":"Voted","logIndex":0,"removed":false,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":0}
1: {"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":true,"proposalID":"15","voter":"0xcd0a161bc367ae0927a92aac9cf6e5086714efca"},"blockHash":null,"blockNumber":null,"event":"Voted","logIndex":0,"removed":false,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":0}
2: {"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":true,"proposalID":"15","voter":"0x89dbadfc48054057b6c9c378f6edf9d15d8b1d68"},"blockHash":null,"blockNumber":null,"event":"Voted","logIndex":0,"removed":false,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":0}
I0111 08:59:18.066685 core/headerchain.go:331] imported 1 headers in   9.304ms. #2972620 [591a881e… / 591a881e…]

我現在將嘗試檢索 1,000 個塊的事件:

I0111 09:07:13.141814 core/headerchain.go:331] imported 0 headers (1 ignored) in  91.993µs. #2972655 [aca94ac7… / aca94ac7…]
> var theDAOVotedEvent = theDAOInterface.Voted({}, { fromBlock: 1630428, toBlock: 1631428 });
undefined
> var i = 0;
undefined
> theDAOVotedEvent.watch(function (error, result) {
   console.log(i++ + ": " + JSON.stringify(result));
});
I0111 09:07:32.414297 core/headerchain.go:331] imported 1 headers in   5.613ms. #2972656 [4de4e836… / 4de4e836…]
// Still no data
I0111 09:12:04.476901 core/headerchain.go:331] imported 1 headers in   5.037ms. #2972686 [e8742c05… / e8742c05…]
// Still no data. Exiting program.
I0111 09:14:20.093697 core/headerchain.go:331] imported 1 headers in   5.376ms. #2972690 [c86f8399… / c86f8399…]

我退出geth並重新啟動geth --light console並執行與上一節相同的命令以從 1,000 個塊中檢索事件,結果在 15 秒內返回。

I0111 09:15:39.512646 core/headerchain.go:331] imported 0 headers (1 ignored) in  75.565µs. #2972693 [7321330d… / 7321330d…]
> var theDAOInterfaceABI = [{ "constant": true ...
...
var theDAOVotedEvent = theDAOInterface.Voted({}, { fromBlock: 1630428, toBlock: 1631428 });
undefined
> var i = 0;
undefined
> theDAOVotedEvent.watch(function (error, result) {
   console.log(i++ + ": " + JSON.stringify(result));
});
I0111 09:15:52.424066 core/headerchain.go:331] imported 1 headers in   6.768ms. #2972694 [40492702… / 40492702…]
I0111 09:15:52.543705 core/headerchain.go:331] imported 0 headers (1 ignored) in   73.79µs. #2972694 [40492702… / 40492702…]
I0111 09:16:10.304987 core/headerchain.go:331] imported 1 headers in   5.613ms. #2972695 [60cc2682… / 60cc2682…]
0: {"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":true,"proposalID":"17","voter":"0x89dbadfc48054057b6c9c378f6edf9d15d8b1d68"},"blockHash":null,"blockNumber":null,"event":"Voted","logIndex":0,"removed":false,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":0}
1: {"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":true,"proposalID":"5","voter":"0x1a51e74e25825b4ff2d0110ced7a46e0405259cd"},"blockHash":null,"blockNumber":null,"event":"Voted","logIndex":0,"removed":false,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":0}
...
29: {"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":true,"proposalID":"17","voter":"0xeef5d8bb8391dccfc606047cf65e3fb24379acf5"},"blockHash":null,"blockNumber":null,"event":"Voted","logIndex":0,"removed":false,"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":0}
I0111 09:16:25.950938 core/headerchain.go:331] imported 1 headers in   5.576ms. #2972696 [59f8d25c… / 59f8d25c…]
I0111 09:16:31.604916 core/headerchain.go:331] imported 1 headers in   7.879ms. #2972697 [5b8f6907… / 5b8f6907…]

結論:

  1. geth --light對於從區塊鏈的歷史部分檢索事件,目前似乎有點不穩定。第一次從 1000 個塊中檢索事件並沒有在合理的時間內返回數據(我等了 7 分鐘)。我停止geth並重新啟動它並再次執行相同的命令。1,000 個區塊的區塊數據已經下載,並且在 15 秒內第二次檢索到事件。
  2. 但如果您只需要目前數據,同步和性能似乎相當不錯。

更新

同步 7 小時的塊花費了 8 秒:

> I0111 16:10:43.598515 eth/downloader/downloader.go:326] Block synchronisation started
I0111 16:10:47.586689 contracts/release/release.go:134] Failed to retrieve current release: Missing trie node f62d536cd4f1bfd9b0b5d2d1a989ea2ca40f9fb4bbdee93fc346addf0d83b9c3
I0111 16:10:49.137822 core/headerchain.go:331] imported 576 headers in    2.053s. #2973345 [d94df51e… / d096138a…]
I0111 16:10:49.209909 core/headerchain.go:331] imported 192 headers in  62.450ms. #2973537 [2fefee19… / d3bfd1eb…]
I0111 16:10:49.323178 core/headerchain.go:331] imported 384 headers in  89.319ms. #2973921 [f7365657… / d3b513bb…]
I0111 16:10:49.942067 core/headerchain.go:331] imported 192 headers in  39.532ms. #2974113 [8f08532d… / 971d6b2c…]
I0111 16:10:52.490579 core/headerchain.go:331] imported 192 headers in  43.145ms. #2974305 [ddd9974a… / 92a3086d…]
I0111 16:10:55.263782 core/headerchain.go:331] imported 121 headers in 155.070ms. #2974426 [907785ea… / f2daed7b…]
> eth.syncing
false
> I0111 16:11:17.416889 core/headerchain.go:331] imported 1 headers in   7.214ms. #2974427 [3dbe6f83… / 3dbe6f83…]
I0111 16:11:17.467800 core/headerchain.go:331] imported 0 headers (1 ignored) in  63.661µs. #2974427 [3dbe6f83… / 3dbe6f83…]
I0111 16:11:17.765045 core/headerchain.go:331] imported 0 headers (1 ignored) in  81.887µs. #2974427 [3dbe6f83… / 3dbe6f83…]
I0111 16:11:25.297098 core/headerchain.go:331] imported 1 headers in   5.074ms. #2974428 [f8717170… / f8717170…]
I0111 16:11:25.435765 core/headerchain.go:331] imported 0 headers (1 ignored) in  72.059µs. #2974428 [f8717170… / f8717170…]

我現在正在做的是使用TestRPC作為瀏覽器 Solidity 作為Chrome 擴展的 Web3 提供程序。

然後,您可以開發和執行 DAPP 前端,並使用 Chrome 控制台與 web3 進行互動。

引用自:https://ethereum.stackexchange.com/questions/10964