Prueba en Rinkeby

Estoy tratando de probar en Rinkeby, así que ejecuté el siguiente comando

geth --rpc --rpcaddr localhost --rpcport 8545

Dentro de mi archivo Javascript tengo el siguiente código

if (typeof web3 !== 'undefined') {
        window.web3 = new Web3(web3.currentProvider);
        console.log(`Web 3 is: ${web3}`);
    } else {
        console.log('No web3? You should consider trying MetaMask!')
        window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
        console.log(window.web3);
    }

Sin embargo, todavía registra No web3? You should consider trying MetaMask!¿Qué es exactamente lo que estoy haciendo mal aquí? Configuré Rinkeby para que esté en localhost 8545.

Aquí está mi registro de terminal

My-MacBook-Pro:opt jorah$ geth --rpc --rpcaddr localhost --rpcport 8545
WARN [12-22|13:09:53] No etherbase set and no accounts found as default 
INFO [12-22|13:09:53] Starting peer-to-peer node               instance=Geth/v1.7.3-stable/darwin-amd64/go1.9.2
INFO [12-22|13:09:53] Allocated cache and file handles         database=/Users/jorah/Library/Ethereum/geth/chaindata cache=128 handles=1024
INFO [12-22|13:09:53] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [12-22|13:09:53] Disk storage enabled for ethash caches   dir=/Users/jorah/Library/Ethereum/geth/ethash count=3
INFO [12-22|13:09:53] Disk storage enabled for ethash DAGs     dir=/Users/jorah/.ethash                      count=2
INFO [12-22|13:09:53] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [12-22|13:09:53] Loaded most recent local header          number=122324 hash=908be9…a59305 td=266307762302484554
INFO [12-22|13:09:53] Loaded most recent local full block      number=0      hash=d4e567…cb8fa3 td=17179869184
INFO [12-22|13:09:53] Loaded most recent local fast block      number=121396 hash=2944a5…a901e0 td=262160416031487320
INFO [12-22|13:09:53] Upgrading chain index                    type=bloombits percentage=86
INFO [12-22|13:09:53] Loaded local transaction journal         transactions=0 dropped=0
INFO [12-22|13:09:53] Regenerated local transaction journal    transactions=0 accounts=0
INFO [12-22|13:09:53] Starting P2P networking 
INFO [12-22|13:09:54] Finished upgrading chain index           type=bloombits
INFO [12-22|13:09:55] UDP listener up                          self=enode://14b2c0b7c271faede8b3049c0c6cb23f8f7e8b9d7cabc1cd6a852a8e6fa3d776f9189c882fa7833f5078965d919b9670782438ca7586ca3ea520848760b33179@[::]:30303
INFO [12-22|13:09:55] RLPx listener up                         self=enode://14b2c0b7c271faede8b3049c0c6cb23f8f7e8b9d7cabc1cd6a852a8e6fa3d776f9189c882fa7833f5078965d919b9670782438ca7586ca3ea520848760b33179@[::]:30303
INFO [12-22|13:09:55] IPC endpoint opened: /Users/jorah/Library/Ethereum/geth.ipc 
INFO [12-22|13:09:55] HTTP endpoint opened: http://localhost:8545 
INFO [12-22|13:10:45] Block synchronisation started 
WARN [12-22|13:10:45] Synchronisation failed, retrying         err="block download canceled (requested)"
INFO [12-22|13:11:06] Imported new block headers               count=0 elapsed=9.072ms number=121780 hash=91b038…8f47ad ignored=384
INFO [12-22|13:11:08] Imported new state entries               count=247 elapsed=6.445µs processed=247 pending=3953 retry=0 duplicate=0 unexpected=0
Si el código javascript que está vinculando se está ejecutando a través de un navegador web, debe verificar que metamask esté instalado y que apunte a la red rinkeby. Si el código JavaScript que está vinculando se ejecuta en un servidor, optaría por conectarme al punto final de IPC.

Respuestas (1)

Intente agregar las siguientes banderas también. Supongo que la parte web3 de rpcapi no se cargó con el comando que ejecutó. --rpcapi db,eth,net,web3,personaly--rpccorsdomain "*"

Comando completo ser como

geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --cache=2048  --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*"
¡Eso realmente lo resolvió! La pregunta es ¿cómo conecto MetaMask ahora? ¿Y cómo obtengo la cuenta predeterminada?
Hay dos cosas aquí, 1. si usa metamask, no necesita un nodo geth local. 2. Si desea conectar metamask a su nodo local, puede hacer clic en el menú desplegable junto a la etiqueta "red principal" desde donde puede elegir localhost 8545.
Si uso metamask, ¿cómo me conecto? Intenté hacer el if (typeof web3 !== 'undefined')para ver si estoy conectado a Rinkeby, pero siempre muestra que no estoy conectado.
Debe haber iniciado sesión en metamask y haberse conectado a la red rinkeby en él. También puede importar su cuenta en él.