要通过geth控制台访问Clique的功能很容易,比如clique.getSnapshot(), clique.propose("address",bool)等等。但是我无法通过web3使用RPC调用来访问这些功能。当我尝试使用web3.clique.getSnapshot()时,我得到的错误是can not read property of undefined。有没有办法使用这些功能?
发布于 2018-10-01 15:36:36
集群API是一个特定于geth的扩展。您可以使用--rpcapi clique启用此功能。
然后可以发送相应的JSON调用。
例如。
curl -X POST --data '{"jsonrpc":"2.0","method":"clique_getSnapshot","params":[],"id":1}' http://localhost:8545
curl -X POST --data '{"jsonrpc":"2.0","method":"clique_getSigners","params":[],"id":1}' http://localhost:8545有关可用方法的列表,请参见https://github.com/ethereum/go-ethereum/blob/master/internal/web3ext/web3ext.go (搜索Clique_JS)。
AFAIK web3库将没有可用的集群对象,因为它是特定于geth的。
https://ethereum.stackexchange.com/questions/50080
复制相似问题