![](/img/trans.png)
[英]How to get all balances for some account using Web3.js and Node.js?
[英]Web3.js not giving accounts back using geth node
我正在使用帶有標志的Geth節點
geth --networkid'49'--datadir'E:\\ Dir'--rpc –rpcapi'web3,net,personal,admin,eth'--rpccorsdomain'*'控制台
我正在嘗試使用Web3.js獲取帳戶。 每當我嘗試請求使用帳戶時。
web3.eth.accounts [0]
要么
web3.eth.getAccounts(帳戶=> console.log(帳戶));
我收到一個錯誤,因此在打印整個Web3響應時,那里沒有任何帳戶,它顯示以下錯誤。
[異常:錯誤:連接錯誤:無法連接到節點http:// localhost:8545 。 在Object.InvalidConnection( http://127.0.0.1:8080/node_modules/web3/dist/web3.js:3137:16 )在HttpProvider.send( http://127.0.0.1:8080/node_modules/web3/dist/在Eth.get的RequestManager.send( http://127.0.0.1:8080/node_modules/web3/dist/web3.js:6357:32 )上的web3.js:4350:18 )[作為帳戶]( http:// 127.0.0.1:8080/node_modules/web3/dist/web3.js:6260:62 )位於Eth.remoteFunction(:2:14)]
當我嘗試不運行HTPP-SERVER的index.html頁面時,錯誤是
無法加載http:// localhost:8545 / :對預檢請求的響應未通過訪問控制檢查:響應中“ Access-Control-Allow-Credentials”標頭的值是“必須為true”當請求的憑據模式為“包含”時。 因此,不允許訪問原始“空”。 XMLHttpRequest發起的請求的憑據模式由withCredentials屬性控制。 HttpProvider.send @ web3.js:4348
未捕獲的錯誤:連接錯誤:無法連接到節點http:// localhost:8545 。 在HttpProvider.send(web3.js:4350)在ObjectManager.send(web3.js:6357)在Eth.get [作為帳戶](web3.js:6260)在HttpProvider.send(web3.js:4350)在Object.InvalidConnection(web3.js:3137) html的:50
我不知道問題出在哪里..在geth節點中的標志或Js中的某些方法是否有任何問題? 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.