We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console.log("\n1. 连接 wss RPC") // 准备 alchemy API 可以参考https://github.com/AmazingAng/WTFSolidity/blob/main/Topics/Tools/TOOL04_Alchemy/readme.md const ALCHEMY_MAINNET_WSSURL = 'wss://eth-mainnet.g.alchemy.com/v2/oKmOQKbneVkxgHZfibs-iFhIlIAl6HDN'; const provider = new ethers.providers.WebSocketProvider(ALCHEMY_MAINNET_WSSURL); let i =0 provider.on("pending", async (txHash) => { if (txHash && i < 100) { // 打印txHash console.log([${(new Date).toLocaleTimeString()}] 监听Pending交易 ${i}: ${txHash} \r); i++ } }); provider ._websocket.on("error", async () => { console.log(Unable to connect to ${ep.subdomain} retrying in 3s...); setTimeout(listen_address, 3000); }); provider ._websocket.on("close", async (code) => { console.log( Connection lost with code ${code}! Attempting reconnect in 3s... ); provider ._websocket.terminate(); setTimeout(listen_address, 3000); });
[${(new Date).toLocaleTimeString()}] 监听Pending交易 ${i}: ${txHash} \r
Unable to connect to ${ep.subdomain} retrying in 3s...
Connection lost with code ${code}! Attempting reconnect in 3s...
求问一下,在第19节 Mempool里,如果是在 ethers v5里,以上的 provider ._websocket.on("error", async () => {});代码是可以正常捕获错误,延时后继续推送交易的; 但是在ethers V6里provider 定义变了 const provider = new ethers.WebSocketProvider(ALCHEMY_MAINNET_WSSURL);然后这个捕获异常provider ._websocket.on("error", async () => {})就不能用了,请问V6里捕获websocket error是怎么用的呢?谢谢大佬,往不吝赐教!
The text was updated successfully, but these errors were encountered:
可以参考V6的官方文档: https://docs.ethers.org/v6/search/?search=websocket
Sorry, something went wrong.
provider.websocket.onerror = async () => { console.log(``); };
No branches or pull requests
console.log("\n1. 连接 wss RPC")
// 准备 alchemy API 可以参考https://github.com/AmazingAng/WTFSolidity/blob/main/Topics/Tools/TOOL04_Alchemy/readme.md
const ALCHEMY_MAINNET_WSSURL = 'wss://eth-mainnet.g.alchemy.com/v2/oKmOQKbneVkxgHZfibs-iFhIlIAl6HDN';
const provider = new ethers.providers.WebSocketProvider(ALCHEMY_MAINNET_WSSURL);
let i =0
provider.on("pending", async (txHash) => {
if (txHash && i < 100) {
// 打印txHash
console.log(
[${(new Date).toLocaleTimeString()}] 监听Pending交易 ${i}: ${txHash} \r
);i++
}
});
provider ._websocket.on("error", async () => {
console.log(
Unable to connect to ${ep.subdomain} retrying in 3s...
);setTimeout(listen_address, 3000);
});
provider ._websocket.on("close", async (code) => {
console.log(
Connection lost with code ${code}! Attempting reconnect in 3s...
);
provider ._websocket.terminate();
setTimeout(listen_address, 3000);
});
求问一下,在第19节 Mempool里,如果是在 ethers v5里,以上的 provider ._websocket.on("error", async () => {});代码是可以正常捕获错误,延时后继续推送交易的;
但是在ethers V6里provider 定义变了 const provider = new ethers.WebSocketProvider(ALCHEMY_MAINNET_WSSURL);然后这个捕获异常provider ._websocket.on("error", async () => {})就不能用了,请问V6里捕获websocket error是怎么用的呢?谢谢大佬,往不吝赐教!
The text was updated successfully, but these errors were encountered: