0

我正在尝试扫描 BSC 上的智能合约创建,但处理在几秒/分钟后停止。有时它会持续更长时间。当它停止时,退出代码为 0。

你能知道我在下面的代码(用 WebStorm 制作)中做错了什么吗?

谢谢

const Web3 = require('web3');
const ethers = require('ethers');

const web3 = new Web3('https://bsc-dataseed1.binance.org:443');

const addresses = {
    WBNB: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
    factory: '0xca143ce32fe78f1f7019d7d551a6402fc5350c73',
    router: '0x10ed43c718714eb63d5aa57b78b54704e256024e',
    recipient: '0xEb519e65aC906F9c670971776851CD7d25848daA'
};

const mnemonic = 'REPLACE';
const provider = new ethers.providers.WebSocketProvider('wss://bsc-ws-node.nariox.org:443');

const wallet = new ethers.Wallet(mnemonic);
const account2 = wallet.connect(provider);

const factory = new ethers.Contract(
    addresses.factory,
    [
        'event PairCreated(address indexed token0, address indexed token1, address pair, uint)',
        'function getPair(address tokenA, address tokenB) external view returns (address pair)'
    ],
    account2
);

console.log('BOT STARTED');
factory.on('PairCreated', async (token0, token1, pairAddress) => {
    console.log("new token pair created on bsc : " + token0 + " " + token1)
})
4

0 回答 0