A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided

Overview

BSCTokenSniper v1.0

A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided.

BSCTokenSniper is a bot written in Python to detect new PairCreated events in the Binance Smart Chain (when a liquidity pair has been created) and buy the token. It is quite reliable and works well but it is the first version, so if you find any problems/improvements/suggestions please let me know by raising an issue.

Description

The aim of BSC Token Sniper is to buy new tokens with a specified amount of BNB, with the aim of the price rising Once the bot detects a PairCreated event, it is able to check the token (mini audit).

It can check if:

  • Source code is verified.
  • If valid PancakeSwap v2 router is being used
  • If a mint function exists
  • If it is a potential honeypot
  • PancakeSwap v1 router address is not being used.

The user can decide whether to enable the mini audit or turn it off (bear in mind you will likely be investing in a lot of scams if you don’t). Once the token has/hasn't been through a mini audit the bot will then attempt to buy X amount of tokens with the specified amount of BNB. The bot will buy the tokens directly through the Binance Smart Chain using the PancakeSwap v2 router and factory address, so it is much quicker than the PancakeSwap web interface.

By avoiding web interfaces & Metamask and directly with Ethereum & EVM Nodes you can snipe tokens faster than any of the web-based platforms. This allows tokens to be sniped almost instantly. During our testing we found the bot would typically be within the first 3 buy transactions of all tokens it finds. The bot buys the tokens using the user's wallet address and private key. This information is kept secure, is only stored locally on your computer, and is only ever used to buy tokens (look through the code to see for yourself).

The bot does not incur any additional fees, only fees are BSC network transaction fees and PancakeSwap fees.

Prerequisites

  • Python 3 or later installed
  • Node.js installed (easiest way) – Install windows version from https://nodejs.org/en/download/
  • Web3 installed (in windows command line type: npm install Web3)
  • BscScan API key (completely free of charge, create an account on BscScan and generate a free API key)
  • BSC wallet address and private key
  • enough BNB in your wallet to snipe tokens.

Setup

  1. Install all dependencies (above)
  2. Edit config.json file with your wallet address, private key and BscScan API key.
  3. (Optional) if you are in windows, open the command prompt and right-click the title bar, click ‘properties’ and set screen buffer size height to 2500. This allows you to scroll through the history of your token snipes.
  4. In command prompt (assuming you are using windows) type 'python' and press enter, and check that it is recognized by the computer. If you get a message that says it isn't recognized, then change the 'launchBSCTokenSniper.bat' file and replace 'python' with the path to your python program's executable file (make sure the filepath is in "" quotes).
  5. Run ‘launchBSCTokenSniper.bat’ and you’re good to go!

Configuration File

When you download the bot, you will find a config.json file. This is where you need to add the following data.

walletAddress: your BSC wallet address (e.g., Metamask) walletPrivateKey: your private key of your wallet address (your private key is kept safe and not shared in any other place) amountToSpendPerSnipe: The amount in BNB you want your wallet to spend on every new token. (e.g., 0.00025 means a new snipe will spend 0.00025 BNB on the new token) transactionRevertTimeSeconds: Time to spend before transaction reverts. Recommended to leave at default. gasAmount: amount of max gas to use per transaction. Recommended to leave at default. gasPrice: max price of gas to use per transaction. Recommended to leave at default. bscScanAPIKey: Your API key from BscScan. observeOnly: enabling this will disable buying of coins but allows you to observe how the bot audits tokens. Recommended to try this at the start to make sure the bot can scan for new tokens.

Mini audit

The bot has an optional mini audit feature which aims to filter some of the scam coins (eg. wrongly configured, honeypots). Obviously, this is not going to be as good as a proper audit (eg. CertiK) but at least the coins the bot will buy will be higher quality and if you enable the options, you should be able to sell the tokens later on (provided it hasn’t been rugged).

The following json entries are for mini audit. Set all to false to disable mini audits, although beware you will probably be buying a lot of scam coins. checkSourceCode: checks if source code is verified. This function is needed for all the other functions so if you disable this be sure to disable all the other audit options. Recommended.

checkValidPancakeV2: checks if the correct PancakeSwap v2 router address is used in the code. Be aware some contracts may externally set their router address so this function may reject a potentially good token. Not recommended.

checkMintFunction: checks if a mint function is present in the code. Recommended.

checkHoneypot: checks the code to see if it might be a honeypot (where you can buy tokens but cannot sell). Recommended.

checkPancakeV1Router: checks to see if the PancakeSwap v1 router address is used in the code. You will not be able to sell the tokens later on if PCS v1 router address is used. Highly recommended.

Note: be very careful when editing config.json and make sure to not alter the syntax. For mini audit options, either use “True” or “False” making sure to capitalise the 1st letter. Any other spelling will not work.

