pancakeswap批量抢跑机器

这篇具有很好参考价值的文章主要介绍了pancakeswap批量抢跑机器。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

这个机器人主要是用来在pancakeswap开盘时抢先购买token。

界面图

pancakeswap批量抢跑机器,区块链,以太坊,bsc,区块链,bsc,智能合约,Powered by 金山文档

完整代码是用vue写的,现在先来个学习版的方便小白理解

这个学习版只有单个抢先的功能,完整版在GitHub

核心代码讲解:

const ethers = require('ethers');
const axios=require('axios');
//This contains an Endpoint URL, and a wallet private key!!!
//const secrets = require('./secrets.json');

//THIS WORK ON BSC TESTNET!!!!!

//All Values are for the testnet!!!!!!!!

//这里填WBNB地址
const WBNB = "0xae13d989dac2f0debff460ac112a837c89baa7cd"; 
//这里填USDT或者BUSD都行
const BUSD = "0x78867BbEeF44f2326bF8DDd1941a4439382EF2A7";

//这里填pancakeswap路由地址
const router = "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3";

//填合约地址
const DogeAddress='0xF2a816876e12378F67E1Aa88Fc466685d5C16874';

//填节点地址
const provider = new ethers.providers.JsonRpcProvider("https://late-divine-emerald.bsc-testnet.discover.quiknode.pro/5a218dc9c94daf4309ea27ff0a6a3c2013fae4b6");
//填你的私钥
const wallet = new ethers.Wallet("你的私钥");
const signer = wallet.connect(provider);

const routerContract = new ethers.Contract(
    router,
    [
        'function getAmountsOut(uint amountIn, address[] memory path) public view returns(uint[] memory amounts)',
        'function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
        'function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
        'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
        'function swapExactETHForTokensSupportingFeeOnTransferTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
    ],
    signer
);

const busdContract = new ethers.Contract(
    BUSD,
    [
        'function approve(address spender, uint256 amount) external returns (bool)',
        'function balanceOf(address account) external view returns (uint256)'
    ],
    signer
)

const WBNBContract = new ethers.Contract(
    WBNB,
    [
        'function approve(address spender, uint256 amount) external returns (bool)'
    ],
    signer
)

async function main() {
    //获取bnb余额
    let balance=await provider.getBalance(wallet.address)
    const balanceInEth = ethers.utils.formatEther(balance);
    console.log(balanceInEth);
    // //获取usdt余额
    
    const BUSDamountIn = ethers.utils.parseUnits('0.001', 'ether')
        const MaxNum = ethers.utils.parseUnits('1', 'ether')
    console.log(BUSDamountIn);
    console.log(BUSDamountIn);
    let amounts = await routerContract.getAmountsOut(BUSDamountIn, [WBNB, DogeAddress])
    const WBNBamountOutMin = amounts[1].sub(amounts[1].div(10));
    
    // console.log(ethers.utils.formatEther(BUSDamountIn));
    // console.log(ethers.utils.formatEther(WBNBamountOutMin));
    //授权
    const approveTx = await WBNBContract.approve(
        router,
        MaxNum.toString()
    );
    let reciept = await approveTx.wait();
   // console.log(reciept);
    //转账
    const swapTx = await routerContract.swapExactETHForTokens(
        0,
        [WBNB, DogeAddress],
        wallet.address,
        Date.now() + 1000 * 60 * 10,
        {
            'gasLimit': 1000000,
            //'value':BUSDamountIn,
            'gasPrice':ethers.utils.parseUnits('10','gwei'),
            //'from':wallet.address
            value:BUSDamountIn
        }
    )
    receipt = await swapTx.wait();
    console.log(receipt);
}

main().then().finally(() => {});

调用swapExactTokensForTokens和swapExactETHForTokens进行转账操作

原vue写的网页完整版在这里:https://github.com/Larsy5/batch_Transfer

觉得不错可以给我点个star文章来源地址https://www.toymoban.com/news/detail-524433.html

到了这里,关于pancakeswap批量抢跑机器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包