我在web3 1.0.0-beta.27
上运行了一个私有区块链,名为: geth -identity“节点”-node最大节点0-datadir path/to/data -networkid 123 -ws-w吻合8546 -wsport "*“控制台。
然后,在一个app.ts
文件中我有:
import * as Web3 from 'web3';
var web3 = new Web3(new Web3.providers.WebsocketProvider('ws://localhost:8546'));
web3.eth.getAccounts().then(accounts => {
var sender = accounts[0];
web3.eth.personal.unlockAccount(sender, 'password');
});
但我错了:
Unhandled rejection Error: Returned error: The method personal_newAccount does not exist/is not available
在网上搜索这个问题,我应该用geth
启动--rpcapi="db,eth,net,web3,personal,web3"
进程,但是添加这个标志没有帮助,尽管rpc
只是一种ipc
,对吗?
此外,在geth控制台上,我可以用
personal.unlockAccount(sender, 'password')
发布于 2018-01-15 09:45:17
您将personal
添加到rpcapi
,但正在通过WS进行连接。您需要将它添加到wsapi
中。
rpc只是一种ipc,对吗?
3种连接协议是IPC-RPC、JSON-RPC和WS.rpc*
配置参数用于JSON (over ),而不是IPC/WS。
https://stackoverflow.com/questions/48268026
复制相似问题