Ich versuche, auf Rinkeby zu testen, also habe ich den folgenden Befehl ausgeführt
geth --rpc --rpcaddr localhost --rpcport 8545
In meiner Javascript-Datei habe ich den folgenden Code
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);
}
Es protokolliert jedoch immer noch No web3? You should consider trying MetaMask!
Was genau mache ich hier falsch? Ich habe Rinkeby auf localhost 8545 gesetzt.
Hier ist mein Terminal-Log
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
Versuchen Sie auch, die folgenden Flags hinzuzufügen. Ich gehe davon aus, dass der web3-Teil von rpcapi nicht mit dem von Ihnen ausgeführten Befehl geladen wurde. --rpcapi db,eth,net,web3,personal
Und--rpccorsdomain "*"
Vollständiger Befehl sein wie
geth --rinkeby --rpc --rpcapi db,eth,net,web3,personal --cache=2048 --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*"
if (typeof web3 !== 'undefined')
zu tun, um zu sehen, ob ich mit Rinkeby verbunden bin, aber es zeigt immer, dass ich nicht verbunden bin.
hextet