Things to note

  • Do not worry if you are not seeing any new tokens being detected. There are often around 10-20 new tokens being created per minute but that can vary quite a lot. Sometimes no new tokens may be detected for a few minutes.

  • The bot only buys tokens whose liquidity is paired with Wrapped BNB (WBNB). You could alter the code to buy tokens paired with another currency if you wanted.

  • Please check that you have enough BNB in your wallet to afford sniping new tokens. If you don’t the bot will not work.

  • Please be careful when editing the config.json file. If you delete a comma or quotation mark etc. the bot will not work and throw an error.

  • To launch the bot, run the ‘launchBSCTokenSniper.bat’. The bot should then open in a cmd window and load.

  • Don’t left click in the cmd window as it will enable select mode and stop the output (you will see ‘Select’ in the title). If this happens right click your mouse to deselect it.

FAQs

I've sniped loads of coins - but how can I check which ones have made a profit?

  • For this go to poocoin.app, click 'Wallet' and connect your Web3 wallet that you are using for your bot (eg. Metamask).
  • It will then give you the list of tokens in your wallet and show you which ones have made the highest profit.
  • Click the descending arrow next to the balance tab to show highest to lowest tokens value.
  • Then you can manually sell the tokens which have made you a profit on PancakeSwap.

I keep getting ‘Transaction failed’ – what’s going on? Either:

  • Gas amount / price too low
  • Wallet address / private key incorrect
  • Not enough BNB to pay for the token and TX fees

The bot isn’t sniping that fast (eg. couple seconds between detection and buying)

  • This is mainly due to internet speed and computer processing power.

Risks:

Investing in BSC tokens / shitcoins is risky and be aware you could lose all your money. For this reason, do not invest more money than you are prepared to lose. It is pretty much impossible to snipe bots very early and be sure it isn’t a rug pull. When people create tokens in most situations, they will manually create liquidity in PancakeSwap. This is when the bot will detect the token. If they burn / lock liquidity, they will then usually send their LP tokens manually to a deadcoin address or put them in a liquidity locker. Therefore, you can’t immediately snipe the tokens with 100% certainty they aren’t rugpulls.

The mini audit feature can’t be 100% accurate but aims to filter out the majority of scams / hacks and reduce the chance of losing your money. If a programmer creates token code in a unique way, they may be able to bypass detection although this is generally quite rare, as the majority of tokens are forks of big projects with very little of the code having been changed e.g., Safemoon.

