4

Is there any software apart from Geth and Mist that offers the Javascript console? I want to use the console but I don't want to do all that syncing.

Parity does not have a console as far as I know and neither does MetaMask. Any other software out there?

1
  • You might consider running Geth with a private chain. There are quite a few tutorials about how to set it up. The gist is 1) initialize the database 2) start the node 3) start mining. Mining is important because if no one is mining, you won't get expected results and that will lead to confusion. Mining is pretty verbose and although you get a console, the messages will get in your way, so 4) attach to the node from another terminal. Commented Dec 27, 2016 at 16:25

6 Answers 6

5

Try geth --light console, available since v1.5.2, but listed under "Experimental Features". Syncs in minutes if not seconds.

Update - The initial sync took 11 minutes. Subsequently, syncing 7 hours worth of blocks took 8 seconds.

I'll document some light client stats below.

Here are some stats (the current block is 2972534:

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…]

Checking the amount of disk space taken:

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

Checking a random account 0x5d03a3e0ab0fd3b00f1c3654b0765d923960c464 balance which is currently 4.03604217 ETH from EtherScan.

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

Checking the retrieval of The DAO events using the code from How do I retrieve the Voted events from The DAO, but only for 10 blocks, it took 12 seconds:

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…]

I'll now try to retrieve the events for 1,000 blocks:

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…]

I exited geth and restarted geth --light console and ran the same command as the previous section to retrieve events from 1,000 blocks and the results came back in 15 seconds.

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…]

Conclusion:

  1. geth --light seems a bit unstable currently for the retrieval of events from a historical part of the blockchain. The first retrieval of events from 1,000 blocks did not return the data in a reasonable time (I waited 7 minutes). I stopped geth and restarted it and ran the same command again. The block data for the 1,000 blocks was already downloaded and the events were retrieved the second time in 15 seconds.
  2. But the syncing and performance seems pretty good if you just need the current data.

Update

Syncing 7 hours worth of blocks took 8 seconds:

> 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…]
2
  • Hi @BokkyPooBah. I have tested web3.fromWei(eth.getBalance("0x5d03a3e0ab0fd3b00f1c3654b0765d923960c464"), "ether") 4.03604217 but unfortunately I get the wrong answer from Geth, namely "0" and not the value you have posted above. Why and can it be rectified?
    – Vesa
    Commented Jan 30, 2017 at 18:50
  • 1
    Wait! I just checked with Etherscan and noticed that the address you used has been subsequently emptied. When I checked with another semi random address like so I got the right amount: web3.fromWei(eth.getBalance("0x4366dDc115d8cF213c564da36e64C8ebaA30CdBD"), "ether") So then it actually seems to be working and maybe I can start actually using Geth for meaningful stuff ; ) Hooray!
    – Vesa
    Commented Jan 30, 2017 at 18:54
4

What I'm doing now is using TestRPC as the Web3 provider to Browser Solidity as a Chrome extension.

You can then develop and run DAPP front-ends and use the Chrome console to interact with web3.

2

The easiest way I found would be to set up a virtual server instance, install nodejs, install the testrpc through npm and also use the Web3 module as mentioned in the post above.

This video goes over how to set up the testrpc on an AWS EC2 instance and how to interact with it using the nodejs console and Web3.

http://www.decypher.tv/series/ethereum-development/video/1

Here are the GitHub commands and notes used for the video.

https://gist.github.com/AlwaysBCoding/9ce09281e5e097ce8ab7add2602c2fc7#file-scripts-txt

2
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Commented Dec 28, 2016 at 15:32
  • Thanks, went ahead and added some more context before the link posts. It's a lot of commands to follow so I posted the link to the notes used to set up the development environment. Commented Dec 29, 2016 at 18:46
1

It's possible to rig up your own JS console for just about any client.

First, acquire web3.js. Either by using npm to install it, or using an HTML file that includes the actual web3.js file will work.

Then connect to your instance over RPC. With node, that'll look something like this:

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
web3.isConnected() // should return true.

If you're not familiar with node.js, you can get a console with just plain node in a terminal. Be sure to do it in the directory where you used npm to install web3.

Alternately, if you included web3 in an HTML file, you can use just this:

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
web3.isConnected() // also should return true.

And then you can use the browser's own JS console.

But you might be able to just use Metamask, though. Try typing web3.isConnected() in the browser's own JS console while using Metamask and see what happens.

1

It turns out that you can use Parity with parity --geth in order for it to work with Mist or geth attach. So you can use Parity's warp sync, and then --geth to use the console.

0

A post above mentions the decyphertv tutorial series. http://decypher.tv/series/ethereum-development The series comes with an open source command line utility that allows you to create secure signed transactions for moving ether or to deploy and manipulate contracts. It then sends them to INFURA if you wish all without the need to run a node.

I am a student of this series and I recommend it highly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.