Heco 网络公开归档节点

在Heco 官方的大力支持之下,HyperGraph 架设了两个公开使用的归档节点,以供大家使用。此节点支持 RPC 与 WS 方式使用,但是鉴于是公共免费资源,请不要过度使用,或者用于长期和大规模的数据服务。

具体配置与测试方式如下:

节点1:

http 方式:

URL:

https://pub001.hg.network/rpc

WS 方式:

URL:

wss://pub001.hg.network/ws

在MetaMask 中连接配置如下图:

可以使用 RPC 方式对1号节点进行测试,分别获取chain ID 和最新区块号,结果如下:

# curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' -H "Content-Type: application/json" https://pub001.hg.network/rpc

{"jsonrpc":"2.0","id":1,"result":"0x80"}

# curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" https://pub001.hg.network/rpc

{"jsonrpc":"2.0","id":1,"result":"0x6479e9"}

你可以编写如下代码,测试Websocket 协议的连通情况:

var Web3 = require('web3');

var web3 = new Web3('wss://pub001.hg.network/ws');

subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {})

.on("data", function (transactionHash) {

web3.eth.getTransaction(transactionHash)

.then(function (transaction) {

console.log(transaction)

});

})

如果正确,将输出如下图

节点2:

http 方式:

URL:

https://pub002.hg.network/rpc

WS 方式:

URL:

wss://pub002.hg.network/ws

在MetaMask 中连接配置如下图:

可以使用 RPC 方式对2号节点进行测试,分别获取chain ID 和最新区块号,结果如下:

# curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' -H "Content-Type: application/json" https://pub002.hg.network/rpc

{"jsonrpc":"2.0","id":1,"result":"0x80"}

# curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" https://pub002.hg.network/rpc

{"jsonrpc":"2.0","id":1,"result":"0x6479ea"}

你可以编写如下代码,测试Websocket 协议的连通情况:

var Web3 = require('web3');

var web3 = new Web3('wss://pub002.hg.network/ws');

subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {})

.on("data", function (transactionHash) {

web3.eth.getTransaction(transactionHash)

.then(function (transaction) {

console.log(transaction)

});

})

如果正确,将输出如下图

Last updated