当前位置:网站首页>Monitoring pancakeswap new token

Monitoring pancakeswap new token

2022-06-25 03:57:00 Blockchain research

Need to use ethers This library

Go straight to the code

const ethers = require('ethers');
const addresses = {
    WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
    router: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
    factory: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
    me: "YOUR_WALLET_ADDRESS"
}


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

let privateKey = ` Your wallet private key `;

const wallet = new ethers.Wallet(privateKey);
const account = wallet.connect(provider);

const factory = new ethers.Contract(
    addresses.factory,
    ['event PairCreated(address indexed token0, address indexed token1, address pair, uint)'],
    account,
);
const router = new ethers.Contract(
    addresses.router,
    [
        'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
        'function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)',
    ],
    account,
);

factory.on("PairCreated", async (token0, token1, addressPair) => {
    console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    console.log('token0', token0);
    console.log('token1', token1);
    console.log('addressPair', addressPair);
});

原网站

版权声明
本文为[Blockchain research]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210537010173.html

随机推荐