Things to do / improve / bug fixes / thoughts:

  • Clarify installation of web3 as alot of users had issues with it
  • Improve honeypot detection (at the moment it is very simple and some tokens are rewriting their code to bypass the bot's detection) (bscheck.eu seem to do a good job of detecting honeypots better than the bot can do, will try to contact them and see how their detection algorithm works)
  • Improve reliability (occasionally it can freeze)
  • Use WebsocketProvider instead of HTTPProvider (faster so will snipe tokens quicker)
  • Implement a feature that makes the bot only invest in tokens that have a certain amount of liquidity (ie. only invest in tokens that have min. 10 BNB liquidity)
  • Implement a GUI? Maybe
  • Look into rugpull detection
  • Auto sell after certain profit reached?
  • Make ETHTokenSniper that does the exact same but runs on the ethereum blockchain
  • Make code more efficient so can run faster and snipe faster
  • Are all tokens that haven't verified their source code bad? Probably not. But I'm currently just assuming that developers will verify their source code before adding liquidity.

If you’ve found this bot useful and have profited from it please consider donating any token to my BSC wallet address: 0xE75470B9a7c93038195ca116E342c42F6B3F758b

Comments
  • mini audit additional scan requested

    mini audit additional scan requested

    Seeing a few rugs happening where tokens get trasnfered and sold from burn address somehow. Do not know the exact details here and might be misinterpreting the issue:

    see chart with just a few transactions before rugpul: https://poocoin.app/tokens/0x9a1a8046d2648bd101c3bd6c6746055418686b7d

    the trasnaction that kills it: https://bscscan.com/tx/0x0f218d5aece288d4223d232c10d5b603467cbf4a6af9777dbfd9062feef709af

    Could it be related to this: https://ethereum.stackexchange.com/questions/98215/why-is-it-considered-a-bad-practice-to-burn-tokens-to-0x0-when-creating-an-erc20

    Any way we can write a function to check for the inproper implementation of burn ?

    Anyway thanks for opensourcing this, this is great work!

    opened by winkelermatthias 17
  • Just Small contribution 👍

    Just Small contribution 👍

    1. added run.py to make it simple runing this bot
    2. Make A copy BSCtokenSniper modified for Linux
    3. Add screenshot
    4. Update Readme.md

    Why i created linux version?

    Because current version not able to run in linux and give the error. It because ctype.windll.kernel32, after working to fix it and it work like charm in Ubuntu Linux.

    web3 from nodejs not needed here. i don't know why. i'm not expert as you.

    opened by geeks121 13
  • Issues and Suggestions

    Issues and Suggestions

    Great project btw ! Thanks for open sourcing this.

    • This should be OS agnostic. Right now it is windows based.
    • After a while it looks like the token parsers just hangs and doesn't pick up new tokens
    • Source code verification could have an option to scan again maybe a small delay or retry as sometimes it take a bit for it to show up
    • Have an option to watch for a specific contract only vs parsing all new token releases.
    • Mini audit check could possibly use a regex system help clean that up and make adding new checks easier.

    I am swamped with other projects but when I have time I can help contribute. Great work btw in getting this out to the community !!!

    opened by EnorMOZ 12
  • Fail during run

    Fail during run

    Hello,

    I'm running the script, but after a while I get the next error when it's going to made a swap:

    [FAIL] Contract source code isn't verified

    What is this for failure and how can I solve this problem?

    opened by phoenix-blue 6
  • SpecifiedTokenSniper 1.1

    SpecifiedTokenSniper 1.1

    I have a request, could you make so that the bot could buy specific token without checking liquidity?

    You just enter token address and it buys the tokens for specified amount of BNB.

    Would really appreciate it!

    opened by aivarasx987 5
  • [QUESTIONS] For anyone who has tried and tested the bot:

    [QUESTIONS] For anyone who has tried and tested the bot:

    Question for everyone who has tried and tested the bot:

    1.) Is the bot affected by the tax system most of these meme coins have built-in their smart contracts?

    2.) I assume the bot is not affected by slippage since it's almost instant, however, some meme coins would specify minimum slippage eg 12% or so. Is the bot affected by this?

    Also if you could help me with this inquiry on Stackflow, I'd really appreciate it https://stackoverflow.com/questions/68899410/check-if-wallet-is-approved-to-spend-token

    Insights will be very much appreciated, thanks!

    opened by Buco11-dev 4
  • [FEATURE REQUEST] Add Some Feature

    [FEATURE REQUEST] Add Some Feature

    Features :

    • Take Profit / Stop loss
    • Trailing stop
    • Twitter Scraper
    • Simulated transaction mode
    • Tax checker
    • Multiwallet
    • Sniper liquidity
    • Sniper liquidity after DxSale
    • Sniper antibot tokens
    • Sniper Telegram
    • Trading mode / Pump bot mode
    • Auto Approve tokens
    • Price/Profit live stream
    • Take Profit / Stop Loss
    • Trailing stop
    • Sell in instant with hotkeys
    • Rebuy dip
    • Simulated transactions mode to avoid loss of gas
    • Rug SHIELD
    • Honeypot SHIELD
    • High tax SHIELD
    • Support PancakeSwap / ApeSwap / Uniswap / Koffeeswap
    opened by coolerspeex 4
  • how can i buy what i wan token with this bot

    how can i buy what i wan token with this bot

    Hi Dear BytePhoenixData how can i buy what i wan token with this bot ? so i login token address then bot will try to buy . How can i do that ? Thanks

    opened by 252furkan 4
  • Honeypot code needs updating

    Honeypot code needs updating

    Take a recently added contract as an example: 0xe4B473c657120ebc91586c335ad9E5aF203F2dC3 Look at the transfer and approve functions.

    I see more complex code poping up to bypass honeypot identification bots.

    Let me know if you would like to collab in finding a way to be optimal in finding the 1% of tokens that are not scams

    opened by Gcvanasel 4
  • Not selling?

    Not selling?

    Set the bot to sell at 2x, and I have tokens going 4x and not selling. Not that I'm complaining since I sold manually, but if I wasn't here monitoring I could miss it. Any reason? fix? Appreciated.

    opened by nickyoung92 3
  • tokenLoop error

    tokenLoop error

    received the below error after connecting to node. Not sure the issue. Using Moralis WS node and v1.3

    [ERROR] tokenLoop error, please notify dev: Traceback (most recent call last): File "BSCTokenSniper.py", line 596, in tokenLoop File "C:\Users\nicho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\web3_utils\filters.py", line 160, in get_new_entries log_entries = self._filter_valid_entries(self.eth_module.get_filter_changes(self.filter_id)) File "C:\Users\nicho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\web3\module.py", line 57, in caller result = w3.manager.request_blocking(method_str, File "C:\Users\nicho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\web3\manager.py", line 187, in request_blocking return self.formatted_response(response, File "C:\Users\nicho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\web3\manager.py", line 168, in formatted_response raise ValueError(response["error"]) ValueError: {'code': -32000, 'message': 'filter not found'}

    opened by nickyoung92 3
Owner
null
This demo is an on-chain NFT auction using smart contracts on the Algorand blockchain.

Algorand Auction Demo This demo is an on-chain NFT auction using smart contracts on the Algorand blockchain. Usage The file auction/operations.py prov

null 1 Jan 27, 2022
A simple Python tool to help anyone use Liquidity Pools on the BitShares blockchain.

ACCOUNT AND ACTIVE KEY ARE NOT PERSISTENT, YOU WILL NEED TO ENTER THEM EACH TIME YOU LAUNCH THE APP (but not every transaction. that's a win). If / wh

Brendan Jensen 17 Jun 15, 2022
Smart-contracts - open sourcing our upcoming smart contracts for better security and transparency

Smart-contracts - open sourcing our upcoming smart contracts for better security and transparency

Rand Gallery 16 Jul 10, 2022
A crypto bot that checks the price movement in the markets and creates buy and sell signals

Booter bot Purpose The purpose of this bot is to check the price fluctuations in a given market in binance and create the idealistic signals based on

null 2 Oct 9, 2022
Simple python crypto bot to trade crypto on Binance based on RSI. Utilizing web sockets to get real-time prices

Py Crypto Bot Using Binance WebSocket API to get real-time price data for cryptocurrencies. Using the TA-Lib library to calculate the RSI and execute

Kennedy Ngugi Mwaura 15 Jan 4, 2023
This is a fully functioning Binance trading bot that takes into account the news sentiment for the top 100 crypto feeds.

This is a fully functioning Binance trading bot that takes into account the news sentiment for the top 100 crypto feeds.

Andrei 1.5k Jan 4, 2023
Python based project to pull useful account statistics from the Algorand block chain.

PlanetWatchStats Python based project to pull useful account statistics from the Algorand block chain. Setup pip install -r requirements.txt Run pytho

M0x40 1 Jan 27, 2022
Stai Beta Of Staiking Chain - Food, Water And Electricity - Worldwide

Stai Beta Of Staiking Chain - Food, Water And Electricity - Worldwide

STATION-I 2 Feb 5, 2022
A little side-project API for me to learn about Blockchain and Tokens

BlockChain API I built this little side project to learn more about Blockchain and Tokens. It might be maintained and implemented to other projects bu

Loïk Mallat 1 Nov 16, 2021
Tool to compare smart contracts source code

smartdiffer Tool to compare smart contracts source code. Heavily relies on API of Etherscan and Diffchecker. Installation pip install smartdiffer API

Roman Moskalenko 23 Nov 16, 2022
smartpassgen - A cross-platform package of modules for generating, secure storage and recovery of complex, cryptographic, smart passwords on the fly.

smartpassgen - A cross-platform package of modules for generating, secure storage and recovery of complex, cryptographic, smart passwords on the fly.

null 4 Sep 4, 2021
A repository for Algogenous Smart Contracts created on the Algorand Blockchain.

Smart Contacts Alogrand Smart Contracts using Choice Coin. Read Docs for how to implement Algogenous Smart Contracts for your own applications. Smart

Choice Coin 3 Dec 20, 2022
A repository for Algogenous Smart Contracts created on the Algorand Blockchain.

Smart Contacts This Repository is dedicated to code for Alogrand Smart Contracts using Choice Coin. Read Docs for how to implement Algogenous Smart Co

Choice Coin 3 Dec 20, 2022
cairo_kernel is a simple Jupyter kernel for Cairo a smart contract programing language for STARKs.

cairo_kernel cairo_kernel is a simple Jupyter kernel for Cairo a smart contract programing language for STARKs. Installation Install virtualenv virtua

Ankit Chiplunkar 29 Sep 21, 2022
Implementation of Smart Batch Auction for NFT launches on Tezos.

NFT Smart Batch Auction Smart Batch Auctions are an improvement over the traditional first come first serve (FCFS) NFT drops. FCFS design has been in

Anshu Jalan 5 May 6, 2022
😈 Shining is a tool that enables engineers to remotely pull smart contract code in multi-file situations.

?? Shining ?? Shining is a tool that enables engineers to remotely pull smart contract code in multi-file situations. Shining is the name of one of my

xxxeyJ 15 Jun 17, 2022
Pythonic Smart Contract Language for the EVM

Getting Started See Installing Vyper to install vyper. See Tools and Resources for an additional list of framework and tools with vyper support. See D

Vyper 4.4k Dec 30, 2022
A workshop to build an NFT smart contract on the polygon blockchain

Polygon NFT Workshop This is an interactive workshop that guides you through the steps to deploy an NFT smart contract on the Polygon blockchain. By t

Banjo Obayomi 56 Oct 14, 2022