Bot to buy, sell, check the price of token listed on Uniswap or PancakeSwap
Bot to buy, sell, check the price of token listed on Uniswap or PancakeSwap.
Will be added to PyPi in the future.
Create an account on Infura to create a free node to process all your transactions. (Only necessary if you will use Uniswap)
Create a Python file called keys.py to store your Metamask information and your Infura project id. Example:
#Infura node
infura_project_id = ""
# Metamask keys
metamask_address = ""
metamask_private_key = ""
You can see an example for buying a token on this file.
Import the Txn_bot object that executes all transactions.
from txns import Txn_bot
Set the token address where you want to buy, sell, check the price. You can check this on CoinMarketCap or Coingecko by searching the coin and looking on Contract.
token_address = "0xf9ba5210f91d0474bd1e1dcdaec4c58e359aad85"
To create a transaction you need to specify four things:
quantity = 0.13*10**18
net = 'eth-rinkeby'
slippage = 30 #%
-- Gas Price: The gas price is a fee to execute your transaction and it is measured in Gwei. The value of one Gwei is 0.000000001 ETH/BNB. The gas price you select on PancakeSwap will be normally 5 Gwei (0.000000005 or 5x10^9 ETH/BNB). (You can use higher gas prices but usually on PancakeSwap is not necessary) On Uniswap the gas price oscillates depending on the network congestion. You can see the real-time prices on GasNow website (For Uniswap I suggest using Rapid or Fast gas prices). The higher the gas price you set the faster your transaction will be completed.
gas_price = 1*10**9
Finally, we can buy the token with the buy_token method that will return a transaction ID which can be tracked and reviewed on EtherScan. Example:
bot = Txn_bot(token_address, quantity, net, slippage, gas_price)
bot.buy_token()
TODO: Add sell and check_price example codes. TODO: Add images to README