土狗抢

关于最近科学家社区不太活跃

我们最近很忙,在忙一些前端的事情,所以没有发文章,希望大家谅解

抢开盘的竞争

主要在于 监控到添加流动性的时间 和发出购买交易的时间 这个是我本人在用的一个监控流动性工具,每个邮箱1000次/每天,可以多注册几个这样就够了 https://explorer.blocknative.com/ 注册账号的步骤就省略了 第一步先在这里点WatchNow,监控BSC上的PancakeSwap所有交易,记住一定打开之后就把右下角的暂停掉,要不然一会你的1000条就没了

然后把V1的勾掉,在v2的地方添加Filters

安装下面的图片操作,这里的操作是监控所有添加流动性的交易。

这个时候你就完成了整个过程,点击下面的Save 就可以去导出你的APIKey了

抄点代码

https://github.com/Supercycled/cake_sniper/tree/1afad7c6e9b478c1024addf3cee9903e5c2bcba5/contracts 这个大哥写的合约,首先是通过Create2计算出池子地址,然后购买,这里相当于自己写了一个Router来用 这里你们需要去remix上部署这些合约,然后就可以往这个合约里面打你的子弹,我每一次都是买1BNB,90%的时候都是几倍之后出来的

缝合

async def txn_handler(txn,unsubscribe):
    string = json.dumps(txn)
    jsonload= json.loads(string)
    print(jsonload['gasPrice'])
    print(jsonload['hash'])
    if('Token合约地址小写' in jsonload['input']):
        print('start! NOW ')
        你的购买函数
        print('success')
    else :
        pass
def RunForEver(): 
    Pancake_v2_router = '0x10ED43C718714eb63d5aA57B78B54704E256024E'
    stream = Stream('XXXX-XXXXX-XXXXX',network_id=56)
    stream.subscribe_address(Pancake_v2_router,txn_handler,filters=filters)
    stream.connect()

这里面只是一个思路包括了监控和合约,至于在什么时间调用卖出函数要看你自己的想法,关于购买

def Buy(gasPrice,tokenB):
    abi=[{ "anonymous": False, "inputs": [{ "indexed": True, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": True, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "inputs": [{ "internalType": "address", "name": "_seller", "type": "address" }], "name": "authenticateSeller", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "emmergencyWithdrawBnb", "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_token", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "emmergencyWithdrawTkn", "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "tokenOut", "type": "address" }, { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }], "name": "sandwichIn", "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "tokenIn", "type": "address" }, { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }], "name": "sandwichOut", "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "addresspayable", "name": "_newAdmin", "type": "address" }], "name": "setAdministrator", "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_newRouter", "type": "address" }], "name": "setSandwichRouter", "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "stateMutability": "payable", "type": "receive" }, { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "authenticatedSeller", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getAdministrator", "outputs": [{ "internalType": "addresspayable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getSandwichRouter", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }]
    rpcUrl = ""
    web3 = Web3(Web3.HTTPProvider(rpcUrl))
    acct = web3.eth.account.from_key("")
    contract_address = ''
    contract = web3.eth.contract(contract_address,abi=abi)
    txn = contract.functions.sandwichIn(tokenB,1000000000000000000,0).buildTransaction({
        'from': acct.address,
        'nonce': web3.eth.getTransactionCount(acct.address),
        'gas': 330000,
        'gasPrice': gasPrice
        })
    signed = acct.signTransaction(txn) 
    tx_id = web3.eth.sendRawTransaction(signed.rawTransaction) 
    print(tx_id.hex())