Advertisement
mrdeeds88

Untitled

Jan 6th, 2022
2,974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | None | 0 0
  1. import json
  2. import config
  3. import asyncio
  4. import datetime
  5. import time
  6. from web3 import Web3
  7.  
  8.  
  9. ## Common Settings ##
  10. bsc = "https://bsc-dataseed.binance.org/"
  11. web3 = Web3(Web3.HTTPProvider(bsc))
  12. sender_address = 'Your Wallet'
  13. PCSRouter_address = '0x10ED43C718714eb63d5aA57B78B54704E256024E'
  14. ###############
  15.  
  16. ## Check connected
  17. print("Connect Status: ", Web3.isConnected(web3))
  18.  
  19. ## ABI Setting ## Get from contract ABI
  20. panabi = ''
  21. #########
  22.  
  23. ## Check Sender Address balance ##
  24. balance = web3.eth.get_balance(sender_address)
  25. balance_converted = web3.fromWei(balance,'ether')
  26. print("Wallet balance:" , balance_converted,"BNB")
  27. ####
  28.  
  29. contract  = web3.eth.contract(address=PCSRouter_address , abi=panabi)
  30. ## Setting token want to swap
  31. tokenToBuy = web3.toChecksumAddress(input("Enter Token Address: "))  #
  32.  
  33. ## Setting BUSD/USDT for swapping
  34. #spend =web3.toChecksumAddress("0x55d398326f99059ff775485246999027b3197955") # USDT
  35. spend =web3.toChecksumAddress("0xe9e7cea3dedca5984780bafc599bd69add087d56")  # BUSD
  36.  
  37. ## Check total transaction of sender Wallet ##
  38. nonce = web3.eth.get_transaction_count(sender_address)
  39. count = 1
  40. MaxTx = 5 ## Setting Number of Tx you want to APE
  41. start = time.time()
  42.  
  43. while count <= MaxTx:
  44.   pancakeswap2_txn = contract.functions.swapExactTokensForTokensSupportingFeeOnTransferTokens(
  45.     web3.toWei('0.2','ether'), # BUSD AMMOUNT You want to spend
  46.     0, # set to 0 means dont care slippage, or specify minimum amount of token you want to receive - consider Decimal!
  47.     [spend,tokenToBuy],
  48.     sender_address,
  49.     (int(time.time()) + 10000)
  50.   ).buildTransaction({
  51.     'from': sender_address,
  52.     'gas': 300000,
  53.     'gasPrice': web3.toWei('5','gwei'),
  54.     'nonce': nonce,
  55.   })
  56.   signed_txn = web3.eth.account.sign_transaction(pancakeswap2_txn, private_key='Your Private Key')
  57.   tx_token = web3.eth.send_raw_transaction(signed_txn.rawTransaction)
  58.   print("TX Hash: ", Web3.toHex(tx_token))
  59.   nonce = nonce +1
  60.   count = count + 1
  61.  
  62. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement