¿Hay algún software aparte de Geth and Mist que ofrezca la consola Javascript? Quiero usar la consola pero no quiero hacer toda esa sincronización.
Parity no tiene una consola que yo sepa y MetaMask tampoco. ¿Algún otro software por ahí?
Pruebe geth --light console
, disponible desde la versión 1.5.2, pero incluida en "Características experimentales". Sincroniza en minutos si no segundos .
Actualización : la sincronización inicial tardó 11 minutos. Posteriormente, la sincronización de 7 horas de bloques tomó 8 segundos.
A continuación, documentaré algunas estadísticas de clientes ligeros.
Aquí hay algunas estadísticas (el bloque actual es 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…]
Comprobación de la cantidad de espacio en disco ocupado:
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
Comprobación de un saldo de cuenta aleatoria 0x5d03a3e0ab0fd3b00f1c3654b0765d923960c464 que actualmente es 4.03604217 ETH de 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
Verificando la recuperación de los eventos de The DAO usando el código de ¿Cómo recupero los eventos Votados de The DAO?, pero solo por 10 bloques, tomó 12 segundos:
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…]
Ahora intentaré recuperar los eventos de 1000 bloques:
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…]
Salí geth
, reinicié geth --light console
y ejecuté el mismo comando que en la sección anterior para recuperar eventos de 1000 bloques y los resultados llegaron en 15 segundos.
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…]
Conclusión:
geth --light
parece un poco inestable actualmente para la recuperación de eventos de una parte histórica de la cadena de bloques. La primera recuperación de eventos de 1000 bloques no devolvió los datos en un tiempo razonable (esperé 7 minutos). Lo detuve geth
y lo reinicié y ejecuté el mismo comando nuevamente. Los datos de bloque para los 1000 bloques ya se descargaron y los eventos se recuperaron por segunda vez en 15 segundos.La sincronización de 7 horas de bloques tomó 8 segundos:
> 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…]
Lo que estoy haciendo ahora es usar TestRPC como proveedor de Web3 para Browser Solidity como una extensión de Chrome .
Luego puede desarrollar y ejecutar front-ends DAPP y usar la consola de Chrome para interactuar con web3.
La forma más fácil que encontré sería configurar una instancia de servidor virtual, instalar nodejs, instalar testrpc a través de npm y también usar el módulo Web3 como se menciona en la publicación anterior.
Este video explica cómo configurar testrpc en una instancia de AWS EC2 y cómo interactuar con él usando la consola de nodejs y Web3.
http://www.decypher.tv/series/ethereum-development/video/1
Estos son los comandos y notas de GitHub utilizados para el video.
https://gist.github.com/AlwaysBCoding/9ce09281e5e097ce8ab7add2602c2fc7#file-scripts-txt
Es posible configurar su propia consola JS para casi cualquier cliente.
Primero, adquiera web3.js. Ya sea usando npm para instalarlo, o usando un archivo HTML que incluya el web3.js
archivo real funcionará.
Luego, conéctese a su instancia a través de RPC. Con el nodo, se verá así:
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
web3.isConnected() // should return true.
Si no está familiarizado con node.js, puede obtener una consola simplemente node
en una terminal. Asegúrese de hacerlo en el directorio donde utilizó npm para instalar web3.
Alternativamente, si incluyó web3 en un archivo HTML, puede usar solo esto:
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
web3.isConnected() // also should return true.
Y luego puede usar la propia consola JS del navegador.
Sin embargo, es posible que solo puedas usar Metamask. Intente escribir web3.isConnected()
en la propia consola JS del navegador mientras usa Metamask y vea qué sucede.
Resulta que puedes usar Parity con parity --geth
para que funcione con Mist o geth attach
. Entonces puede usar la sincronización warp de Parity y luego --geth
usar la consola.
Una publicación anterior menciona la serie de tutoriales decyphertv. http://decypher.tv/series/ethereum-development La serie viene con una utilidad de línea de comandos de código abierto que le permite crear transacciones firmadas seguras para mover ether o implementar y manipular contratos. Luego los envía a INFURA si lo desea todo sin necesidad de ejecutar un nodo.
Soy estudiante de esta serie y la recomiendo ampliamente.
Rob Hitchens