├── BNB Chain ├── .DS_Store ├── BuySpecificToken │ ├── BuyaSpecificToken.py │ └── config.py ├── DEX │ ├── CheckIfLiquidity_IsAdded.py │ └── NewlyCreatedPair.py ├── Evaluate Bsc Token │ ├── AfterLP-buy.py │ ├── Evaluate-BSCTOKEN.py │ ├── Evaluate-Binance-Token.py │ ├── GetLocktime.py │ ├── Scam-metrics.md │ ├── Wallet-trade-history.py │ ├── abi.py │ └── config.py ├── Memepool │ ├── AnalazizeProfitablitly.py │ ├── DecodeMulticall.py │ ├── PanCakeSwapV3Memepool.py │ ├── Pancakeswap_memepool.py │ ├── Sandwich-Attack.py │ ├── config.py │ └── router_abi.json ├── Miscellaneous │ ├── GetContractEventNames.py │ ├── GetTelegramGroup.py │ ├── GetTokenReserves_WithRIghtIndex.py │ └── GettokenPrice_BNB_and_USDT.py ├── Trading │ ├── AddLiquidityEvents.py │ ├── BuyWithMultipleAddress.py │ ├── CopyBuy_Sells.py │ ├── CopyWalletTrade.py │ ├── LaunchBot.py │ ├── MonitorMultipleAddresses.py │ ├── TrackEOA_ReceivingBNB.py │ ├── TrackingSmartContractEvents.py │ └── sendMessage.py └── Wallet │ ├── BuywithMultipleWallets.py │ ├── Hd-wallet.py │ ├── MonitorMultipleWallets.py │ ├── MonitorPriceandSell.py │ ├── SendBNB-MultipleWallets.py │ ├── addresses_and_keys.crypto │ └── create-multiple-BSCaddress.py ├── Ethereum ├── Buy_Sell │ └── Buy_Sell.py ├── DEX │ ├── CheckIfLiquidity_IsAdded.py │ └── NewlyCreatedPair.py ├── Decoding │ ├── Example_1.py │ └── Example_2.py ├── Evaluate ERC20 Token │ ├── EvaluateToken_HoneypotAPI.py │ ├── GetLocktime.py │ ├── Token-Early-Transactions.py │ ├── TokenProperty.py │ └── Ultimate_TokenEvaluator.py ├── GasFees │ └── gas_fees.py ├── GoogleCloudSetUp │ └── Instructions.md ├── JarethFromSubway │ ├── jareth_anlytics.py │ ├── jareth_copytrade.py │ └── uniswapAnalytics.py ├── Launchpads │ ├── All_LaunchpadsEvents.py │ ├── PinkySaleLockEvents.py │ ├── TrustswapSecurity.py │ └── UnicryptLockEvents.py ├── Memepool │ ├── AllrouterAddresses.py │ ├── DecodingExecuteFunction.py │ ├── DecodingMulticall.py │ ├── memepool2.0.py │ ├── router_abi.json │ ├── simple.py │ └── v3Memepool.py ├── Miscellaneous │ ├── Block_logs.py │ ├── GetEventNames.py │ ├── GetTokenPairFromLp.py │ └── SpecificTokenInWallet_PriceInWETHUSDT.py ├── Monitoring │ ├── Monitor-MultipleLp-Concurrently.py │ └── MonitorPools-TokenOwned.py ├── Trading │ ├── AddLp_Events.py │ ├── BuyTokenErc20-1inch.py │ ├── CopyAnyWallets-Buy_Sells.py │ ├── CopyTrade-IrrespectiveOfRouter.py │ ├── CopyWalletTrade.py │ ├── GaslessApprove.py │ ├── MonitorPriceOfBoughtToken.py │ ├── MonitorPriceandSell.py │ ├── Monitor_TokenLiquidityTxn.py │ ├── SnipeOnSameBlock.py │ ├── Subscribe.py │ ├── TrackLockEvents.py │ └── jarethfromsubway.py └── Wallet │ ├── BuyWithMultipleWallets.py │ ├── Hd-wallet.py │ ├── MultisignatureWallet.py │ └── create-multiple-ETHaddress.py ├── LICENSE ├── Learning Resources └── myLearningResources.md ├── Notes └── Todo.txt ├── README.md ├── SDK └── AlchemyPythonSDK │ ├── BananGunRouter_Buys_Sells.py │ ├── CopyTrade_MultipleWallets.py │ ├── GetNumberOfBuys.py │ ├── MonitorWallet_MinedTransactions.py │ ├── MonitorWallet_PendingTransaction.py │ ├── SMS_Notifications.py │ └── Send_PrivateTxn ├── Smart Contracts ├── BuyandSell.sol ├── ER20HoneypotChecker.sol ├── MEV_Bot.sol ├── Memepool.sol ├── Sameblock.sol └── ScanNewlyCreatedPairs.sol ├── Solana ├── Listen_tokenBurns.py ├── Miscellaneous │ ├── Deserialize.py │ ├── Deserialize_SPL.py │ ├── GetAmmID.py │ └── GetPool_Info.py ├── Monitor │ ├── Buy_Sells.py │ ├── Concurrent-Monitoring-Accounts.py │ ├── DifferentTransactionBuilds.py │ └── MonitorWalletList.py ├── NewPairs_Simple.py ├── NewlyCreatedPairs.py ├── Solana Dev Resources.txt ├── Solana-Web3JS │ ├── DecodeMarketBid.ts │ └── NewPoolRaydium.js ├── TokenAnalysis.py ├── TrackBots.py ├── Trade │ ├── Buy.py │ ├── Sell.py │ ├── create_close_account.py │ ├── dexscreener.py │ └── layouts.py ├── Wallet │ ├── .env │ ├── Create_WalletAddress.py │ └── WalletFrom_PrivateKey.py ├── Wallet_AddressAnalytics.py ├── copyTrade.py ├── progam.py └── spl-token-Analytics.py ├── Subgraphs └── NewlyCreatedPairs.py └── Telegram Bot ├── snipe_telegram.py └── tg.py /BNB Chain/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/BNB Chain/.DS_Store -------------------------------------------------------------------------------- /BNB Chain/BuySpecificToken/config.py: -------------------------------------------------------------------------------- 1 | 2 | WalletAddress="Enter Your Wallet Address Here " 3 | 4 | private2= "Enter Your Private Key" 5 | -------------------------------------------------------------------------------- /BNB Chain/DEX/CheckIfLiquidity_IsAdded.py: -------------------------------------------------------------------------------- 1 | import json 2 | from web3 import Web3 3 | import time 4 | import datetime 5 | import requests 6 | 7 | 8 | 9 | class style(): # Class of different text colours - default is white 10 | BLACK = '\033[30m' 11 | RED = '\033[31m' 12 | GREEN = '\033[32m' 13 | YELLOW = '\033[33m' 14 | BLUE = '\033[34m' 15 | MAGENTA = '\033[35m' 16 | CYAN = '\033[36m' 17 | WHITE = '\033[37m' 18 | UNDERLINE = '\033[4m' 19 | RESET = '\033[0m' 20 | 21 | 22 | 23 | 24 | def getTimestamp(): 25 | while True: 26 | timeStampData = datetime.datetime.now() 27 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 28 | return currentTimeStamp 29 | 30 | 31 | web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed2.binance.org/")) 32 | if web3.is_connected(): 33 | print(getTimestamp()," BSC Node successfully connected") 34 | 35 | contract_address = input("Enter Token Address: ") 36 | WBNB= "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" 37 | 38 | pancake_factory = '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73' # Testnet #0x6725F303b657a9451d8BA641348b6761A6CC7a17 39 | pancake_factory_abi = json.loads('[{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":true,"inputs":[],"name":"INIT_CODE_PAIR_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]') 40 | contract = web3.eth.contract(address=pancake_factory, abi=pancake_factory_abi) 41 | lp_abi = '[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint112","name":"reserve0","type":"uint112"},{"indexed":false,"internalType":"uint112","name":"reserve1","type":"uint112"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MINIMUM_LIQUIDITY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint112","name":"_reserve0","type":"uint112"},{"internalType":"uint112","name":"_reserve1","type":"uint112"},{"internalType":"uint32","name":"_blockTimestampLast","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"kLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"price0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"price1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"skim","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount0Out","type":"uint256"},{"internalType":"uint256","name":"amount1Out","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sync","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]' 42 | 43 | 44 | 45 | 46 | 47 | def get_liquidity_balance(lp_address): 48 | lp_contract = web3.eth.contract(address=lp_address, abi=lp_abi) 49 | reserves = lp_contract.functions.getReserves().call() 50 | balance = reserves[0] 51 | return balance 52 | 53 | def check_liquidity(lp_address): 54 | balance = get_liquidity_balance(lp_address) 55 | if balance > 0: 56 | print(f"{getTimestamp()} Liquidity balance detected' {balance}") 57 | #buy() # We can set up buy as soon as liquidity is added 58 | else: 59 | pass 60 | #print('No liquidity balance detected') 61 | 62 | 63 | 64 | def run_lp_check(): 65 | lp_address = contract.functions.getPair(contract_address, WBNB).call() 66 | if lp_address != web3.to_checksum_address('0x0000000000000000000000000000000000000000'): 67 | #print('LP address detected:', lp_address) 68 | check_liquidity(lp_address) 69 | return True 70 | else: 71 | print('No LP address found') 72 | return False 73 | print("Checking for Liquidity....") 74 | 75 | while True: 76 | #print("Checking for Liquidity....") 77 | run_lp_check() 78 | time.sleep(1) 79 | 80 | 81 | -------------------------------------------------------------------------------- /BNB Chain/DEX/NewlyCreatedPair.py: -------------------------------------------------------------------------------- 1 | import json 2 | from web3 import Web3 3 | import asyncio 4 | import time 5 | import datetime 6 | import requests 7 | 8 | 9 | 10 | class style(): # Class of different text colours - default is white 11 | BLACK = '\033[30m' 12 | RED = '\033[31m' 13 | GREEN = '\033[32m' 14 | YELLOW = '\033[33m' 15 | BLUE = '\033[34m' 16 | MAGENTA = '\033[35m' 17 | CYAN = '\033[36m' 18 | WHITE = '\033[37m' 19 | UNDERLINE = '\033[4m' 20 | RESET = '\033[0m' 21 | 22 | 23 | 24 | 25 | def getTimestamp(): 26 | while True: 27 | timeStampData = datetime.datetime.now() 28 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 29 | return currentTimeStamp 30 | 31 | 32 | web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed2.binance.org/")) 33 | if web3.is_connected(): 34 | print(getTimestamp()," BSC Node successfully connected") 35 | 36 | 37 | 38 | # 39 | # pancakeswap factory 40 | pancake_factory = '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73' # Testnet #0x6725F303b657a9451d8BA641348b6761A6CC7a17 41 | pancake_factory_abi = json.loads( 42 | '[{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":true,"inputs":[],"name":"INIT_CODE_PAIR_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]') 43 | contract = web3.eth.contract(address=pancake_factory, abi=pancake_factory_abi) 44 | """Connection to Pancakeswap""" 45 | 46 | tokenNameABI = json.loads( 47 | '[ { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Approval", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "_owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" } ], "name": "allowance", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "approve", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "account", "type": "address" } ], "name": "balanceOf", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getOwner", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transfer", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "sender", "type": "address" }, { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" } ]') 48 | 49 | 50 | 51 | #web3.middleware_onion.inject(geth_poa_middleware, layer=0) 52 | 53 | liquidityPairAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" 54 | 55 | #event_filter = contract.events.PairCreated.create_filter(fromBlock=30716374, toBlock=30718978) 56 | 57 | event_filter = contract.events.PairCreated.create_filter(fromBlock="latest") 58 | 59 | while True: 60 | try: 61 | #events = event_filter.get_all_entries() 62 | events = event_filter.get_new_entries() 63 | 64 | if len(events) > 0: 65 | for event in events: 66 | if (event['args']['token1'] == "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"): 67 | tokenAddress = event['args']['token0'] 68 | 69 | getTokenName = web3.eth.contract(address=tokenAddress, 70 | abi=tokenNameABI) 71 | tokenName = getTokenName.functions.name().call() 72 | tokenSymbol = getTokenName.functions.symbol().call() 73 | tx_hash = web3.to_hex(event['transactionHash']) 74 | print( 75 | style.YELLOW + getTimestamp() + " [Token] New Token Detected: " + style.CYAN + tokenName + " (" + tokenSymbol + "): " + style.MAGENTA + tokenAddress + " https://bscscan.com/tx/" + tx_hash + style.RESET) 76 | 77 | elif (event['args']['token0'] == liquidityPairAddress): 78 | tokenAddress = event['args']['token1'] 79 | getTokenName = web3.eth.contract(address=tokenAddress, 80 | abi=tokenNameABI) # code to get name and symbol from token address 81 | tokenName = getTokenName.functions.name().call() 82 | tokenSymbol = getTokenName.functions.symbol().call() 83 | tx_hash = web3.to_hex(event['transactionHash']) 84 | print( 85 | style.RED + getTimestamp() + " [Token] New Token Detected: " + style.CYAN + tokenName + " (" + tokenSymbol + "): " + style.MAGENTA + tokenAddress + " https://bscscan.com/tx/" + tx_hash + style.RESET) 86 | 87 | 88 | else: 89 | print(style.BLUE + "Not WBNB LQ PAIR") 90 | time.sleep(1) 91 | 92 | 93 | except Exception as e: 94 | print(f"Error: {e}") 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /BNB Chain/Evaluate Bsc Token/AfterLP-buy.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | You actually see early transactions of a project and it's a high determinant of it's success 4 | You just have to know what to fine 5 | This script can help you spot good wallets to follow. 6 | 7 | """ 8 | import requests 9 | import json 10 | 11 | 12 | api_key = 'KFEM9CQIBQVGZWTDGW5VDZGSM5ZYVGJ6KR' 13 | 14 | # Prompt user to input the token contract address and number of wallets 15 | contract_address = input("Enter the token contract address: ") 16 | num_wallets = int(input("Enter the number of Transactions to display: ")) 17 | 18 | # Define the BscScan API URL 19 | url = f"https://api.bscscan.com/api?module=account&action=tokentx&contractaddress={contract_address}&apikey={api_key}" 20 | 21 | # Send a request to BscScan API and parse the JSON response 22 | response = requests.get(url) 23 | data = json.loads(response.text) 24 | 25 | if data['status'] == "1": 26 | transactions = data['result'] 27 | 28 | # Filter transactions and get the first 'num_wallets' wallet addresses 29 | wallets = [] 30 | print(f"\nThe first {num_wallets} wallets that bought the token after liquidity was added:\n") 31 | for tx in transactions: 32 | if tx['from'] != contract_address and tx['to'] != contract_address: 33 | if tx['from'] not in wallets: 34 | wallets.append(tx['from']) 35 | print(f"{len(wallets)}. Wallet: {tx['from']}, TxHash: https://bscscan.com/tx/{tx['hash']}") 36 | 37 | if len(wallets) >= num_wallets: 38 | break 39 | elif tx['to'] == contract_address.lower(): #and len(wallets) == 1: 40 | print(f"Liquidity added transaction: TxHash: {tx['hash']}\n") 41 | else: 42 | print("Error fetching transactions. Please check the contract address and try again.") 43 | -------------------------------------------------------------------------------- /BNB Chain/Evaluate Bsc Token/GetLocktime.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | # Unix timestamp 4 | timestamp = int(input("Enter unix timestamp: ")) 5 | 6 | # Convert the timestamp to a date 7 | date = datetime.datetime.fromtimestamp(timestamp) 8 | 9 | # Get the current date 10 | current_date = datetime.datetime.now() 11 | 12 | lock_date = f"{current_date:%d-%m-%Y %H:%M:%S}" 13 | 14 | # Calculate the difference from current date 15 | difference = date-current_date 16 | locktime= difference.days 17 | print(current_date) 18 | print(locktime) 19 | print("Tokens are locked till: ",lock_date) 20 | print("Months Lock",locktime//30) 21 | print("Years Lock",locktime//365) 22 | -------------------------------------------------------------------------------- /BNB Chain/Evaluate Bsc Token/Scam-metrics.md: -------------------------------------------------------------------------------- 1 | # Key Metrics for Evaluating a Token to determine whether it's a cam 2 | 3 | 4 | If this repository reaches 50 stars, a surprise awaits with some exciting revelations 5 | 6 | 7 | 8 | 9 | 1.**Property 1** 10 | 11 | -------------------------------------------------------------------------------- /BNB Chain/Evaluate Bsc Token/Wallet-trade-history.py: -------------------------------------------------------------------------------- 1 | "Analyse an EOA wallet trade history" -------------------------------------------------------------------------------- /BNB Chain/Evaluate Bsc Token/config.py: -------------------------------------------------------------------------------- 1 | bsc_api ="KFEM9CQIBQVGZWTDGW5VDZGSM5ZYVGJ6KR" 2 | -------------------------------------------------------------------------------- /BNB Chain/Memepool/AnalazizeProfitablitly.py: -------------------------------------------------------------------------------- 1 | """This script aims to analyze the profitability of an EOA 2 | 3 | https://dexcheck.ai/app/address-analyzer/ 4 | 5 | 6 | """" 7 | 8 | -------------------------------------------------------------------------------- /BNB Chain/Memepool/Sandwich-Attack.py: -------------------------------------------------------------------------------- 1 | #sandwich-attack-bot 2 | #Scans the memepool for transactions and buys before the victm and sells after victime. buys -------------------------------------------------------------------------------- /BNB Chain/Memepool/config.py: -------------------------------------------------------------------------------- 1 | bsc_api ="KFEM9CQIBQVGZWTDGW5VDZGSM5ZYVGJ6KR" 2 | -------------------------------------------------------------------------------- /BNB Chain/Memepool/router_abi.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/BNB Chain/Memepool/router_abi.json -------------------------------------------------------------------------------- /BNB Chain/Miscellaneous/GetContractEventNames.py: -------------------------------------------------------------------------------- 1 | import web3 2 | from web3 import Web3 3 | import requests 4 | 5 | contract_abi = "contract_abi_string" 6 | 7 | web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed2.binance.org/")) 8 | 9 | 10 | 11 | contract_address =input("Enter Contract Address: ") 12 | 13 | def get_contract_abi(contract_address): 14 | try: 15 | bscscan_api_key = 'YJ1VVGT761NZBN6RTC5JWPTZ511GN4VHGT' 16 | url = f'https://api.bscscan.com/api?module=contract&action=getsourcecode&address={contract_address}&apikey={bscscan_api_key}' 17 | response = requests.get(url) 18 | 19 | if response.status_code == 200: 20 | contract_info = response.json() 21 | if 'result' in contract_info and contract_info['result'] and 'ABI' in contract_info['result'][0]: 22 | return contract_info['result'][0]['ABI'] 23 | else: 24 | return None 25 | else: 26 | return None 27 | except Exception as e: 28 | print(f"An error occurred while fetching contract ABI: {e}") 29 | return None 30 | 31 | 32 | contract_tirla = web3.eth.contract(address=contract_address, abi=get_contract_abi(contract_address)) 33 | 34 | event = contract_tirla.events 35 | 36 | 37 | for events in event: 38 | print(events) 39 | 40 | -------------------------------------------------------------------------------- /BNB Chain/Miscellaneous/GetTelegramGroup.py: -------------------------------------------------------------------------------- 1 | import json 2 | import time 3 | import datetime 4 | from web3 import Web3 5 | import requests 6 | import re 7 | 8 | 9 | 10 | 11 | web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed1.binance.org/")) 12 | 13 | def get_source_code(token_address): 14 | Eth_Api = "VFZUKK626NHN7SQTP1GAE5MK6TZN3BV2BR" # Change this to your Etherscan API ID 15 | sourceCodeGetRequestURL = "https://api.bscscan.com/api?module=contract&action=getsourcecode&address=" + token_address + "&apikey=" + Eth_Api 16 | response = requests.get(url=sourceCodeGetRequestURL) 17 | resultSourceCode = response.json() 18 | 19 | # Check if the request was successful 20 | if 'status' in resultSourceCode and resultSourceCode['status'] == '1': 21 | sourceCode = resultSourceCode['result'][0]['SourceCode'] 22 | #print(sourceCode) 23 | 24 | # Extract the Telegram link from the source code 25 | telegram_link = extract_telegram_link(str(sourceCode)) 26 | print(telegram_link) 27 | else: 28 | print("Failed to get source code.") 29 | 30 | 31 | 32 | def extract_telegram_link(source_code): 33 | pattern = r'(https?://t\.me/[^\s]+)' 34 | match = re.search(pattern, source_code) 35 | if match: 36 | return match.group(1) 37 | else: 38 | return None 39 | 40 | 41 | 42 | source_code =get_source_code("0x2BF588C05dfF2d926095e10f2bC0a2667eC0ABDE") 43 | -------------------------------------------------------------------------------- /BNB Chain/Miscellaneous/GettokenPrice_BNB_and_USDT.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | 3 | pancakeSwapAbi = [ 4 | { 5 | "inputs": [ 6 | {"internalType": "uint256", "name": "amountIn", "type": "uint256"}, 7 | {"internalType": "address[]", "name": "path", "type": "address[]"}, 8 | ], 9 | "name": "getAmountsOut", 10 | "outputs": [{"internalType": "uint256[]", "name": "amounts", "type": "uint256[]"}], 11 | "stateMutability": "view", 12 | "type": "function", 13 | } 14 | ] 15 | 16 | 17 | 18 | 19 | pancakeSwapContract = "0x10ED43C718714eb63d5aA57B78B54704E256024E" 20 | web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed1.binance.org")) 21 | 22 | 23 | def getAmountInBNB(tokenAddress, tokenAmount): 24 | BNBTokenAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" 25 | tokenAmountWei = web3.to_wei(tokenAmount, "ether") 26 | 27 | try: 28 | router = web3.eth.contract(abi=pancakeSwapAbi, address=pancakeSwapContract) 29 | amounts = router.functions.getAmountsOut(tokenAmountWei, [tokenAddress, BNBTokenAddress]).call() 30 | if amounts and len(amounts) > 1: 31 | amountInBNBWei = amounts[1] 32 | amountInBNB = web3.from_wei(amountInBNBWei, "ether") 33 | return round(amountInBNB,2) 34 | else: 35 | return None 36 | except Exception as error: 37 | print("Error in getAmountInBNB:", error) 38 | return None 39 | 40 | #def getAmountInUSDT(tokenAddress,tokenAmount,decimal): 41 | def getAmountInUSDT(tokenAmount): 42 | BNBTokenAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" 43 | USDTokenAddress = "0x55d398326f99059fF775485246999027B3197955" 44 | bnbToSell = web3.to_wei(tokenAmount, "ether") 45 | amountOut = None 46 | 47 | try: 48 | router = web3.eth.contract(abi=pancakeSwapAbi, address=pancakeSwapContract) 49 | amountOut = router.functions.getAmountsOut(bnbToSell, [BNBTokenAddress, USDTokenAddress]).call() 50 | #print("Amounts:", amountOut) # Add this line 51 | 52 | amountOut = web3.from_wei(amountOut[1], "ether") 53 | except Exception as error: 54 | print("Error:", error) # Add this line 55 | 56 | pass 57 | 58 | if not amountOut: 59 | return 0 60 | return round(amountOut) 61 | 62 | 63 | 64 | 65 | 66 | def main(): 67 | tokenAddress =web3.to_checksum_address("0xce186ad6430e2fe494a22c9edbd4c68794a28b35") 68 | tokenAmount = 102000 69 | 70 | amountInBNB = getAmountInBNB(tokenAddress, tokenAmount) 71 | amountInUSDT= getAmountInUSDT(amountInBNB) 72 | 73 | if amountInBNB is not None: 74 | print(f'Token Amount: {tokenAmount}') 75 | print(f'Token Amount in BNB: {amountInBNB}') 76 | print(f'Token Amount in USDT: ${amountInUSDT}') 77 | else: 78 | print("Failed to calculate the token amount in BNB.") 79 | 80 | 81 | if __name__ == "__main__": 82 | main() 83 | -------------------------------------------------------------------------------- /BNB Chain/Trading/AddLiquidityEvents.py: -------------------------------------------------------------------------------- 1 | "Using logs to listen to addingLiquity Events For All tokens on PancakeSwap" 2 | 3 | import web3 4 | import time 5 | import datetime 6 | 7 | url = "https://bsc-dataseed1.binance.org/" # Replace with your Ethereum node URL 8 | 9 | w3 = web3.Web3(web3.HTTPProvider(url)) 10 | def getTimestamp(): 11 | while True: 12 | timeStampData = datetime.datetime.now() 13 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 14 | return currentTimeStamp 15 | 16 | # Define Topic Filter 17 | topic_filter = [ 18 | "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f", 19 | "0x00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e" 20 | ] 21 | while True: 22 | # Create an event filter with the specified event signature 23 | event_filter = w3.eth.filter({'topics': topic_filter}) 24 | 25 | 26 | # Get changes in the filter to retrieve AddLiquidity events 27 | add_liquidity_events = w3.eth.get_filter_changes(event_filter.filter_id) 28 | 29 | 30 | for event in add_liquidity_events: 31 | txn_hash = event['transactionHash'].hex() 32 | txn_receipt= w3.eth.get_transaction(txn_hash) 33 | input_signature= txn_receipt['input'][:10].hex() 34 | #Filter with Add Liquidity Function Signature 35 | if input_signature.startswith('0xf305d719'): 36 | print("AddLiquidity Event:") 37 | print("Block Number:", event['blockNumber']) 38 | print("Transaction Hash:", event['transactionHash'].hex()) 39 | print("Log Index:", event['logIndex']) 40 | print("Topics:", event['topics']) 41 | print("Data:", event['data'].hex()) 42 | print("\n") 43 | 44 | -------------------------------------------------------------------------------- /BNB Chain/Trading/CopyBuy_Sells.py: -------------------------------------------------------------------------------- 1 | "Copy Buys and Sells Of a list of wallets" 2 | -------------------------------------------------------------------------------- /BNB Chain/Trading/CopyWalletTrade.py: -------------------------------------------------------------------------------- 1 | """Copy Wallet Trade""" 2 | 3 | 4 | import asyncio 5 | import json 6 | from web3 import Web3 7 | from websockets import connect 8 | import datetime 9 | import asyncio 10 | 11 | """ 12 | Subscribes to pending transactions 13 | https://community.infura.io/t/web3-py-how-to-subscribe-to-pending-ethereum-transactions-in-python/5409 14 | """ 15 | 16 | class style(): # Class of different text colours - default is white 17 | BLACK = '\033[30m' 18 | RED = '\033[31m' 19 | GREEN = '\033[32m' 20 | YELLOW = '\033[33m' 21 | BLUE = '\033[34m' 22 | MAGENTA = '\033[35m' 23 | CYAN = '\033[36m' 24 | WHITE = '\033[37m' 25 | UNDERLINE = '\033[4m' 26 | RESET = '\033[0m' 27 | def getTimestamp(): 28 | while True: 29 | timeStampData = datetime.datetime.now() 30 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 31 | return currentTimeStamp 32 | 33 | 34 | def format_hex(original_hex): 35 | hex_without_prefix = original_hex[2:] 36 | 37 | desired_length = 64 38 | 39 | padded_hex = hex_without_prefix.zfill(desired_length) 40 | 41 | final_hex = "0x" + padded_hex 42 | 43 | return final_hex.lower() 44 | 45 | 46 | 47 | 48 | infura_ws_url="Enter Your ChainStack Websocket URL" 49 | infura_http_url = 'https://bsc-dataseed1.binance.org/' 50 | web3 = Web3(Web3.HTTPProvider(infura_http_url)) 51 | WETH="0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" 52 | 53 | 54 | #Enter list of Wallet Addresses to monitor and copyTrade 55 | addresses = ["0x142aAbcc7D567e138384C1Fe637e3868e79eb9EB", 56 | "0xA80711c35543250191B52d3BDcABA125bceCC483", 57 | "0x981D4337876D3756d5BccbE2e1f3CF41C4496f7D"] 58 | 59 | monitored_wallets_hex = [format_hex(address) for address in addresses] 60 | 61 | 62 | async def get_event(): 63 | async with connect(infura_ws_url) as ws: 64 | await ws.send('{"jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}') 65 | subscription_response = await ws.recv() 66 | print(subscription_response) 67 | 68 | while True: 69 | try: 70 | message = await asyncio.wait_for(ws.recv(), timeout=15) 71 | response = json.loads(message) 72 | txHash = response['params']['result'] 73 | receipt = web3.eth.get_transaction_receipt(txHash) 74 | # print(receipt) 75 | transfer_details = web3.eth.get_transaction(txHash) 76 | 77 | from_address = transfer_details['from'] 78 | 79 | txn_hash = web3.to_hex(transfer_details['hash']) 80 | block_num = transfer_details['blockNumber'] 81 | if receipt['status'] == 1: 82 | # print(from_address) 83 | # 84 | # print(f"Transaction Successful, TxnHash: https://bscscan.com/tx/{txn_hash}") 85 | 86 | eth_value = None 87 | 88 | for logs in receipt['logs']: 89 | if logs['address'] == WETH and web3.to_hex(logs['topics'][ 90 | 0]) == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": 91 | hex_value = web3.to_hex(logs['data']) 92 | integer_value = int(hex_value, 16) 93 | eth_value = web3.from_wei(integer_value, 'ether') 94 | eth_value = '{:.4f}'.format(eth_value) 95 | 96 | if eth_value is not None: 97 | for logs in receipt['logs']: 98 | if logs['address'] != WETH: 99 | if web3.to_hex(logs['topics'][ 100 | 0]) == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": 101 | if web3.to_hex(logs['topics'][2]) in monitored_wallets_hex: 102 | print( 103 | f" {getTimestamp()} {style.RED}{block_num}{style.RESET} {style.GREEN} TOKEN BOUGHT: {logs['address']} {style.RESET} {style.MAGENTA} WALLET_ADDRESS: {from_address}{style.RESET} For {eth_value} BNB", 104 | style.RESET) 105 | print(f"TxnHash: https://bscscan.com/tx/{txn_hash} ") 106 | print(style.CYAN + "====BUYING TRADE SIMULATION======", style.RESET) 107 | # analyze_token(logs['address']) 108 | 109 | elif web3.to_hex(logs['topics'][1]) in monitored_wallets_hex: 110 | print( 111 | f" {getTimestamp()} {style.RED}{block_num}{style.RESET} {style.YELLOW}TOKEN SOLD: {logs['address']} {style.RESET} {style.MAGENTA} WALLET_ADDRESS: {from_address}{style.RESET} For {eth_value} BNB", 112 | style.RESET) 113 | print(f"TxnHash: https://bscscan.com/tx/{txn_hash} ") 114 | print(style.MAGENTA + "====SELLING TRADE SALE SIMULATION=====", style.RESET) 115 | elif logs['address'] != WETH: 116 | if web3.to_hex( 117 | logs['topics'][ 118 | 0]) == "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925": 119 | if web3.to_hex(logs['topics'][1]) in monitored_wallets_hex: 120 | print( 121 | f"{getTimestamp()} {style.RED}{block_num}{style.RESET}{style.MAGENTA} TOKEN APPROVED: {logs['address']}{style.RESET}{style.MAGENTA} WALLET_ADDRESS {from_address}{style.RESET} ", 122 | style.RESET) 123 | print(f"TxnHash: https://bscscan.com/tx/{txn_hash}") 124 | print(style.MAGENTA + "====APPROVED TRANSACTION=====", style.RESET) 125 | else: 126 | pass 127 | # print("Transaction Failed") 128 | # print(f"TxnHash: https://bscscan.com/tx/{txn_hash}") 129 | # print(style.RED + "====TRANSACTION FAILED=====", style.RESET) 130 | except Exception as e: 131 | pass 132 | #print("An error occurred while processing a transaction:", e) 133 | 134 | if __name__ == "__main__": 135 | loop = asyncio.get_event_loop() 136 | while True: 137 | loop.run_until_complete(get_event()) -------------------------------------------------------------------------------- /BNB Chain/Trading/LaunchBot.py: -------------------------------------------------------------------------------- 1 | "Monitor token liquidity pools and automatically execute token purchases upon detecting the addition of liquidity." -------------------------------------------------------------------------------- /BNB Chain/Trading/MonitorMultipleAddresses.py: -------------------------------------------------------------------------------- 1 | #TODO -------------------------------------------------------------------------------- /BNB Chain/Trading/TrackEOA_ReceivingBNB.py: -------------------------------------------------------------------------------- 1 | #TODO Track the contract address of BNB smartcontract dispatcher. The aim is to find new wallets that receive BNB ie Lowe nonce count and the aggregae them in a pool and monitor them for new transactions emmited -------------------------------------------------------------------------------- /BNB Chain/Trading/TrackingSmartContractEvents.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/BNB Chain/Trading/TrackingSmartContractEvents.py -------------------------------------------------------------------------------- /BNB Chain/Trading/sendMessage.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | #https://testnet.bscscan.com/address/0x32f4b44286be50e905cfc5ab16b0a4747f477276 3 | # Node Connection 4 | w3 = Web3(Web3.HTTPProvider('https://data-seed-prebsc-1-s1.binance.org:8545/')) 5 | 6 | # Replace these with the sender's private key and the recipient's address 7 | sender_private_key = 'Enter Your Private Key' 8 | recipient_address = w3.toChecksumAddress('Enter Recipient Address') 9 | 10 | # Your message 11 | message = 'Enter Your Message' 12 | 13 | # Convert the message to hexadecimal data 14 | message_hex = message.encode('utf-8').hex() 15 | 16 | # Sender's address 17 | sender_address = w3.toChecksumAddress("Sender's Address") 18 | 19 | 20 | # Set up the transaction 21 | transaction = { 22 | 'to': recipient_address, 23 | 'value': w3.toWei(0, 'ether'), # Set the amount of Ether to send 24 | 'gas': 100000, 25 | 'gasPrice': w3.toWei('50', 'gwei'), 26 | 'nonce': w3.eth.getTransactionCount(sender_address), 27 | 'data': '0x' + message_hex, # Include the message as hexadecimal data 28 | } 29 | 30 | # Sign the transaction 31 | signed_transaction = w3.eth.account.signTransaction(transaction, sender_private_key) 32 | 33 | # Send the transaction 34 | transaction_hash = w3.eth.sendRawTransaction(signed_transaction.rawTransaction) 35 | 36 | print(f'Transaction hash: {transaction_hash.hex()}') 37 | 38 | #https://testnet.bscscan.com/tx/0x2803ab01415414661a1ab5bb235d591748affd369fd2a30048c9f76a6f8b028f -------------------------------------------------------------------------------- /BNB Chain/Wallet/BuywithMultipleWallets.py: -------------------------------------------------------------------------------- 1 | #To Do -------------------------------------------------------------------------------- /BNB Chain/Wallet/Hd-wallet.py: -------------------------------------------------------------------------------- 1 | "Generate Wallet from Mnemonic" 2 | 3 | from web3 import Web3 4 | from mnemonic import Mnemonic 5 | from web3 import Web3 6 | import secrets 7 | from eth_account import Account 8 | """ 9 | Please note the public key might differ when importing the mnemonic phrase into different wallet services 10 | like TrustWallet or SafePal because these services might use different derivation paths. 11 | 12 | Popular derivation paths include: 13 | 14 | BIP44: m/44'/coin_type'/account'/change/address_index 15 | BIP49: m/49'/coin_type'/account'/change/address_index 16 | BIP84: m/84'/coin_type'/account'/change/address_index 17 | 18 | """ 19 | 20 | w3 = Web3(Web3.HTTPProvider("https://bsc-dataseed1.binance.org/")) 21 | 22 | mnemo = Mnemonic("english") 23 | words = mnemo.generate(strength=256) 24 | 25 | extra_security= secrets.token_hex(32) 26 | 27 | w3.eth.account.enable_unaudited_hdwallet_features() 28 | #Generated Acct from Mnemonic 29 | acct = Account.from_mnemonic(words,passphrase=extra_security) 30 | acct_privatekeys =w3.toHex(acct.privateKey) 31 | accout = w3.eth.account.privateKeyToAccount(acct_privatekeys) 32 | 33 | account_publickey = accout.address 34 | account_privatekey= accout.privateKey 35 | # print("MNEMONIC ADDRESS-- Public Key",acct.address) 36 | # print("MNEMONIC PRIVATE KEY---[KEEP PRIVATE]",w3.toHex(acct.privateKey)) 37 | print("MNEMONIC PHRASE--[KEEP PRIVATE]",words) 38 | 39 | print('Public Key', account_publickey) 40 | print("Private_Key---[KEEP PRIVATE]",w3.toHex(account_privatekey)) -------------------------------------------------------------------------------- /BNB Chain/Wallet/MonitorMultipleWallets.py: -------------------------------------------------------------------------------- 1 | """Monitor Multiple Wallets 2 | Keep track of their Nonce and current Balance 3 | 4 | 5 | """ 6 | 7 | ## TODO -------------------------------------------------------------------------------- /BNB Chain/Wallet/MonitorPriceandSell.py: -------------------------------------------------------------------------------- 1 | #To do -------------------------------------------------------------------------------- /BNB Chain/Wallet/SendBNB-MultipleWallets.py: -------------------------------------------------------------------------------- 1 | "Send BNB to Multiple wallets " -------------------------------------------------------------------------------- /BNB Chain/Wallet/addresses_and_keys.crypto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/BNB Chain/Wallet/addresses_and_keys.crypto -------------------------------------------------------------------------------- /BNB Chain/Wallet/create-multiple-BSCaddress.py: -------------------------------------------------------------------------------- 1 | 2 | from web3 import Web3 3 | import secrets 4 | import csv 5 | import os 6 | 7 | # Connect to the Binance blockchain using the Infura node 8 | web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed1.binance.org/")) 9 | 10 | # Define the number of addresses to generate 11 | num_addresses = 10 12 | 13 | # Define the filename 14 | filename = "addresses_and_keys.csv" 15 | 16 | # Check if the file exists; if not, create it and write the header row 17 | if not os.path.exists(filename): 18 | with open(filename, "w", newline='') as csvfile: 19 | csvwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) 20 | csvwriter.writerow(['Enumeration', 'Address', 'Private Key']) 21 | 22 | # Open the CSV file in append mode to store the new addresses and private keys 23 | with open(filename, "a", newline='') as csvfile: 24 | # Create a CSV writer object 25 | csvwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) 26 | 27 | # Get the current enumeration value from the file 28 | with open(filename, "r") as csvfile_read: 29 | enumeration = sum(1 for _ in csvfile_read) - 1 # Subtract 1 for the header row 30 | 31 | # Generate the addresses and private keys 32 | for i in range(num_addresses): 33 | extra_security = secrets.token_hex(32) 34 | # Generate a new Binance address and private key 35 | address = web3.eth.account.create(extra_security) 36 | 37 | # Print the address and private key 38 | print(f"Address: {address.address}") 39 | print(f"Private key: {address.privateKey.hex()}") 40 | 41 | # Write the enumeration, address, and private key to the CSV file 42 | csvwriter.writerow([enumeration + i + 1, address.address, address.privateKey.hex()]) 43 | 44 | 45 | 46 | 47 | 48 | """Object Oriented Implementation """ 49 | 50 | # from web3 import Web3 51 | # import secrets 52 | # import csv 53 | # import os 54 | # 55 | # 56 | # class BinanceAddressGenerator: 57 | # def __init__(self, num_addresses=10, filename="addresses_and_keys.csv"): 58 | # self.web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed1.binance.org/")) 59 | # self.num_addresses = num_addresses 60 | # self.filename = filename 61 | # 62 | # def generate_address(self): 63 | # extra_security = secrets.token_hex(32) 64 | # return self.web3.eth.account.create(extra_security) 65 | # 66 | # def save_addresses_to_csv(self, addresses): 67 | # if not os.path.exists(self.filename): 68 | # with open(self.filename, "w", newline='') as csvfile: 69 | # csvwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) 70 | # csvwriter.writerow(['Enumeration', 'Address', 'Private Key']) 71 | # 72 | # with open(self.filename, "a", newline='') as csvfile: 73 | # csvwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) 74 | # 75 | # with open(self.filename, "r") as csvfile_read: 76 | # enumeration = sum(1 for _ in csvfile_read) - 1 77 | # 78 | # for i, address in enumerate(addresses): 79 | # csvwriter.writerow([enumeration + i + 1, address.address, address.privateKey.hex()]) 80 | # 81 | # def generate_and_save_addresses(self): 82 | # addresses = [self.generate_address() for _ in range(self.num_addresses)] 83 | # self.save_addresses_to_csv(addresses) 84 | # return addresses 85 | # 86 | # 87 | # if __name__ == "__main__": 88 | # generator = BinanceAddressGenerator(num_addresses=10) 89 | # generated_addresses = generator.generate_and_save_addresses() 90 | # 91 | # for address in generated_addresses: 92 | # print(f"Address: {address.address}") 93 | # print(f"Private key: {address.privateKey.hex()}") 94 | -------------------------------------------------------------------------------- /Ethereum/DEX/CheckIfLiquidity_IsAdded.py: -------------------------------------------------------------------------------- 1 | import json 2 | from web3 import Web3 3 | import time 4 | import datetime 5 | import requests 6 | 7 | 8 | 9 | class style(): # Class of different text colours - default is white 10 | BLACK = '\033[30m' 11 | RED = '\033[31m' 12 | GREEN = '\033[32m' 13 | YELLOW = '\033[33m' 14 | BLUE = '\033[34m' 15 | MAGENTA = '\033[35m' 16 | CYAN = '\033[36m' 17 | WHITE = '\033[37m' 18 | UNDERLINE = '\033[4m' 19 | RESET = '\033[0m' 20 | 21 | 22 | 23 | 24 | def getTimestamp(): 25 | while True: 26 | timeStampData = datetime.datetime.now() 27 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 28 | return currentTimeStamp 29 | 30 | 31 | web3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 32 | if web3.is_connected(): 33 | print(getTimestamp()," Ethereum Node successfully connected") 34 | 35 | contract_address = input("Enter Token Address: ") 36 | WETH= "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 37 | 38 | pancake_factory = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f' # Testnet #0x6725F303b657a9451d8BA641348b6761A6CC7a17 39 | pancake_factory_abi = json.loads('[{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]') 40 | contract = web3.eth.contract(address=pancake_factory, abi=pancake_factory_abi) 41 | lp_abi = '[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint112","name":"reserve0","type":"uint112"},{"indexed":false,"internalType":"uint112","name":"reserve1","type":"uint112"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MINIMUM_LIQUIDITY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint112","name":"_reserve0","type":"uint112"},{"internalType":"uint112","name":"_reserve1","type":"uint112"},{"internalType":"uint32","name":"_blockTimestampLast","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"kLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"price0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"price1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"skim","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount0Out","type":"uint256"},{"internalType":"uint256","name":"amount1Out","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sync","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]' 42 | 43 | 44 | 45 | 46 | 47 | def get_liquidity_balance(lp_address): 48 | lp_contract = web3.eth.contract(address=lp_address, abi=lp_abi) 49 | reserves = lp_contract.functions.getReserves().call() 50 | balance = reserves[0] 51 | return balance 52 | 53 | def check_liquidity(lp_address): 54 | balance = get_liquidity_balance(lp_address) 55 | if balance > 0: 56 | print(f"{getTimestamp()} Liquidity balance detected' {balance}") 57 | #buy() # We can set up buy as soon as liquidity is added 58 | else: 59 | print('No liquidity balance detected') 60 | 61 | 62 | 63 | def run_lp_check(): 64 | lp_address = contract.functions.getPair(contract_address, WETH).call() 65 | if lp_address != web3.to_checksum_address('0x0000000000000000000000000000000000000000'): 66 | print('LP address detected:', lp_address) 67 | check_liquidity(lp_address) 68 | return True 69 | else: 70 | print('No LP address found') 71 | return False 72 | 73 | while True: 74 | print("Starting Check") 75 | run_lp_check() 76 | time.sleep(1) 77 | break 78 | 79 | -------------------------------------------------------------------------------- /Ethereum/Decoding/Example_1.py: -------------------------------------------------------------------------------- 1 | from eth_abi import abi 2 | from web3 import Web3 3 | # ABI for the transferFrom function 4 | transfer_from_abi = ['address', 'address', 'uint256'] 5 | web3 = Web3(Web3.HTTPProvider('ENTER YOUR NODEURL')) 6 | 7 | txn_hash="0xfdc9939cb6bd71bdec1f86eccd44dc7faa79f98c82dac2ae1910e383971fbe8d" 8 | 9 | tx_log = web3.eth.get_transaction_receipt(txn_hash).logs 10 | topics= tx_log[1]['topics'] # 5th log is the swap 11 | #print(topics) 12 | first_topic = web3.to_hex(topics[1]) 13 | second_topic = web3.to_hex(topics[2]) 14 | third_topic = web3.to_hex(topics[3]) 15 | 16 | DATA = topics[1] + topics[2] + topics[3] 17 | decodedABI = abi.decode(transfer_from_abi, DATA) 18 | print(decodedABI) 19 | 20 | -------------------------------------------------------------------------------- /Ethereum/Decoding/Example_2.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | from eth_abi import abi 3 | tx_hash = '0xb9ae909908fc911f547845c853422832538ef97ff2c569ac403ecbd252840c6e' 4 | web3 = Web3(Web3.HTTPProvider('Enter your node url')) 5 | 6 | txn_log = web3.eth.get_transaction_receipt(tx_hash).logs 7 | topics = txn_log[5]['topics'] # 5th log is the swap log 8 | first_topic = web3.to_hex(topics[1]) 9 | second_topic = web3.to_hex(topics[2]) 10 | third_topic = web3.to_hex(txn_log[5]['data']) 11 | 12 | # Print the values of topics 13 | # print("First Topic:", first_topic) 14 | # print("Second Topic:", second_topic) 15 | # print("Third Topic:", third_topic) 16 | 17 | DATA = topics[1] + topics[2] + txn_log[5]['data'] 18 | 19 | decodedABI = abi.decode(['address', 'uint256', 'uint256', 'uint256','uint256','address'], DATA) 20 | print(decodedABI) 21 | -------------------------------------------------------------------------------- /Ethereum/Evaluate ERC20 Token/EvaluateToken_HoneypotAPI.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | #TODO Add additional checks based on research 4 | class style(): # Class of different text colours - default is white 5 | BLACK = '\033[30m' 6 | RED = '\033[31m' 7 | GREEN = '\033[32m' 8 | YELLOW = '\033[33m' 9 | BLUE = '\033[34m' 10 | MAGENTA = '\033[35m' 11 | CYAN = '\033[36m' 12 | WHITE = '\033[37m' 13 | UNDERLINE = '\033[4m' 14 | RESET = '\033[0m' 15 | 16 | def check_token_honeypot(): 17 | token_address= input("Enter Token Address: ") 18 | # API endpoint URL 19 | url = "https://api.honeypot.is/v2/IsHoneypot" 20 | 21 | # Construct the query parameters 22 | params = { 23 | "address": token_address, 24 | } 25 | 26 | # Make the GET request 27 | response = requests.get(url, params=params) 28 | 29 | if response.status_code == 200: 30 | data = response.json() 31 | is_honeypot = data['honeypotResult']['isHoneypot'] 32 | honeypot_reason = data['honeypotResult'].get('honeypotReason', None) 33 | 34 | simulation_results = { 35 | "BUY TAX": f"{data['simulationResult']['buyTax']:.2f}%", 36 | "SELL TAX": f"{data['simulationResult']['sellTax']:.2f}%", 37 | "TRANSFER TAX": f"{data['simulationResult']['transferTax']:.2f}%", 38 | "BUY GAS": data['simulationResult']['buyGas'], 39 | "SELL GAS": data['simulationResult']['sellGas'], 40 | "SOURCE CODE": "OPEN SOURCE", 41 | } 42 | 43 | recent_holders_analysis = { 44 | "HOLDERS ANALYSED": data['holderAnalysis']['holders'], 45 | "CAN SELL": data['holderAnalysis']['successful'], 46 | "CAN'T SELL": data['holderAnalysis']['failed'], 47 | "SIPHONED": data['holderAnalysis']['siphoned'], 48 | "AVERAGE TAX": f"{data['holderAnalysis']['averageTax']:.1f}%", 49 | "HIGHEST TAX": f"{data['holderAnalysis']['highestTax']:.1f}%", 50 | "AVERAGE GAS": f"{data['holderAnalysis']['averageGas']:,}", 51 | "EXTREMELY HIGH TAX HOLDERS": data['holderAnalysis']['highTaxWallets'], 52 | } 53 | 54 | column_width = 30 55 | 56 | if is_honeypot: 57 | print(style.RED + f"EXECUTION REVERTED\n{honeypot_reason}\n" + style.RESET) 58 | if float(simulation_results["BUY TAX"][:-1]) > 50 or float(simulation_results["SELL TAX"][:-1]) > 50: 59 | print("WARNINGS") 60 | print( 61 | "The taxes on this token are extremely high. You will get significantly less from a trade than expected, be careful!") 62 | print("The average tax is very high. Be careful!\n") 63 | print("SIMULATION RESULTS") 64 | for key, value in simulation_results.items(): 65 | print(f"{key:{column_width}}{value:{column_width}}") 66 | print(f"BUY LIMIT:{'NONE DETECTED':{column_width}}SELL LIMIT:{'NONE DETECTED':{column_width}}") 67 | print("EXTREMELY HIGH TAX HOLDERS\n" + data['holderAnalysis']['highTaxWallets']) 68 | print("\nRECENT HOLDERS ANALYSIS") 69 | for key, value in recent_holders_analysis.items(): 70 | print(f"{key:{column_width}}{value:{column_width}}") 71 | else: 72 | print(style.GREEN + "NOT A HONEYPOT" + style.RESET) 73 | print("SIMULATION RESULTS") 74 | for key, value in simulation_results.items(): 75 | print(f"{key:{column_width}}{value:{column_width}}") 76 | print(f"BUY LIMIT:{'NONE DETECTED':{column_width}}SELL LIMIT:{'NONE DETECTED':{column_width}}") 77 | print("EXTREMELY HIGH TAX HOLDERS\n" + data['holderAnalysis']['highTaxWallets']) 78 | print("\nRECENT HOLDERS ANALYSIS") 79 | for key, value in recent_holders_analysis.items(): 80 | print(f"{key:{column_width}}{value:{column_width}}") 81 | 82 | 83 | check_token_honeypot() 84 | -------------------------------------------------------------------------------- /Ethereum/Evaluate ERC20 Token/GetLocktime.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | # Unix timestamp 4 | timestamp = int(input("Enter unix timestamp: ")) 5 | 6 | # Convert the timestamp to a date 7 | date = datetime.datetime.fromtimestamp(timestamp) 8 | 9 | # Get the current date 10 | current_date = datetime.datetime.now() 11 | 12 | lock_date = f"{current_date:%d-%m-%Y %H:%M:%S}" 13 | 14 | # Calculate the difference from current date 15 | difference = date-current_date 16 | locktime= difference.days 17 | print(current_date) 18 | print(locktime) 19 | print("Tokens are locked till: ",lock_date) 20 | print("Months Lock",locktime//30) 21 | print("Years Lock",locktime//365) 22 | -------------------------------------------------------------------------------- /Ethereum/Evaluate ERC20 Token/Token-Early-Transactions.py: -------------------------------------------------------------------------------- 1 | "Focus on buys immediately after liquitidy is added" 2 | 3 | import requests 4 | import json 5 | 6 | 7 | api_key = 'QSD4D9KG1NYTX3Y6CPAR62G9FBW16UZ81Z' 8 | 9 | # Prompt user to input the token contract address and number of wallets 10 | contract_address = input("Enter the token contract address: ") 11 | num_wallets = int(input("Enter the number of wallets to display: ")) 12 | 13 | # Define the BscScan API URL 14 | url = f"https://api.etherscan.io/api?module=account&action=tokentx&contractaddress={contract_address}&apikey={api_key}" 15 | 16 | # Send a request to BscScan API and parse the JSON response 17 | response = requests.get(url) 18 | data = json.loads(response.text) 19 | 20 | 21 | if data['status'] == "1": 22 | transactions = data['result'] 23 | 24 | # Filter transactions and get the first 'num_wallets' wallet addresses 25 | wallets = [] 26 | print(f"\nThe first {num_wallets} wallets that bought the token after liquidity was added:\n") 27 | for tx in transactions: 28 | #if tx['from'] != contract_address and tx['to'] != contract_address: 29 | if tx['from'] not in wallets: 30 | wallets.append(tx['from']) 31 | print(f"{len(wallets)}. Wallet: {tx['from']}, TxHash: https://etherscan.io/tx/{tx['hash']}") 32 | 33 | if len(wallets) >= num_wallets: 34 | break 35 | # elif tx['to'] == contract_address.lower(): #and len(wallets) == 1: 36 | # print(f"Liquidity added transaction: TxHash: {tx['hash']}\n") 37 | else: 38 | print("Error fetching transactions. Please check the contract address and try again.") 39 | -------------------------------------------------------------------------------- /Ethereum/GasFees/gas_fees.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | 3 | # Replace 'YOUR_NODE_URL' with the URL of your Ethereum node 4 | web3 = Web3(Web3.HTTPProvider('Enter your Node URL')) 5 | latest_block = web3.eth.get_block('latest') 6 | 7 | # Ensure connection to the node 8 | if web3.is_connected(): 9 | # Get the latest block 10 | latest_block = web3.eth.get_block('latest') 11 | #latest_block= 18792112 12 | gas_used = 300000 # Replace with the actual gas used by your transaction 13 | 14 | # Extract gas limit and base fee 15 | gas_limit = latest_block['gasLimit'] 16 | base_fee = latest_block['baseFeePerGas'] 17 | print(f"Latest Block: {latest_block['number']}") 18 | print(f"Gas Limit: {gas_limit}") 19 | print(f"Base Fee: {base_fee}") 20 | base_fee_gwei = base_fee / 10**9 21 | print(f"Base Fee (GWEI): {base_fee_gwei}") 22 | # Calculate transaction cost in Ether 23 | transaction_cost_ether = (gas_used * base_fee_gwei) / 10 ** 9 24 | print(f"Transaction Cost (Ether): {transaction_cost_ether}") 25 | gas_price_estimate = web3.eth.gas_price 26 | print(f"Gas Price Estimate (Wei): {gas_price_estimate}") 27 | 28 | # Convert gas price to Gwei for a more readable output 29 | gas_price_gwei = web3.from_wei(gas_price_estimate, 'gwei') 30 | print(f"Gas Price Estimate (Gwei): {gas_price_gwei}") 31 | print(f"Block status: {len(latest_block['transactions'])}") -------------------------------------------------------------------------------- /Ethereum/GoogleCloudSetUp/Instructions.md: -------------------------------------------------------------------------------- 1 | ###Instructions on how to host your crypto bot on the cloud -------------------------------------------------------------------------------- /Ethereum/JarethFromSubway/jareth_copytrade.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/Ethereum/JarethFromSubway/jareth_copytrade.py -------------------------------------------------------------------------------- /Ethereum/JarethFromSubway/uniswapAnalytics.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Ethereum/Launchpads/All_LaunchpadsEvents.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/Ethereum/Launchpads/All_LaunchpadsEvents.py -------------------------------------------------------------------------------- /Ethereum/Memepool/DecodingExecuteFunction.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | import requests 3 | 4 | from uniswap_universal_router_decoder import RouterCodec 5 | 6 | 7 | trx_input="0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000064a20d9f00000000000000000000000000000000000000000000000000000000000000020b080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000008e1bc9bf04000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000008e1bc9bf040000000000000000000000000000000000000000000000000027f13b0836f656fb7a00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000073ae4ba01e38ba5da762e3e65eeb9b03a732dcd9" 8 | codec = RouterCodec() 9 | decoded_trx_input = codec.decode.function_input(trx_input) 10 | 11 | path = decoded_trx_input[1]['inputs'][1][1]['path'] 12 | 13 | # print(decoded_trx_input) 14 | print(path) -------------------------------------------------------------------------------- /Ethereum/Memepool/simple.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from web3 import Web3 4 | import time 5 | 6 | w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 7 | 8 | uniswap_contract_address = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D' # Replace with Uniswap contract address 9 | 10 | def handle_new_block(block): 11 | for tx_hash in block['transactions']: 12 | 13 | try: 14 | tx = w3.eth.getTransaction(tx_hash) 15 | 16 | if tx['to'].lower() == uniswap_contract_address.lower(): 17 | # Process the transaction 18 | print("Transaction interacting with Uniswap:", w3.toHex(tx['hash'])) 19 | print("Input", tx['input']) 20 | except Exception as e: 21 | print("An error occurred while processing a transaction:", e) 22 | 23 | 24 | def setup_block_filter(): 25 | new_block_filter = w3.eth.filter('latest') 26 | 27 | while True: 28 | for block_hash in new_block_filter.get_new_entries(): 29 | block = w3.eth.getBlock(block_hash) 30 | handle_new_block(block) 31 | 32 | # Sleep for a certain interval before checking for new blocks again 33 | time.sleep(1) 34 | 35 | # Set up the block filter 36 | setup_block_filter() -------------------------------------------------------------------------------- /Ethereum/Miscellaneous/Block_logs.py: -------------------------------------------------------------------------------- 1 | 2 | from web3 import Web3 3 | w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 4 | 5 | 6 | 7 | 8 | block = w3.eth.get_block(17828184) 9 | 10 | 11 | block_number = 17828184 # Replace this with the block number you want to fetch 12 | 13 | 14 | for transaction_hash in block['transactions']: 15 | transaction = w3.eth.get_transaction(transaction_hash) 16 | transaction_receipt = w3.eth.get_transaction_receipt(transaction_hash) 17 | 18 | if transaction_receipt and 'logs' in transaction_receipt: 19 | logs = transaction_receipt['logs'] 20 | 21 | for log in logs: 22 | # Process the log data as needed 23 | print(f"Transaction Hash: {transaction_hash.hex()}, Log: {log}") -------------------------------------------------------------------------------- /Ethereum/Miscellaneous/GetEventNames.py: -------------------------------------------------------------------------------- 1 | import web3 2 | from web3 import Web3 3 | import requests 4 | 5 | contract_abi = "contract_abi_string" 6 | 7 | web3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 8 | 9 | # pinkysale ="0x71B5759d73262FBb223956913ecF4ecC51057641" 10 | # unicript = "0x663A5C229c09b049E36dCc11a9B0d4a8Eb9db214" 11 | # trustswap="0xE2fE530C047f2d85298b07D9333C05737f1435fB" 12 | 13 | contract_address =input("Enter Contract Address: ") 14 | 15 | def get_contract_abi(contract_address): 16 | try: 17 | bscscan_api_key = 'QSD4D9KG1NYTX3Y6CPAR62G9FBW16UZ81Z' 18 | url = f'https://api.etherscan.io/api?module=contract&action=getsourcecode&address={contract_address}&apikey={bscscan_api_key}' 19 | response = requests.get(url) 20 | 21 | if response.status_code == 200: 22 | contract_info = response.json() 23 | if 'result' in contract_info and contract_info['result'] and 'ABI' in contract_info['result'][0]: 24 | return contract_info['result'][0]['ABI'] 25 | else: 26 | return None 27 | else: 28 | return None 29 | except Exception as e: 30 | print(f"An error occurred while fetching contract ABI: {e}") 31 | return None 32 | 33 | 34 | contract_tirla = web3.eth.contract(address=contract_address, abi=get_contract_abi(contract_address)) 35 | 36 | event = contract_tirla.events 37 | 38 | 39 | for events in event: 40 | print(events) 41 | 42 | -------------------------------------------------------------------------------- /Ethereum/Miscellaneous/GetTokenPairFromLp.py: -------------------------------------------------------------------------------- 1 | "Get Token Pair from lp address" 2 | 3 | 4 | from web3 import Web3 5 | 6 | 7 | w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 8 | lp_address = input("Enter LP Address: ") 9 | 10 | 11 | uniswap_v2_pair_abi = '[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint112","name":"reserve0","type":"uint112"},{"indexed":false,"internalType":"uint112","name":"reserve1","type":"uint112"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MINIMUM_LIQUIDITY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint112","name":"_reserve0","type":"uint112"},{"internalType":"uint112","name":"_reserve1","type":"uint112"},{"internalType":"uint32","name":"_blockTimestampLast","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"kLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"price0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"price1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"skim","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount0Out","type":"uint256"},{"internalType":"uint256","name":"amount1Out","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"sync","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]' 12 | 13 | uniswap_v2_pair = w3.eth.contract(address=lp_address, abi=uniswap_v2_pair_abi) 14 | 15 | 16 | 17 | 18 | 19 | def get_token_from_lp(lpAddres): 20 | uniswap_v2_pair = w3.eth.contract(address=lp_address, abi=uniswap_v2_pair_abi) 21 | 22 | tokenA_address = uniswap_v2_pair.functions.token0().call() 23 | tokenB_address = uniswap_v2_pair.functions.token1().call() 24 | 25 | return f" Token A: {tokenA_address} Token B {tokenB_address}" 26 | 27 | print(get_token_from_lp(lp_address)) 28 | 29 | 30 | -------------------------------------------------------------------------------- /Ethereum/Miscellaneous/SpecificTokenInWallet_PriceInWETHUSDT.py: -------------------------------------------------------------------------------- 1 | 2 | from web3 import Web3 3 | web3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 4 | 5 | 6 | tokenAbi = [ 7 | {"constant": True, "inputs": [], "name": "decimals", "outputs": [{"name": "", "type": "uint8"}], "payable": False, "stateMutability": "view", "type": "function"}, 8 | {"constant": True, "inputs": [], "name": "name", "outputs": [{"name": "", "type": "string"}], "payable": False, "stateMutability": "view", "type": "function"}, 9 | {"constant": True, "inputs": [], "name": "symbol", "outputs": [{"name": "", "type": "string"}], "payable": False, "stateMutability": "view", "type": "function"}, 10 | {"constant": True,"inputs": [{"name": "owner", "type": "address"}],"name": "balanceOf","outputs": [{"name": "", "type": "uint256"}],"payable": False,"stateMutability": "view","type": "function"} 11 | ] 12 | 13 | 14 | V2SwapAbi = [ 15 | { 16 | "inputs": [ 17 | {"internalType": "uint256", "name": "amountIn", "type": "uint256"}, 18 | {"internalType": "address[]", "name": "path", "type": "address[]"}, 19 | ], 20 | "name": "getAmountsOut", 21 | "outputs": [{"internalType": "uint256[]", "name": "amounts", "type": "uint256[]"}], 22 | "stateMutability": "view", 23 | "type": "function", 24 | }, 25 | 26 | ] 27 | 28 | V2SwapContract = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" 29 | 30 | 31 | tokenAddress= input("Enter Token Address ") 32 | #tokenAddress=web3.to_checksum_address(tokenAddress) 33 | walletAddress= input("Enter Wallet Address") 34 | walletAddress=web3.to_checksum_address(walletAddress) 35 | 36 | tokenContract = web3.eth.contract(address=tokenAddress, abi=tokenAbi) 37 | 38 | decimals = tokenContract.functions.decimals().call() 39 | tokenName = tokenContract.functions.name().call() 40 | balance = tokenContract.functions.balanceOf(walletAddress).call() 41 | token_balance= balance/10 **decimals 42 | WETH="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 43 | USDT="0xdAC17F958D2ee523a2206206994597C13D831ec7" 44 | def findMatchingDecimal(token_decimals): 45 | decimalsDict = { 46 | 1: "wei", 47 | 1000: "kwei", 48 | 1000000: "mwei", 49 | 1000000000: "gwei", 50 | 1000000000000: "szabo", 51 | 1000000000000000: "finney", 52 | 1000000000000000000: "ether", 53 | 1000000000000000000000: "kether", 54 | 1000000000000000000000000: "mether", 55 | 1000000000000000000000000000: "gether", 56 | 1000000000000000000000000000000: "tether" 57 | } 58 | 59 | matching_entry = decimalsDict.get(10 ** token_decimals) 60 | return matching_entry 61 | 62 | def getAmountInBNB(tokenAddress, tokenAmount): 63 | tokenAmountWei = web3.to_wei(tokenAmount, findMatchingDecimal(decimals)) 64 | 65 | try: 66 | router = web3.eth.contract(abi=V2SwapAbi, address=V2SwapContract) 67 | amounts = router.functions.getAmountsOut(tokenAmountWei, [tokenAddress, WETH]).call() 68 | if amounts and len(amounts) > 1: 69 | amountInBNBWei = amounts[1] 70 | amountInBNB = web3.from_wei(amountInBNBWei, "ether") 71 | return round(amountInBNB,2) 72 | else: 73 | return None 74 | except Exception as error: 75 | print("Error in getAmountInBNB:", error) 76 | return None 77 | 78 | 79 | def getAmountInUSDT(tokenAmount): 80 | 81 | EthToSell = web3.to_wei(tokenAmount, "ether") 82 | #EthToSell = web3.to_wei(str(tokenAmount), "ether") 83 | #EthToSell = int(tokenAmount * 1e18) # Convert to wei directly 84 | 85 | amountOut = None 86 | 87 | try: 88 | router = web3.eth.contract(abi=V2SwapAbi, address=V2SwapContract) 89 | amountOut = router.functions.getAmountsOut(EthToSell, [WETH, USDT]).call() 90 | #print("Amounts:", amountOut) # Add this line 91 | amountOut = web3.from_wei(amountOut[1], "mwei") 92 | 93 | except Exception as error: 94 | print("Error:", error) # Add this line 95 | 96 | pass 97 | 98 | # if not amountOut: 99 | # return 0 100 | return round(amountOut) 101 | 102 | weth_amount= getAmountInBNB(tokenAddress,token_balance) 103 | print(weth_amount) 104 | if web3.is_connected() and tokenContract: 105 | if balance is not None and decimals is not None: 106 | print(f"Token Balance: {round(token_balance)}") 107 | print(f"Balance in ETH: {getAmountInBNB(tokenAddress,token_balance)}") 108 | print(f"Balance in USDT {getAmountInUSDT(weth_amount)}") 109 | print(f"Token Name: {tokenName}") 110 | 111 | else: 112 | print("Failed to retrieve token balance or decimals.") 113 | else: 114 | print("Web3 connection error or invalid token contract.") 115 | -------------------------------------------------------------------------------- /Ethereum/Monitoring/Monitor-MultipleLp-Concurrently.py: -------------------------------------------------------------------------------- 1 | """Monitor multiple liquidity providers concurrently and send alerts to telegram bot. Have a basis for growth rate and decline rate." 2 | 3 | How can this be intergrated to the evaluabtion bot? 4 | Can you get traction of a token and determine optimal buying point and selling point 5 | 6 | What data do you need to determine the optimal buying point and selling point? 7 | 8 | What is the best way to determine the optimal buying point and selling point? 9 | 10 | """ -------------------------------------------------------------------------------- /Ethereum/Monitoring/MonitorPools-TokenOwned.py: -------------------------------------------------------------------------------- 1 | #Here we monitor pools of a list of token addresses owned by a wallet 2 | #How useful ? Even in your sleep you can trigger sells or buys of a specific pool based on your strategy 3 | -------------------------------------------------------------------------------- /Ethereum/Trading/AddLp_Events.py: -------------------------------------------------------------------------------- 1 | import web3 2 | import time 3 | import requests 4 | import datetime 5 | 6 | from alchemy import Alchemy, Network 7 | from decimal import Decimal 8 | 9 | network = Network.ETH_MAINNET 10 | 11 | api_key = "BLHi-AZvCt6LjvO8W7nFtloBJFZa393M" 12 | 13 | alchemy_ws_url="wss://eth-mainnet.g.alchemy.com/v2/WoUWFd2SYi7sNbmTTaT_fWMPCOUZ8yDI" 14 | alchemy= Alchemy(api_key,network) 15 | 16 | url = "https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq" 17 | headers = { 18 | "accept": "application/json", 19 | "content-type": "application/json" 20 | } 21 | 22 | printed_values = [] 23 | topic_filter = [ 24 | "0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f", 25 | "0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d" 26 | ] 27 | 28 | 29 | 30 | 31 | def getTimestamp(): 32 | while True: 33 | timeStampData = datetime.datetime.now() 34 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 35 | return currentTimeStamp 36 | try: 37 | while True: 38 | payload = { 39 | "id": 1, 40 | "jsonrpc": "2.0", 41 | "method": "eth_getLogs", 42 | "params": [ 43 | 44 | { 45 | "topics":[topic_filter] 46 | 47 | } 48 | 49 | ] 50 | } 51 | 52 | 53 | response = requests.post(url, json=payload, headers=headers) 54 | response_data = response.json() 55 | 56 | 57 | if 'result' in response_data: 58 | 59 | for res in response_data['result']: 60 | 61 | if res not in printed_values: 62 | try: 63 | 64 | transaction_hash= res['transactionHash'] 65 | txn_receipt = alchemy.core.get_transaction_receipt(transaction_hash) 66 | c = alchemy.core.get_transaction(transaction_hash) 67 | ether_value=alchemy.from_wei(c['value'], 'ether') 68 | 69 | 70 | token_address= txn_receipt['logs'][0]['address'] 71 | 72 | input_signature = alchemy.to_hex(c['input'][:10]) 73 | 74 | 75 | if input_signature.startswith("0xf305d719"): 76 | print(getTimestamp(),"ADD LP") 77 | print("Token Address: ", token_address) 78 | print("Block Number:", res['blockNumber']) 79 | print("Transaction Hash:", res['transactionHash']) 80 | print("Log Index:", res['logIndex']) 81 | print("Topics:", res['topics']) 82 | print("Data:", ether_value) 83 | print("=======================") 84 | elif input_signature.startswith("0xc9567bf9"): 85 | hex_data = res['data'] 86 | second_number = hex_data[66:] 87 | decimal_value = int(second_number, 16) 88 | wei_value = alchemy.to_wei(decimal_value, 'wei') 89 | eth_value = alchemy.from_wei(wei_value, 'ether') 90 | print(getTimestamp(),"OPEN TRADING") 91 | print("Token Address: ", token_address) 92 | print("Block Number:", res['blockNumber']) 93 | print("Transaction Hash:", res['transactionHash']) 94 | print("Log Index:", res['logIndex']) 95 | print("Topics:", res['topics']) 96 | print("Data:", eth_value) 97 | 98 | 99 | 100 | print("=======================") 101 | 102 | elif input_signature.startswith("0x6e3fa5d1"): 103 | print(getTimestamp(),"CREATE ERC20") 104 | print("Token Address: ", token_address) 105 | print("Block Number:", res['blockNumber']) 106 | print("Transaction Hash:", res['transactionHash']) 107 | print("Log Index:", res['logIndex']) 108 | print("Topics:", res['topics']) 109 | print("Data:", ether_value) 110 | 111 | print("=======================") 112 | elif input_signature.startswith("0x4bb278f3"): 113 | hex_data = txn_receipt['logs'][12]['data'] 114 | second_number = hex_data[66:] 115 | decimal_value = int(second_number, 16) 116 | wei_value = alchemy.to_wei(decimal_value, 'wei') 117 | eth_value = alchemy.from_wei(wei_value, 'ether') 118 | print(getTimestamp(), "Finalize") 119 | print("Token Address: ", txn_receipt['logs'][2]['address']) 120 | print("Block Number:", txn_receipt['blockNumber']) 121 | print("Transaction Hash:", txn_receipt['transactionHash']) 122 | 123 | print("Data:", ether_value) 124 | 125 | print("=======================") 126 | else: 127 | 128 | pass 129 | 130 | 131 | except Exception as e: 132 | print(f"Error {e} {alchemy.to_hex(c['input'][:10])} {transaction_hash}") 133 | pass 134 | 135 | printed_values.append(res) 136 | else: 137 | print(f"No result in response_data {response_data}") 138 | except Exception as e: 139 | print(f"Error {e} {alchemy.to_hex(c['input'][:10])} {transaction_hash}") 140 | print(response_data) 141 | 142 | time.sleep(1) 143 | -------------------------------------------------------------------------------- /Ethereum/Trading/BuyTokenErc20-1inch.py: -------------------------------------------------------------------------------- 1 | "Buy using 1inch aggregator for cheap Gas fees " 2 | #Todo -------------------------------------------------------------------------------- /Ethereum/Trading/CopyAnyWallets-Buy_Sells.py: -------------------------------------------------------------------------------- 1 | "Do you have a list of wallets you wish to follow? Copy Trades of any Wallets Buys and Sells " 2 | -------------------------------------------------------------------------------- /Ethereum/Trading/CopyTrade-IrrespectiveOfRouter.py: -------------------------------------------------------------------------------- 1 | "Irrespective of routers used copy trade list of wallets---BUYS AND SELL-----*******" 2 | 3 | 4 | """-----ADD YOUR WALLETS ON LINE 65 -----""" 5 | #TODO Keep a log of buy amount and sell amount in ETH use Data-Analytic techniques to determine most profitable wallet 6 | #TODO Display Sales profit and keep log for data analysis 7 | 8 | import asyncio 9 | import json 10 | import websockets 11 | from web3 import Web3 12 | import requests 13 | from alchemy import Alchemy, Network 14 | import datetime 15 | 16 | 17 | 18 | class style(): # Class of different text colours - default is white 19 | BLACK = '\033[30m' 20 | RED = '\033[31m' 21 | GREEN = '\033[32m' 22 | YELLOW = '\033[33m' 23 | BLUE = '\033[34m' 24 | MAGENTA = '\033[35m' 25 | CYAN = '\033[36m' 26 | WHITE = '\033[37m' 27 | UNDERLINE = '\033[4m' 28 | RESET = '\033[0m' 29 | 30 | 31 | 32 | api_key = "Enter Your Alchemy API" 33 | network = Network.ETH_MAINNET 34 | alchemy_ws_url="wss://eth-mainnet.g.alchemy.com/v2/"+api_key 35 | alchemy= Alchemy(api_key,network) 36 | WETH="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 37 | provider_url = "wss://eth-mainnet.g.alchemy.com/v2/"+api_key 38 | 39 | 40 | 41 | 42 | 43 | 44 | def getTimestamp(): 45 | while True: 46 | timeStampData = datetime.datetime.now() 47 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 48 | return currentTimeStamp 49 | 50 | 51 | def format_hex(original_hex): 52 | hex_without_prefix = original_hex[2:] 53 | 54 | desired_length = 64 55 | 56 | padded_hex = hex_without_prefix.zfill(desired_length) 57 | 58 | final_hex = "0x" + padded_hex 59 | 60 | return final_hex.lower() 61 | 62 | 63 | 64 | queue = asyncio.Queue() 65 | 66 | addresses = [ 67 | # "0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13", 68 | # "0x6b75d8AF000000e20B7a7DDf000Ba900b4009A80", 69 | "0x0f894fc241C8f211C9a6B6Cd01108D1C878845E4", 70 | "0x82E00E14288012C9033cDc6ce2AF0fe7b135EDB3", 71 | "0x66e3e90A4Cf3742c212Cf7c30603cE22F9Fa9c94", 72 | "0x3A52F0Aeef21b3EF1C92F4Be10e6b0738C829Dba", 73 | "0xfcDCAC15c9b2A4227A00BF050d31486fA8652FB8", 74 | "0x7b1184bF2aB8a2F0fB2522C3C8BA726A7ae44c1A", 75 | "0xFa9BeC18fB25E26320518F90eD63B68CB3A11671", 76 | "0xe267727A0c8614800A9CA10C1f135dCa094657c9", 77 | "0x1831322f48dBd8a9323b72d304d6018Cf37dD40E", 78 | "0x876cD87bF451b1764880fDf14Ee49212AE2a4d0f", 79 | "0x45107f30fbf5752c5767b1c70b03c41fc0f4b507", 80 | "0xe6C5e38110d841608DC44096c6673D69EbB681EB", 81 | "0x2e52c65e3Ffc8E87A13263867E042bf59A9ca6BD", 82 | "0x7e8D45eec0613731517E3E62e52755634711DbfC", 83 | "0x9660259A30Bb8ae9Bbcf28241d745b2D581280C1", 84 | "0x516449F7a5c75238326F6f770567D97F5c3F9b11", 85 | "0x0Ea06e9d6Be66e3E1fC67685F4797Ff7fc849667", 86 | "0x2C1433fA8dD5d550b8CEd8dD5C9eC065C124538b", 87 | "0x4D4368A6eB8262BC7C57aBeA1CB7f8Cf18397440", 88 | "0x0203458eE55e240140aE61B5DaFAF5605D1E011D", 89 | "0x0f894fc241C8f211C9a6B6Cd01108D1C878845E4", 90 | "0x89a976060B464bf41d7632E0C459bdA8Ae211D36", 91 | "0xb238e7a094E7f4fE6CCC9af2ef24d7c2184621b0", 92 | "0x609F4Da674397d16BF0422288B5e18b09572e863", 93 | "0x0Db098Ab5217dbd31aBc417dD71a2a8676398A79", 94 | "0xbd579c4f7886bfdDA1b5e3459f2FFB77d3741132", 95 | "0xAC12785Bf910513FD47192A34E23D4533312FB46", 96 | "0xFdfBeA492bcB16deb4b1390eA1A3c41464806cBE", 97 | "0x8A2955394DEC47d14AbaE7F506E7D183C37cF39e", 98 | "0x3fA027c1718AcD863eAaEeC33Ef33fC2377F4c88", 99 | "0x740De8cC9E916049CC493BEcAf186063d3F14ec5", 100 | "0xC7B9433D4E856e34F7519AEF92a9f8e9d9759330", 101 | "0xD1469EdA328e7E9cE63Ad704731C92CD69c475bC", 102 | "0x006f0537ED493f7F84340dc6c417a8381C6B1035", 103 | "0xe076A42bf0eFb5259AaE29e71A1F1abEd3206319", 104 | "0xD2d7cFcD0b4c6DC48a059B0b7Dd5819075C36345", 105 | "0x81021704a53630963159E14f467304218d86bE43", 106 | "0xcDA31b98131B059FE6464963F1F474De6e13eB2b", 107 | "0xb6380198D5D96D9a950714f9eFF9EBF283307180", 108 | "0x7ce9dA83253aFA7677c18815747a1adB271F92cA", 109 | "0x2f6fc19d5Da153F9610EBcaBA3E770b94F29f362", 110 | "0xdC449654E3fB063c0C6932CBF169Fb43fa8e2DD9", 111 | "0xa98D3AE9312192956be5F98DBdD87963ede57687", 112 | "0x3ba9692Bc12562eE15DC88B3F3e55339bd51C5b3", 113 | "0x9Fc5389C66bBfAC23b77bDef85700672928De555", 114 | "0x8d3B36AB2c9eF588d3472c8de0950796Ac8A2443", 115 | "0x42fc2073d081bea5Cea3cce9b05507Fb6d3c2a63", 116 | "0x4F8c93faD9282eA50A8b7e73ed5ef44c8c60BD4d", 117 | "0x3Ca9eC53D076784dcA3d8BB467e7ff78c29C73c4", 118 | "0xc03D38F89b175596859C99eaB231d31e1808358c", 119 | "0xAb819462df33618b383fe402f875260b683F11ac", 120 | "0xEE06aAc8BAc0d7a3A3B4A8554e8bF4E348a92700", 121 | "0x9fc4Baf5C37f23C3875c7bE693682EeAe6d632eD", 122 | "0xF891bF97f1a51D57bD4D2568f94A9f8882162050", 123 | "0x2d007C5C757cEf2fb53c593242331f50b159a72D", 124 | "0x6F7a0B2F75be0b106aAD8b355D6b59D93624DCA4", 125 | "0x7C7A2AD5037701593D76Fad7fb0AB0902366EFA3", 126 | "0x02Cf562FA7503C4743AE6A38737CFbC227466deE", 127 | "0x81d882e41D8d0b594aa7636f1303Cb9A5a4B4b2E", 128 | "0x691598900ceC00B6CBdb32aE821c4f8Fc0C727d4", 129 | "0xebb8c8e5FBdc556Eedab7757f4E26F79Df8E2269", 130 | "0xc03D38F89b175596859C99eaB231d31e1808358c", 131 | "0xbaA56bE07Be167D0eFaFFdEFD08689B77C7524fE", 132 | "0xfDA68F66824Ef2695DF85a5aaAc94097587D2893", 133 | "0x238FdfEF295EEa7296bb6CDb5FB14c9D0DCd8B93", 134 | "0xFCe2ceCbb4EF3439664A3E8Da7Dba922F988A86d", 135 | "0xF36445d62EE61a296bA58F118D6Aa001a98FD51a", 136 | "0x0000DD10e16fD09E41cE5BBb263e70f743dA882E", 137 | "0xaBe4702cA08A9B9732E534Bca4E65b4B2f1f1FC3", 138 | "0xc4E1549543C31A3B86Ce04F071CDe2B64451bcd4", 139 | "0xc21524df508dfB9A5f183fe536dCC57227149b0F", 140 | "0x60C530171A6B38Eb0712C12bDD7B5a164b2EA710", 141 | "0x202b029C2Ff6096c33c72B54c56381C46A8483D6", 142 | "0x07b6692dC260C0C140d7BAA6947166f0420F3Fc9", 143 | "0x7F2827620907dC8b2861839D60916d7Bd575Cdee", 144 | "0x83a46c5b87ABEb4Df5e4d03DDD117824a549a346", 145 | "0x15952737622Dd0b09CC69A5089FC67A0aB7C0903", 146 | "0xd05965c9FD9c3bE171071f382615D39D7A19377f", 147 | "0x8f81DE2419feF279451BfeF2E2ca2ffAa2783dC0", 148 | "0x0015FCe9235e359EFf59890F9ff23352c876235d", 149 | "0x0eD382D36d29f932153107637ADba858f6417413", 150 | "0x1C01EE7741c3152a6B5Aa764747748130127E56A", 151 | "0xAcc71d0F7B18bB2c8e9c53e82C47e10Ab367F902", 152 | "0x7eD06C84F061DBF012D6AEc932762d2937d35f88", 153 | "0x1b38690Bf9C22604cDDad1764eEE6edd94dd3d1E" 154 | 155 | ] 156 | 157 | monitored_wallets_hex = [format_hex(address) for address in addresses] 158 | async def process_transaction(transaction_hash): 159 | try: 160 | receipt = alchemy.core.get_transaction_receipt(transaction_hash) 161 | #print(receipt) 162 | transfer_details = alchemy.core.get_transaction(transaction_hash) 163 | 164 | from_address=transfer_details['from'] 165 | 166 | txn_hash= alchemy.to_hex( transfer_details['hash']) 167 | block_num= transfer_details['blockNumber'] 168 | 169 | print("=======================") 170 | 171 | if receipt['status'] == 1: 172 | eth_value = None 173 | 174 | for logs in receipt['logs']: 175 | if logs['address'] == WETH and alchemy.to_hex(logs['topics'][0]) == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": 176 | hex_value = alchemy.to_hex(logs['data']) 177 | integer_value = int(hex_value, 16) 178 | eth_value = alchemy.from_wei(integer_value, 'ether') 179 | eth_value= '{:.4f}'.format(eth_value) 180 | 181 | if eth_value is not None: 182 | for logs in receipt['logs']: 183 | if logs['address'] != WETH: 184 | if alchemy.to_hex(logs['topics'][ 185 | 0]) == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": 186 | if alchemy.to_hex(logs['topics'][2]) in monitored_wallets_hex: 187 | 188 | print(f" {getTimestamp()} {style.RED}{block_num}{style.RESET} {style.GREEN} TOKEN BOUGHT: {logs['address']} {style.RESET} {style.MAGENTA} WALLET_ADDRESS: {from_address}{style.RESET} For {eth_value}ETH",style.RESET) 189 | print(f"TxnHash: https://etherscan.io/tx/{txn_hash} ") 190 | print(style.CYAN + "====BUYING TRADE SIMULATION======", style.RESET) 191 | 192 | elif alchemy.to_hex(logs['topics'][1]) in monitored_wallets_hex: 193 | print(f" {getTimestamp()} {style.RED}{block_num}{style.RESET} {style.YELLOW}TOKEN SOLD: {logs['address']} {style.RESET} {style.MAGENTA} WALLET_ADDRESS: {from_address}{style.RESET} For {eth_value} ETH", style.RESET) 194 | print(f"TxnHash: https://etherscan.io/tx/{txn_hash} ") 195 | print(style.MAGENTA+"====SELLING TRADE SALE SIMULATION=====",style.RESET) 196 | elif logs['address'] != WETH: 197 | if alchemy.to_hex( 198 | logs['topics'][0]) == "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925": 199 | if alchemy.to_hex(logs['topics'][1]) in monitored_wallets_hex: 200 | print(f"{getTimestamp()} {style.RED}{block_num}{style.RESET}{style.MAGENTA} TOKEN APPROVED: {logs['address']}{style.RESET}{style.MAGENTA} WALLET_ADDRESS {from_address}{style.RESET} ",style.RESET) 201 | print(f"TxnHash: https://etherscan.io/tx/{txn_hash}") 202 | print(style.MAGENTA+"====APPROVED TRANSACTION=====",style.RESET) 203 | queue.task_done() 204 | 205 | 206 | 207 | 208 | except Exception as e: 209 | queue.task_done() 210 | 211 | 212 | 213 | 214 | async def subscribe_to_pending_transactions(): 215 | print("Connecting to WebSocket...") 216 | async with websockets.connect(alchemy_ws_url) as websocket: 217 | print("WebSocket connection established.") 218 | ws_url = alchemy_ws_url 219 | subscription_data = { 220 | "jsonrpc": "2.0", 221 | "method": "eth_subscribe", 222 | "params": ["alchemy_minedTransactions", 223 | {"addresses": [{"from": address} for address in addresses], "includeRemoved": False, 224 | "hashesOnly": True}], 225 | "id": 1 226 | } 227 | 228 | async with websockets.connect(ws_url) as websocket: 229 | await websocket.send(json.dumps(subscription_data)) 230 | while True: 231 | response = await websocket.recv() 232 | response_data = json.loads(response) 233 | if "params" in response_data and "result" in response_data["params"]: 234 | transaction_hash = response_data["params"]["result"]['transaction']['hash'] 235 | queue.put_nowait(transaction_hash) 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | async def process_queue(): 244 | print(style.GREEN+"=====Monitoring Targets Wallets To Copy Transaction======",style.RESET) 245 | while True: 246 | if queue.qsize() <= 3: # Check if there are more than 3 transactions in the queue 247 | wait_time =3 # Wait for 3 seconds 248 | else: 249 | wait_time = 1 # Default wait time for less than or equal to 3 transactions 250 | 251 | transaction_hash = await queue.get() 252 | print(getTimestamp(),transaction_hash) 253 | await asyncio.sleep(wait_time) # Wait for the determined wait_time 254 | await process_transaction(transaction_hash) 255 | 256 | if __name__ == "__main__": 257 | asyncio.gather(subscribe_to_pending_transactions(), process_queue()) 258 | asyncio.get_event_loop().run_forever() 259 | 260 | 261 | -------------------------------------------------------------------------------- /Ethereum/Trading/CopyWalletTrade.py: -------------------------------------------------------------------------------- 1 | # Test on testnet 2 | 3 | import asyncio 4 | from web3 import Web3 5 | import json 6 | import requests 7 | 8 | class style(): # Class of different text colours - default is white 9 | BLACK = '\033[30m' 10 | RED = '\033[31m' 11 | GREEN = '\033[32m' 12 | YELLOW = '\033[33m' 13 | BLUE = '\033[34m' 14 | MAGENTA = '\033[35m' 15 | CYAN = '\033[36m' 16 | WHITE = '\033[37m' 17 | UNDERLINE = '\033[4m' 18 | RESET = '\033[0m' 19 | 20 | 21 | """ 22 | Scenario Explanation 23 | I want to copy a wallet trades this wallet can interact with different router's depending on the 24 | Dex Exchange used Assuming trades are done via a dex and not via a smart contract 25 | 26 | I scan the memepool for transaction involving that wallet 27 | If trade traced in the memepool is a Buy based on the swap function used 28 | I will proceed to make a buy too 29 | 30 | 31 | """ 32 | 33 | #Goerli Testnet RPC 34 | #w3 = Web3(Web3.HTTPProvider("https://eth-goerli.g.alchemy.com/v2/demo")) 35 | w3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 36 | 37 | 38 | #TODO ADD -Aggregation Router 0x1111111254EEB25477B68fb85Ed929f73A960582 39 | 40 | #This list is to check for all interaction of target wallets with any of these routers 41 | uniswap_router_addresses = [ 42 | '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', #Uniswap-V2 Router 43 | '0xE592427A0AEce92De3Edee1F18E0157C05861564', #Uniswap-V3 Router 44 | '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45', #Uniswap-V3 02 Router 45 | '0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B', #OldUniversal-Router 46 | '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD', #Universal-Router 47 | 48 | ] 49 | 50 | if w3.is_connected(): 51 | #print(style.GREEN+"Connected To Goerli Testnet") 52 | print(style.GREEN + "Connected To Mainnet Testnet") 53 | 54 | # print(w3.eth.get_block('latest')) 55 | 56 | check_Buy_functions = {"swapETHForExactTokens": True, "swapExactETHForTokens": True, 57 | "swapExactETHForTokensSupportingFeeOnTransferTokens": True, 58 | 'multicall': True, 'execute': True} 59 | 60 | #Here is the wallet Address I wish to copy 61 | Target_WalletAddress= "0xb6007a21D1c890742bd9a3A4E2C0CA8Df646b0Be" 62 | 63 | 64 | 65 | count= 0 66 | async def handle_new_block(block): 67 | global count 68 | for tx_hash in block['transactions']: 69 | try: 70 | tx = w3.eth.get_transaction(tx_hash) 71 | 72 | 73 | for router_address in uniswap_router_addresses: 74 | 75 | if tx['from'] == Target_WalletAddress and tx['to'] == router_address: 76 | hash= tx['hash'] 77 | tx_hash = w3.to_hex(hash) 78 | # function_name = decode_input_data(tx['input'], tx['to']) 79 | # if function_name is not None: 80 | # count += 1 81 | 82 | 83 | 84 | count+=1 85 | print(count,style.YELLOW + "Tx_Hash: ", 86 | "https://etherscan.io/tx/"+w3.to_hex(hash)) 87 | 88 | # print(style.GREEN+f"{function_name}") 89 | print(style.RED+"------------------") 90 | #break 91 | else: 92 | 93 | continue 94 | 95 | except Exception as e: 96 | print("An error occurred while processing a transaction:", e,w3.to_hex(tx_hash)) 97 | 98 | async def track_new_blocks(): 99 | current_block_number = w3.eth.block_number 100 | 101 | 102 | while True: 103 | latest_block = w3.eth.get_block('latest') 104 | latest_block_number = latest_block['number'] 105 | 106 | if latest_block_number > current_block_number: 107 | for block_number in range(current_block_number + 1, latest_block_number + 1): 108 | block = w3.eth.get_block(block_number) 109 | await handle_new_block(block) 110 | 111 | current_block_number = latest_block_number 112 | 113 | # Delay between checking for new blocks 114 | await asyncio.sleep(5) 115 | 116 | # Run the event loop 117 | async def main(): 118 | await track_new_blocks() 119 | 120 | if __name__ == '__main__': 121 | loop = asyncio.get_event_loop() 122 | loop.run_until_complete(main()) -------------------------------------------------------------------------------- /Ethereum/Trading/GaslessApprove.py: -------------------------------------------------------------------------------- 1 | "Gasless approve for faster selling Txn Via Uniswap V2" 2 | -------------------------------------------------------------------------------- /Ethereum/Trading/MonitorPriceOfBoughtToken.py: -------------------------------------------------------------------------------- 1 | ""Monitor Price of bot token and automatically trigger sale"" 2 | -------------------------------------------------------------------------------- /Ethereum/Trading/MonitorPriceandSell.py: -------------------------------------------------------------------------------- 1 | #Monitor Price of a token and gain on the price volatility 2 | -------------------------------------------------------------------------------- /Ethereum/Trading/Monitor_TokenLiquidityTxn.py: -------------------------------------------------------------------------------- 1 | "Monitor transactions involving Removing liquidity and sell before it occurs" -------------------------------------------------------------------------------- /Ethereum/Trading/SnipeOnSameBlock.py: -------------------------------------------------------------------------------- 1 | #Todo 2 | #Ensure your first buy occurs on the same block be it for copytrading or Snipping 3 | -------------------------------------------------------------------------------- /Ethereum/Trading/Subscribe.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import json 3 | from web3 import Web3 4 | from websockets import connect 5 | 6 | """ 7 | Subscribes to pending transactions 8 | https://community.infura.io/t/web3-py-how-to-subscribe-to-pending-ethereum-transactions-in-python/5409 9 | """ 10 | 11 | infura_ws_url="wss://mainnet.infura.io/ws/v3/d617b8c04ea349faa0ccb45aa2b8ad72" 12 | infura_http_url = 'https://mainnet.infura.io/v3/d617b8c04ea349faa0ccb45aa2b8ad72' 13 | web3 = Web3(Web3.HTTPProvider(infura_http_url)) 14 | 15 | # Used if you want to monitor ETH transactions to a specific address 16 | account = 'Enter Address' 17 | 18 | async def get_event(): 19 | async with connect(infura_ws_url) as ws: 20 | await ws.send('{"jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}') 21 | subscription_response = await ws.recv() 22 | print(subscription_response) 23 | 24 | while True: 25 | try: 26 | message = await asyncio.wait_for(ws.recv(), timeout=15) 27 | response = json.loads(message) 28 | txHash = response['params']['result'] 29 | print(txHash) 30 | # Uncomment lines below if you want to monitor transactions to 31 | # a specific address 32 | # tx = web3.eth.get_transaction(txHash) 33 | # if tx.to == account: 34 | # print("Pending transaction found with the following details:") 35 | # print({ 36 | # "hash": txHash, 37 | # "from": tx["from"], 38 | # "value": web3.from_wei(tx["value"], 'ether') 39 | # }) 40 | pass 41 | except: 42 | pass 43 | 44 | if __name__ == "__main__": 45 | loop = asyncio.get_event_loop() 46 | while True: 47 | loop.run_until_complete(get_event()) -------------------------------------------------------------------------------- /Ethereum/Trading/TrackLockEvents.py: -------------------------------------------------------------------------------- 1 | 2 | #Todo 3 | # How to track lock events of Popular locked Contracts, TrustSwap Security, Pinky, UNICRYPT Security 4 | # If lock > 100Year Buy Token 5 | # Write function to find contract address from LP -Addess 6 | # Inspired by Test Token -------------------------------------------------------------------------------- /Ethereum/Wallet/BuyWithMultipleWallets.py: -------------------------------------------------------------------------------- 1 | #Todo -------------------------------------------------------------------------------- /Ethereum/Wallet/Hd-wallet.py: -------------------------------------------------------------------------------- 1 | "Generate Wallet from Mnemonic" 2 | 3 | from web3 import Web3 4 | from mnemonic import Mnemonic 5 | from web3 import Web3 6 | import secrets 7 | from eth_account import Account 8 | 9 | 10 | w3 = Web3(Web3.HTTPProvider("Enter Infura Node")) 11 | 12 | mnemo = Mnemonic("english") 13 | words = mnemo.generate(strength=256) 14 | 15 | extra_security= secrets.token_hex(32) 16 | 17 | w3.eth.account.enable_unaudited_hdwallet_features() 18 | #Generated Acct from Mnemonic 19 | acct = Account.from_mnemonic(words,passphrase=extra_security) 20 | acct_privatekeys =w3.toHex(acct.privateKey) 21 | accout = w3.eth.account.privateKeyToAccount(acct_privatekeys) 22 | 23 | account_publickey = accout.address 24 | account_privatekey= accout.privateKey 25 | 26 | print("MNEMONIC PHRASE--[KEEP PRIVATE]",words) 27 | print('Public Key', account_publickey) 28 | print("Private_Key---[KEEP PRIVATE]",w3.toHex(account_privatekey)) -------------------------------------------------------------------------------- /Ethereum/Wallet/MultisignatureWallet.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/Ethereum/Wallet/MultisignatureWallet.py -------------------------------------------------------------------------------- /Ethereum/Wallet/create-multiple-ETHaddress.py: -------------------------------------------------------------------------------- 1 | 2 | from web3 import Web3 3 | import secrets 4 | 5 | # Connect to the Ethereum blockchain using the Infura node 6 | 7 | web3 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/lTlatSTYDZmCv6wVLRIDff7S3kZhL2dq")) 8 | 9 | # Define the number of addresses to generate 10 | num_addresses = 10 11 | 12 | # Generate the addresses and private keys 13 | for i in range(num_addresses): 14 | extra_security = secrets.token_hex(32) 15 | # Generate a new Ethereum address and private key 16 | address = web3.eth.account.create(extra_security) 17 | 18 | # Print the address and private key 19 | print(f"Address: {address.address}") 20 | print(f"Private key: {address._private_key.hex()}") -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Henry Tirla 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Learning Resources/myLearningResources.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | #Books I found Useful On my starter Journey 4 | 5 | ##Trading Books 6 | How to DeFi: A Practical Guide to Decentralized Finance (DeFi) by CoinGecko 7 | 8 | Cryptocurrency - A Trader's Handbook: A Complete Guide On How To Trade Bitcoin And Altcoins by Marvin Neuefeind 9 | 10 | 11 | ##Blockchain Books/ Programming Books 12 | 13 | Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos 14 | 15 | Mastering Ethereum: Building Smart Contracts and DApps by Andreas M. Antonopoulos 16 | 17 | 18 | 19 | ....... -------------------------------------------------------------------------------- /Notes/Todo.txt: -------------------------------------------------------------------------------- 1 | Write articles on how to use these script and get the best out of it 2 | henrytirla.medium.com add comment of article on each script 3 | 4 | -Number of lines of code ? A--T R<---T 5 | - Diff Checker--Check against scam contracts 6 | - How many wallets bought on the block liquidity was added and how much percentage of the token do they hold? 7 | - Was a whitelist present to prevent external wallets from buying on a specific time ie during the first minutes of the life of a token. 8 | - Use Subgraphs to get Live onchain data -Track Traction Filter Scams and Buy 9 | Make youtube Videos explaining scripts and how they can be relevant. 10 | 11 | 12 | # Host Script on GCP - Automate Trading Process - Write article 13 | 14 | #Create UI for memepool script and after LP 15 | 16 | Make UI of copy trade scripts BNB and Ethereum Network 17 | 18 | Evaluate tokens while scanning memepool - Categorize tokens in categories 19 | 20 | Build API for erc20 tokens checking for honeypots 21 | 22 | Build tool able to read the logic of a smartcontract and detect contract base scams that pass all technical properties.Eg Token Approval Scam 23 | 24 | Script to evaluate the profitability of a wallet 25 | 26 | -Make a concise list of scams and write code to counter it at least to a certain degree. Test and measure against time how good these scripts perform 27 | 28 | -binary buying criteria 29 | 30 | - Add in evaluaton metric + Number of buys occuring in the same block that liquidity was added ie how many unique wallets bought and how much percentage of the token 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Hi 👋, I'm a Blockchain Engineer 👈🏻

2 | 3 | # Decentralized-Exchange-Trading-Scripts 4 | 5 | Here, you'll find a collection of useful scripts designed to automate trading on various decentralized exchanges (DEX). These tools have been meticulously crafted from the ground up, with a focus on building a robust suite of degen-tools. 6 | 7 | ## How Can These Scripts Help You? 8 | 9 | If you're looking to set up your own degen toolbox for trading on DEX platforms, you've come to the right place. My scripts can simplify the process and enhance your trading experience. 10 | 11 | Are you a crypto enthusiast with unique degen trading ideas? Feel free to connect with me to discuss how these scripts can be tailored to your specific needs. 12 | 13 | 14 | 15 | ## Your Feedback Matters 16 | 17 | We value your feedback! If you're using these scripts, please share your thoughts and suggestions. Your input will play a crucial role in shaping the future development of these tools. I am also planning to create a user-friendly Graphic User Interface (GUI) based on your feedback. 18 | 19 | ## Video Series Coming Soon 20 | Exciting news! I have a video series in the works to provide in-depth guidance on using these scripts effectively. To stay updated, make sure to subscribe to my [YouTube Channel](https://www.youtube.com/@henrytirla) 21 | 22 | 23 | ## Services 24 | I build crypto bots and on-chain analytics tools that will give you an edge on the market, contact me let's work on your degen toolbox and bring your ideas to life. 25 | The more complex and intricate the idea, the better. I love a good challenge! 26 | ### Mentorship 27 | 28 | Have me as a mentor , where I offer my knowledgeable experience and strategies in trading cryptocurrencies. Whether you're a beginner looking to understand the basics or an 29 | experienced enthusiast aiming to enhance your skills, I'm here to help you on your crypto journey. Contact for more information. 30 | 31 | 32 | 33 | ## Contact Information 34 | 35 | - Email: bitbanana717@gmail.com 36 | - Telegram: [Let's Chat](https://t.me/bitfancy) 37 | 38 | ## Support My Work 39 | If these scripts have helped you, please consider supporting my work. Your support will help me continue to develop these tools and create more useful resources for the crypto community. 40 | 41 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/BananGunRouter_Buys_Sells.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import json 3 | import websockets 4 | from alchemy import Alchemy, Network 5 | import datetime 6 | import requests 7 | 8 | alchemy_ws_url = "wss://eth-mainnet.g.alchemy.com/v2/BLHi-AZvCt6LjvO8W7nFtloBJFZa393M" 9 | api_key = "BLHi-AZvCt6LjvO8W7nFtloBJFZa393M" 10 | network = Network.ETH_MAINNET 11 | alchemy = Alchemy(api_key, network) 12 | WETH="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 13 | 14 | queue = [] 15 | 16 | class style(): # Class of different text colours - default is white 17 | BLACK = '\033[30m' 18 | RED = '\033[31m' 19 | GREEN = '\033[32m' 20 | YELLOW = '\033[33m' 21 | BLUE = '\033[34m' 22 | MAGENTA = '\033[35m' 23 | CYAN = '\033[36m' 24 | WHITE = '\033[37m' 25 | UNDERLINE = '\033[4m' 26 | RESET = '\033[0m' 27 | 28 | def getTimestamp(): 29 | while True: 30 | timeStampData = datetime.datetime.now() 31 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 32 | return currentTimeStamp 33 | def get_creation_timestamp(contract_address): 34 | from datetime import datetime 35 | url = f'https://api.etherscan.io/api?module=account&action=txlist&address={contract_address}&startblock=0&endblock=99999999&page=1&offset=3&sort=asc&apikey=QSD4D9KG1NYTX3Y6CPAR62G9FBW16UZ81Z' 36 | response = requests.get(url) 37 | data = response.json() 38 | 39 | if data['status'] == '1': 40 | for tx in data['result']: 41 | if tx['to'] == contract_address.lower(): 42 | timestamp = int(tx['timeStamp']) 43 | formatted_time = datetime.utcfromtimestamp(timestamp).strftime("%d-%m-%Y %H:%M:%S") 44 | return formatted_time 45 | else: 46 | raise Exception('Error while fetching transactions: ' + data['message']) 47 | def calculate_time_difference(creation_time_str): 48 | from datetime import datetime, timedelta 49 | 50 | creation_time = datetime.strptime(creation_time_str, "%d-%m-%Y %H:%M:%S") 51 | current_time = datetime.utcnow() 52 | time_difference = current_time - creation_time 53 | 54 | # Extract days, hours, and minutes from the time difference 55 | days = time_difference.days 56 | hours, remainder = divmod(time_difference.seconds, 3600) 57 | minutes, _ = divmod(remainder, 60) 58 | 59 | return f"{days} days {hours} hours {minutes} minutes ago" 60 | 61 | def getTotalBuys(to_address, contract_address): 62 | category = ["erc20"] 63 | with_metadata = False 64 | from_block = "0x0" 65 | to_block = "latest" 66 | from_address = None 67 | result = alchemy.core.get_asset_transfers(category,with_metadata,from_block,to_block,from_address,to_address,[contract_address]) 68 | length= len(result['transfers']) 69 | token_name= result['transfers'][0].asset 70 | return length, token_name 71 | def get_Days(creation_time_str): 72 | from datetime import datetime, timedelta 73 | 74 | creation_time = datetime.strptime(creation_time_str, "%d-%m-%Y %H:%M:%S") 75 | current_time = datetime.utcnow() 76 | time_difference = current_time - creation_time 77 | 78 | # Extract days, hours, and minutes from the time difference 79 | days = time_difference.days 80 | hours, remainder = divmod(time_difference.seconds, 3600) 81 | minutes, _ = divmod(remainder, 60) 82 | 83 | return days 84 | 85 | tokenlogs={} 86 | 87 | async def process_transaction(transaction_hash): 88 | #await asyncio.sleep(5) # Simulate some processing time 89 | #print(f"{getTimestamp()} Processing transaction: {transaction_hash}") 90 | receipt = alchemy.core.get_transaction_receipt(transaction_hash) 91 | # WalletAddress = receipt['from'] 92 | # tokenBought = receipt['logs'][2]['address'] 93 | # check_log = tokenlogs.get(tokenBought, False) 94 | 95 | if receipt['status'] == 1: 96 | 97 | if receipt['logs'][0]['address'] == WETH: 98 | WalletAddress = receipt['from'] 99 | tokenBought = receipt['logs'][2]['address'] 100 | check_log = tokenlogs.get(tokenBought, False) 101 | if not check_log: 102 | try: 103 | numberOfBuys, tokenName = getTotalBuys(WalletAddress, tokenBought) 104 | creation_time = get_creation_timestamp(tokenBought) 105 | time_difference_str = calculate_time_difference(creation_time) 106 | num_days= get_Days(creation_time) 107 | #print(numberOfBuys, tokenName) 108 | if numberOfBuys ==1 and num_days < 1: 109 | print(style.GREEN + f" Router {receipt['to']} Buy Detected from {WalletAddress}:Token Name: {tokenName} tokenBought {tokenBought} {style.RED}Token Creation Time: {time_difference_str} TXN HASh---https://etherscan.io/tx/{transaction_hash} ",style.RESET) 110 | tokenlogs[tokenBought]= True 111 | print("-----------------------") 112 | except Exception as e: 113 | #print("Error",e,transaction_hash) 114 | pass 115 | 116 | else: 117 | pass 118 | # print(style.MAGENTA + f"This is a sale {WalletAddress}: # of tokenSold {tokenBought} ", 119 | # style.RESET) 120 | # print("------------------------") 121 | 122 | 123 | #0x58dF81bAbDF15276E761808E872a3838CbeCbcf9 Banana Gun router 124 | 125 | async def subscribe_to_pending_transactions(): 126 | async with websockets.connect(alchemy_ws_url) as websocket: 127 | subscription_payload = { 128 | "jsonrpc": "2.0", 129 | "method": "eth_subscribe", 130 | "params": ["alchemy_minedTransactions", {"addresses": [{"to": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"}], "includeRemoved": False, "hashesOnly": True}], 131 | "id": 1 132 | } 133 | 134 | await websocket.send(json.dumps(subscription_payload)) 135 | 136 | while True: 137 | response = await websocket.recv() 138 | response_data = json.loads(response) 139 | #print(response_data) 140 | if "params" in response_data and "result" in response_data["params"]: 141 | transaction_hash = response_data["params"]["result"]['transaction']['hash'] 142 | queue.append(transaction_hash) 143 | 144 | async def process_queue(): 145 | print(style.GREEN+"Scanning Transaction.....",style.RESET) 146 | while True: 147 | if queue: 148 | transaction_hash = queue.pop(0) 149 | await process_transaction(transaction_hash) 150 | else: 151 | await asyncio.sleep(1) # Sleep for a while if queue is empty 152 | 153 | async def main(): 154 | subscribe_task = asyncio.create_task(subscribe_to_pending_transactions()) 155 | process_queue_task = asyncio.create_task(process_queue()) 156 | 157 | await asyncio.gather(subscribe_task, process_queue_task) 158 | 159 | if __name__ == "__main__": 160 | asyncio.run(main()) 161 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/CopyTrade_MultipleWallets.py: -------------------------------------------------------------------------------- 1 | "This script will copytrade a wallet list." 2 | 3 | "Irrespective of routers used copy trade list of wallets---BUYS AND SELL-----*******" 4 | 5 | 6 | """-----ADD YOUR WALLETS ON LINE 65 -----""" 7 | 8 | import asyncio 9 | import json 10 | import websockets 11 | from web3 import Web3 12 | import requests 13 | from alchemy import Alchemy, Network 14 | import datetime 15 | 16 | 17 | 18 | class style(): # Class of different text colours - default is white 19 | BLACK = '\033[30m' 20 | RED = '\033[31m' 21 | GREEN = '\033[32m' 22 | YELLOW = '\033[33m' 23 | BLUE = '\033[34m' 24 | MAGENTA = '\033[35m' 25 | CYAN = '\033[36m' 26 | WHITE = '\033[37m' 27 | UNDERLINE = '\033[4m' 28 | RESET = '\033[0m' 29 | 30 | 31 | 32 | api_key = "Enter Your Alchemy API KEY" 33 | network = Network.ETH_MAINNET 34 | alchemy_ws_url="wss://eth-mainnet.g.alchemy.com/v2/"+api_key 35 | alchemy= Alchemy(api_key,network) 36 | WETH="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 37 | provider_url = "wss://eth-mainnet.g.alchemy.com/v2/"+api_key 38 | 39 | 40 | 41 | 42 | 43 | 44 | def getTimestamp(): 45 | while True: 46 | timeStampData = datetime.datetime.now() 47 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 48 | return currentTimeStamp 49 | 50 | 51 | def format_hex(original_hex): 52 | hex_without_prefix = original_hex[2:] 53 | 54 | desired_length = 64 55 | 56 | padded_hex = hex_without_prefix.zfill(desired_length) 57 | 58 | final_hex = "0x" + padded_hex 59 | 60 | return final_hex.lower() 61 | 62 | 63 | 64 | queue = asyncio.Queue() 65 | 66 | # Enter List of Address you wish to Copy Trade as below seperated by commas eg "Address1","Address2","Address3 NB Delete this Two in the list " 67 | addresses = ["0x0f894fc241C8f211C9a6B6Cd01108D1C878845E4", 68 | "0x82E00E14288012C9033cDc6ce2AF0fe7b135EDB3", 69 | "0x66e3e90A4Cf3742c212Cf7c30603cE22F9Fa9c94", 70 | "0x3A52F0Aeef21b3EF1C92F4Be10e6b0738C829Dba", 71 | "0xfcDCAC15c9b2A4227A00BF050d31486fA8652FB8", 72 | "0x7b1184bF2aB8a2F0fB2522C3C8BA726A7ae44c1A", 73 | "0xFa9BeC18fB25E26320518F90eD63B68CB3A11671", 74 | "0xe267727A0c8614800A9CA10C1f135dCa094657c9", 75 | "0x1831322f48dBd8a9323b72d304d6018Cf37dD40E", 76 | "0x876cD87bF451b1764880fDf14Ee49212AE2a4d0f", 77 | "0x45107f30fbf5752c5767b1c70b03c41fc0f4b507", 78 | "0xe6C5e38110d841608DC44096c6673D69EbB681EB", 79 | "0x2e52c65e3Ffc8E87A13263867E042bf59A9ca6BD", 80 | "0x7e8D45eec0613731517E3E62e52755634711DbfC", 81 | "0x9660259A30Bb8ae9Bbcf28241d745b2D581280C1", 82 | "0x516449F7a5c75238326F6f770567D97F5c3F9b11", 83 | "0x0Ea06e9d6Be66e3E1fC67685F4797Ff7fc849667", 84 | "0x2C1433fA8dD5d550b8CEd8dD5C9eC065C124538b", 85 | "0x4D4368A6eB8262BC7C57aBeA1CB7f8Cf18397440", 86 | "0x0203458eE55e240140aE61B5DaFAF5605D1E011D", 87 | "0x0f894fc241C8f211C9a6B6Cd01108D1C878845E4", 88 | "0x89a976060B464bf41d7632E0C459bdA8Ae211D36", 89 | "0xb238e7a094E7f4fE6CCC9af2ef24d7c2184621b0", 90 | "0x609F4Da674397d16BF0422288B5e18b09572e863", 91 | "0x0Db098Ab5217dbd31aBc417dD71a2a8676398A79", 92 | "0xbd579c4f7886bfdDA1b5e3459f2FFB77d3741132", 93 | "0xAC12785Bf910513FD47192A34E23D4533312FB46", 94 | "0xFdfBeA492bcB16deb4b1390eA1A3c41464806cBE", 95 | "0x8A2955394DEC47d14AbaE7F506E7D183C37cF39e", 96 | "0x3fA027c1718AcD863eAaEeC33Ef33fC2377F4c88", 97 | "0x740De8cC9E916049CC493BEcAf186063d3F14ec5", 98 | "0xC7B9433D4E856e34F7519AEF92a9f8e9d9759330", 99 | "0xD1469EdA328e7E9cE63Ad704731C92CD69c475bC", 100 | "0x006f0537ED493f7F84340dc6c417a8381C6B1035", 101 | "0xe076A42bf0eFb5259AaE29e71A1F1abEd3206319", 102 | "0xD2d7cFcD0b4c6DC48a059B0b7Dd5819075C36345", 103 | "0x81021704a53630963159E14f467304218d86bE43", 104 | "0xcDA31b98131B059FE6464963F1F474De6e13eB2b", 105 | "0xb6380198D5D96D9a950714f9eFF9EBF283307180", 106 | "0x7ce9dA83253aFA7677c18815747a1adB271F92cA", 107 | "0x2f6fc19d5Da153F9610EBcaBA3E770b94F29f362", 108 | "0xdC449654E3fB063c0C6932CBF169Fb43fa8e2DD9", 109 | "0xa98D3AE9312192956be5F98DBdD87963ede57687", 110 | "0x3ba9692Bc12562eE15DC88B3F3e55339bd51C5b3", 111 | "0x9Fc5389C66bBfAC23b77bDef85700672928De555", 112 | "0x8d3B36AB2c9eF588d3472c8de0950796Ac8A2443", 113 | "0x42fc2073d081bea5Cea3cce9b05507Fb6d3c2a63", 114 | "0x4F8c93faD9282eA50A8b7e73ed5ef44c8c60BD4d", 115 | "0x3Ca9eC53D076784dcA3d8BB467e7ff78c29C73c4", 116 | "0xc03D38F89b175596859C99eaB231d31e1808358c", 117 | "0xAb819462df33618b383fe402f875260b683F11ac", 118 | "0xEE06aAc8BAc0d7a3A3B4A8554e8bF4E348a92700", 119 | "0x9fc4Baf5C37f23C3875c7bE693682EeAe6d632eD", 120 | "0xF891bF97f1a51D57bD4D2568f94A9f8882162050", 121 | "0x2d007C5C757cEf2fb53c593242331f50b159a72D", 122 | "0x6F7a0B2F75be0b106aAD8b355D6b59D93624DCA4", 123 | "0x7C7A2AD5037701593D76Fad7fb0AB0902366EFA3", 124 | "0x02Cf562FA7503C4743AE6A38737CFbC227466deE", 125 | "0x81d882e41D8d0b594aa7636f1303Cb9A5a4B4b2E", 126 | "0x691598900ceC00B6CBdb32aE821c4f8Fc0C727d4", 127 | "0xebb8c8e5FBdc556Eedab7757f4E26F79Df8E2269", 128 | "0xc03D38F89b175596859C99eaB231d31e1808358c", 129 | "0xbaA56bE07Be167D0eFaFFdEFD08689B77C7524fE"] 130 | 131 | monitored_wallets_hex = [format_hex(address) for address in addresses] 132 | async def process_transaction(transaction_hash): 133 | try: 134 | receipt = alchemy.core.get_transaction_receipt(transaction_hash) 135 | transfer_details = alchemy.core.get_transaction(transaction_hash) 136 | from_address=transfer_details['from'] 137 | eth_value=alchemy.from_wei(transfer_details['value'], 'ether') 138 | txn_hash= alchemy.to_hex( transfer_details['hash']) 139 | block_num= transfer_details['blockNumber'] 140 | 141 | print("=======================") 142 | 143 | if receipt['status'] == 1: 144 | for logs in receipt['logs']: 145 | if logs['address'] != WETH: 146 | if alchemy.to_hex(logs['topics'][0]) == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": 147 | if alchemy.to_hex(logs['topics'][2]) in monitored_wallets_hex: 148 | print(f" {getTimestamp()} {block_num} {style.GREEN} TOKEN BOUGHT {logs['address']} {style.RESET} {style.MAGENTA} {from_address} {style.RESET} for {eth_value} ETH TxnHash: https://etherscan.io/tx/{txn_hash}", style.RESET) 149 | print(style.CYAN+"====COPY TRADING BUY TRADE SIMULATION======",style.RESET) 150 | 151 | elif alchemy.to_hex(logs['topics'][1]) in monitored_wallets_hex: 152 | print(f" {getTimestamp()} {block_num} {style.YELLOW}TOKEN SOLD {logs['address']} {style.RESET} {style.MAGENTA} {from_address} {style.RESET} TxnHash: https://etherscan.io/tx/{txn_hash} ", style.RESET) 153 | print(style.MAGENTA+"====COPY TRADING TRADE SALE SIMULATION=====",style.RESET) 154 | elif alchemy.to_hex(logs['topics'][0]) == "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925": 155 | if alchemy.to_hex(logs['topics'][1]) in monitored_wallets_hex: 156 | print(f"{getTimestamp()} {style.RED}{block_num}{style.RESET} {style.YELLOW} TOKEN APPROVED {logs['address']} {style.RESET} {style.MAGENTA} {from_address} {style.RESET} TxnHash: https://etherscan.io/tx/{txn_hash}",style.RESET) 157 | 158 | 159 | queue.task_done() 160 | 161 | 162 | 163 | 164 | except Exception as e: 165 | queue.task_done() 166 | 167 | 168 | 169 | 170 | async def subscribe_to_pending_transactions(): 171 | print("Connecting to WebSocket...") 172 | async with websockets.connect(alchemy_ws_url) as websocket: 173 | print("WebSocket connection established.") 174 | ws_url = alchemy_ws_url 175 | subscription_data = { 176 | "jsonrpc": "2.0", 177 | "method": "eth_subscribe", 178 | "params": ["alchemy_minedTransactions", 179 | {"addresses": [{"from": address} for address in addresses], "includeRemoved": False, 180 | "hashesOnly": True}], 181 | "id": 1 182 | } 183 | 184 | async with websockets.connect(ws_url) as websocket: 185 | await websocket.send(json.dumps(subscription_data)) 186 | while True: 187 | response = await websocket.recv() 188 | response_data = json.loads(response) 189 | if "params" in response_data and "result" in response_data["params"]: 190 | transaction_hash = response_data["params"]["result"]['transaction']['hash'] 191 | queue.put_nowait(transaction_hash) 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | async def process_queue(): 200 | print(style.GREEN+"Scanning Transaction.....",style.RESET) 201 | while True: 202 | if queue.qsize() <= 3: 203 | wait_time =3 204 | else: 205 | wait_time = 1 206 | 207 | transaction_hash = await queue.get() 208 | print(getTimestamp(),transaction_hash) 209 | await asyncio.sleep(wait_time) 210 | await process_transaction(transaction_hash) 211 | 212 | if __name__ == "__main__": 213 | asyncio.gather(subscribe_to_pending_transactions(), process_queue()) 214 | asyncio.get_event_loop().run_forever() 215 | 216 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/GetNumberOfBuys.py: -------------------------------------------------------------------------------- 1 | """Get number of times a wallet bought a token """ 2 | 3 | 4 | 5 | from alchemy import Alchemy, Network 6 | 7 | ALCHEMY_API_KEY = "Enter your API KEY" 8 | network = Network.ETH_MAINNET 9 | 10 | contract_ADDRESS = ["Enter Contract Address"] 11 | 12 | wallet_Address="Enter your wallet Address" 13 | alchemy = Alchemy(ALCHEMY_API_KEY, network) 14 | 15 | 16 | def main(): 17 | alchemy = Alchemy(ALCHEMY_API_KEY, network) 18 | 19 | transfers = alchemy.core.get_asset_transfers(category=["erc20"],contract_addresses=contract_ADDRESS,to_address=wallet_Address) 20 | print(transfers) 21 | 22 | 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/MonitorWallet_MinedTransactions.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import json 3 | import websockets 4 | from alchemy import Alchemy, Network 5 | import datetime 6 | 7 | alchemy_ws_url = "wss://eth-mainnet.g.alchemy.com/v2/BLHi-AZvCt6LjvO8W7nFtloBJFZa393M" 8 | api_key = "Enter your Alchemy API" 9 | network = Network.ETH_GOERLI 10 | alchemy = Alchemy(api_key, network) 11 | 12 | queue = [] 13 | 14 | def getTimestamp(): 15 | while True: 16 | timeStampData = datetime.datetime.now() 17 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 18 | return currentTimeStamp 19 | 20 | 21 | async def process_transaction(transaction_hash): 22 | await asyncio.sleep(5) # Simulate some processing time 23 | print(f"{getTimestamp()} Processing transaction: {transaction_hash}") 24 | 25 | async def subscribe_to_pending_transactions(): 26 | async with websockets.connect(alchemy_ws_url) as websocket: 27 | subscription_payload = { 28 | "jsonrpc": "2.0", 29 | "method": "eth_subscribe", 30 | "params": ["alchemy_minedTransactions", {"addresses": [{"from": "0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13"}], "includeRemoved": False, "hashesOnly": True}], 31 | "id": 1 32 | } 33 | 34 | await websocket.send(json.dumps(subscription_payload)) 35 | 36 | while True: 37 | response = await websocket.recv() 38 | response_data = json.loads(response) 39 | #print(response_data) 40 | if "params" in response_data and "result" in response_data["params"]: 41 | transaction_hash = response_data["params"]["result"]['transaction']['hash'] 42 | queue.append(transaction_hash) 43 | 44 | async def process_queue(): 45 | while True: 46 | if queue: 47 | transaction_hash = queue.pop(0) 48 | await process_transaction(transaction_hash) 49 | else: 50 | await asyncio.sleep(1) # Sleep for a while if queue is empty 51 | 52 | async def main(): 53 | subscribe_task = asyncio.create_task(subscribe_to_pending_transactions()) 54 | process_queue_task = asyncio.create_task(process_queue()) 55 | 56 | await asyncio.gather(subscribe_task, process_queue_task) 57 | 58 | if __name__ == "__main__": 59 | asyncio.run(main()) 60 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/MonitorWallet_PendingTransaction.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import json 3 | import websockets 4 | from web3 import Web3 5 | import requests 6 | from websockets import connect 7 | 8 | 9 | from alchemy import Alchemy, Network 10 | """ 11 | for reference Subscription Type Description 12 | alchemy_minedTransactions Emits full transaction objects or hashes that are mined on the network based on provided filters and block tags. 13 | alchemy_pendingTransactions Emits full transaction objects or hashes that are sent to the network, marked as "pending", based on provided filters. 14 | newPendingTransactions Emits transaction hashes that are sent to the network and marked as "pending". 15 | newHeads Emits new blocks that are added to the blockchain. 16 | logs Emits logs attached to a new block that match certain topic filters. 17 | 18 | """ 19 | 20 | api_key = "Enter your Alcheny API KEY HERE" 21 | network = Network.ETH_MAINNET 22 | 23 | 24 | url = f"https://eth-mainnet.g.alchemy.com/v2/{api_key}" 25 | alchemy_ws_url="wss://eth-mainnet.g.alchemy.com/v2/WoUWFd2SYi7sNbmTTaT_fWMPCOUZ8yDI" 26 | alchemy= Alchemy(api_key,network) 27 | async def subscribe_to_pending_transactions(): 28 | ws_url = alchemy_ws_url 29 | subscription_data = { 30 | "jsonrpc": "2.0", 31 | "id": 1, 32 | "method": "eth_subscribe", 33 | "params": ["alchemy_pendingTransactions", { 34 | "fromAddress":"0xbd2C6a28a156377bD75C363aD8f849c68922b4Dc" #The address you want to monitor be it from or to 35 | # "toAddress": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" 36 | }] 37 | } 38 | 39 | async with websockets.connect(ws_url) as websocket: 40 | await websocket.send(json.dumps(subscription_data)) 41 | 42 | while True: 43 | response = await websocket.recv() 44 | response_data = json.loads(response) 45 | if "params" in response_data and "result" in response_data["params"]: 46 | #transaction_data = response_data["params"]['result']['from'] 47 | transaction_data = response_data["params"] 48 | print(transaction_data) 49 | 50 | 51 | if __name__ == "__main__": 52 | asyncio.get_event_loop().run_until_complete(subscribe_to_pending_transactions()) 53 | 54 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/SMS_Notifications.py: -------------------------------------------------------------------------------- 1 | #Using twillo api get notified of a transaction via SMS 2 | 3 | import json 4 | import asyncio 5 | import websockets 6 | 7 | from twilio.rest import Client 8 | 9 | # Set your Twilio credentials 10 | account_sid = ''# Replace with your Twilio account SID 11 | auth_token = ''# Replace with your Twilio auth token 12 | client = Client(account_sid, auth_token) 13 | 14 | ALCHEMY_KEY = 'BLHi-AZvCt6LjvO8W7nFtloBJFZa393M' 15 | alchemy_ws_url = "wss://eth-mainnet.g.alchemy.com/v2/BLHi-AZvCt6LjvO8W7nFtloBJFZa393M" 16 | 17 | async def main(): 18 | for i in range(3): 19 | try: 20 | async with websockets.connect(alchemy_ws_url) as ws: 21 | print("Connection made") 22 | subscription_payload = { 23 | "jsonrpc": "2.0", 24 | "method": "eth_subscribe", 25 | "params": ["alchemy_filteredNewFullPendingTransactions", {"toAddress": "0x50B8f49f4B2E80e09cE8015C4e7A9c277738Fd3d"}], 26 | "id": 1 27 | } 28 | await ws.send(json.dumps(subscription_payload)) 29 | print("JSON eth_subscribe sent") 30 | 31 | while True: 32 | try: 33 | result = await ws.recv() 34 | result = json.loads(result) 35 | 36 | if "params" in result and "result" in result["params"]: 37 | from_address = result["params"]["result"]["from"] 38 | to_address = result["params"]["result"]["to"] 39 | hash = result["params"]["result"]["hash"] 40 | blockHash = result["params"]["result"]["blockNumber"] 41 | 42 | print("from:", from_address) 43 | print("to:", to_address) 44 | print("hash: ", hash) 45 | print("blockHash: ", blockHash) 46 | 47 | print("Send Twilio SMS for pending transaction!") 48 | message = client.messages.create( 49 | body="\n \n PENDING TX! \n\n From: " + from_address + " \n\n To: " + to_address + "\n\n @tx:" + hash, 50 | from_='+0000000', # Replace with your Twilio number 51 | to='+000000000'# Replace with your phone number 52 | ) 53 | 54 | print(message.sid) 55 | 56 | else: 57 | print("Received unexpected JSON response:", result) 58 | 59 | except Exception as error: 60 | print('JSON Error: ' + repr(error)) 61 | await asyncio.sleep(1) 62 | 63 | except Exception as error: 64 | print('Connection Error: ' + repr(error)) 65 | await asyncio.sleep(3) 66 | 67 | if __name__ == "__main__": 68 | asyncio.run(main()) 69 | -------------------------------------------------------------------------------- /SDK/AlchemyPythonSDK/Send_PrivateTxn: -------------------------------------------------------------------------------- 1 | "Send a private transactions and avoid sandwich Attacks from Mev Bot" 2 | -------------------------------------------------------------------------------- /Smart Contracts/BuyandSell.sol: -------------------------------------------------------------------------------- 1 | //Deploy your own smart contract and buy and sell via it. Interface via A telegram Bot--Premium 2 | -------------------------------------------------------------------------------- /Smart Contracts/ER20HoneypotChecker.sol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/Smart Contracts/ER20HoneypotChecker.sol -------------------------------------------------------------------------------- /Smart Contracts/MEV_Bot.sol: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Smart Contracts/Memepool.sol: -------------------------------------------------------------------------------- 1 | // Scan memepool, evaluate project metrics and buy --Todo -------------------------------------------------------------------------------- /Smart Contracts/Sameblock.sol: -------------------------------------------------------------------------------- 1 | //Buy and sell a token on the same block . 2 | -------------------------------------------------------------------------------- /Smart Contracts/ScanNewlyCreatedPairs.sol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BitFancy/Solana-Trading-Bot/c5bf9b933bc01278b6d292052a744f2ca4969f3b/Smart Contracts/ScanNewlyCreatedPairs.sol -------------------------------------------------------------------------------- /Solana/Listen_tokenBurns.py: -------------------------------------------------------------------------------- 1 | #Listen for token Burns and buy 2 | -------------------------------------------------------------------------------- /Solana/Miscellaneous/Deserialize.py: -------------------------------------------------------------------------------- 1 | #Deseralize account Data 2 | -------------------------------------------------------------------------------- /Solana/Miscellaneous/Deserialize_SPL.py: -------------------------------------------------------------------------------- 1 | #Deserialize SPL Account DATA 2 | 3 | 4 | from borsh_construct import CStruct, U64, Bytes 5 | from solana.rpc.api import Client 6 | from solders.pubkey import Pubkey 7 | from construct import Bytes, Int8ul, Int32ul, Int64ul, Pass, Switch,IfThenElse 8 | PUBLIC_KEY_LAYOUT = Bytes(32) 9 | solana_client=Client("https://api.mainnet-beta.solana.com") 10 | SPL_ACCOUNT_LAYOUT = CStruct( 11 | "mint" / PUBLIC_KEY_LAYOUT, 12 | "owner" / PUBLIC_KEY_LAYOUT, 13 | "amount" / U64, 14 | "delegateOption" / Int32ul, 15 | "delegate" / PUBLIC_KEY_LAYOUT, 16 | "state" / Int8ul, 17 | "isNativeOption" / Int32ul, 18 | "isNative" / U64, 19 | "delegatedAmount" / U64, 20 | "closeAuthorityOption" / Int32ul, 21 | "closeAuthority" / PUBLIC_KEY_LAYOUT 22 | ) 23 | 24 | def transactionType(Account: str): 25 | data = solana_client.get_account_info(Pubkey.from_string(Account)).value.data 26 | parsed_data = SPL_ACCOUNT_LAYOUT.parse(data) 27 | parsed_data.mint=Pubkey.from_bytes(parsed_data.mint) 28 | parsed_data.owner=Pubkey.from_bytes(parsed_data.owner) 29 | parsed_data.delegate=Pubkey.from_bytes(parsed_data.delegate) 30 | parsed_data.closeAuthority=Pubkey.from_bytes(parsed_data.closeAuthority) 31 | 32 | 33 | return parsed_data 34 | 35 | 36 | print(transactionType("UwwaA87kG33YTTQNA3QyVQZFmNiFDioZLZrqNvcGbFr")) 37 | -------------------------------------------------------------------------------- /Solana/Miscellaneous/GetAmmID.py: -------------------------------------------------------------------------------- 1 | #Get AmmId of New created pool without raydium sdk-------DONE_COMPLETE 2 | -------------------------------------------------------------------------------- /Solana/Miscellaneous/GetPool_Info.py: -------------------------------------------------------------------------------- 1 | #Get raydium pool info of any token much faster than downloading a whole 70MB json file. 2 | 3 | 4 | 5 | import base58 6 | from solana.rpc.api import Client 7 | from solana.rpc.types import MemcmpOpts 8 | from solders.pubkey import Pubkey 9 | solana_client = Client("https://solana-mainnet.g.alchemy.com/v2/zWDdevLas9BnD8ZvpXyEXE-7QdkX_Kn6") 10 | address = Pubkey.from_string("5b5aQ8J9iv9Mzvy2Xr79jpQcEtb9v2hpQch4QwUicv5W") 11 | RAYDIUM = Pubkey.from_string("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8") 12 | OPENBOOK = Pubkey.from_string("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX") 13 | from borsh_construct import CStruct, U64, Bytes, U128 14 | from construct import Bytes, Int8ul, Int32ul, Int64ul, Pass, Switch 15 | from base58 import b58decode, b58encode 16 | PUBLIC_KEY_LAYOUT = Bytes(32) 17 | 18 | liquidity_state_layout_v4 = CStruct( 19 | "status" / U64, 20 | "nonce" / U64, 21 | "maxOrder" / U64, 22 | "depth" / U64, 23 | "baseDecimal" / U64, 24 | "quoteDecimal" / U64, 25 | "state" / U64, 26 | "resetFlag" / U64, 27 | "minSize" / U64, 28 | "volMaxCutRatio" / U64, 29 | "amountWaveRatio" / U64, 30 | "baseLotSize" / U64, 31 | "quoteLotSize" / U64, 32 | "minPriceMultiplier" / U64, 33 | "maxPriceMultiplier" / U64, 34 | "systemDecimalValue" / U64, 35 | "minSeparateNumerator" / U64, 36 | "minSeparateDenominator" / U64, 37 | "tradeFeeNumerator" / U64, 38 | "tradeFeeDenominator" / U64, 39 | "pnlNumerator" / U64, 40 | "pnlDenominator" / U64, 41 | "swapFeeNumerator" / U64, 42 | "swapFeeDenominator" / U64, 43 | "baseNeedTakePnl" / U64, 44 | "quoteNeedTakePnl" / U64, 45 | "quoteTotalPnl" / U64, 46 | "baseTotalPnl" / U64, 47 | "poolOpenTime" / U64, 48 | "punishPcAmount" / U64, 49 | "punishCoinAmount" / U64, 50 | "orderbookToInitTime" / U64, 51 | "swapBaseInAmount" / U128, 52 | "swapQuoteOutAmount" / U128, 53 | "swapBase2QuoteFee" / U64, 54 | "swapQuoteInAmount" / U128, 55 | "swapBaseOutAmount" / U128, 56 | "swapQuote2BaseFee" / U64, 57 | "baseVault" / PUBLIC_KEY_LAYOUT, 58 | "quoteVault" / PUBLIC_KEY_LAYOUT, 59 | "baseMint" / PUBLIC_KEY_LAYOUT, 60 | "quoteMint" / PUBLIC_KEY_LAYOUT, 61 | "lpMint" / PUBLIC_KEY_LAYOUT, 62 | "openOrders" / PUBLIC_KEY_LAYOUT, 63 | "marketId" / PUBLIC_KEY_LAYOUT, 64 | "marketProgramId" / PUBLIC_KEY_LAYOUT, 65 | "targetOrders" / PUBLIC_KEY_LAYOUT, 66 | "withdrawQueue" / PUBLIC_KEY_LAYOUT, 67 | "lpVault" / PUBLIC_KEY_LAYOUT, 68 | "owner" / PUBLIC_KEY_LAYOUT, 69 | "lpReserve" / U64, 70 | # Const(b'\x00\x00\x00') # padding 71 | ) 72 | 73 | 74 | bytes= base58.b58decode("SEDNswjQdnSyxhNBET1LvUCJ5wGKRwNBm5vNb88nKCw") 75 | print(bytes) 76 | 77 | def getRaydiumMarkets(tokenMint: Pubkey): 78 | memcmp_filter = MemcmpOpts(offset=(30 * 8) + 64 + 32 + 64 , bytes=tokenMint) 79 | markets = solana_client.get_program_accounts( 80 | RAYDIUM, 81 | commitment="confirmed", 82 | filters=[memcmp_filter] 83 | ) 84 | # return markets 85 | data= markets.value[0].account.data 86 | parsed_data=liquidity_state_layout_v4.parse(data) 87 | parsed_data.baseVault = Pubkey.from_bytes(parsed_data.baseVault) 88 | parsed_data.quoteVault = Pubkey.from_bytes(parsed_data.quoteVault) 89 | parsed_data.baseMint = Pubkey.from_bytes(parsed_data.baseMint) 90 | parsed_data.quoteMint = Pubkey.from_bytes(parsed_data.quoteMint) 91 | parsed_data.lpMint = Pubkey.from_bytes(parsed_data.lpMint) 92 | parsed_data.openOrders = Pubkey.from_bytes(parsed_data.openOrders) 93 | parsed_data.marketId = Pubkey.from_bytes(parsed_data.marketId) 94 | parsed_data.marketProgramId = Pubkey.from_bytes(parsed_data.marketProgramId) 95 | parsed_data.targetOrders = Pubkey.from_bytes(parsed_data.targetOrders) 96 | parsed_data.withdrawQueue = Pubkey.from_bytes(parsed_data.withdrawQueue) 97 | parsed_data.lpVault = Pubkey.from_bytes(parsed_data.lpVault) 98 | parsed_data.owner = Pubkey.from_bytes(parsed_data.owner) 99 | 100 | 101 | return parsed_data 102 | 103 | print(getRaydiumMarkets(bytes)) 104 | print("=====================") 105 | 106 | -------------------------------------------------------------------------------- /Solana/Monitor/Buy_Sells.py: -------------------------------------------------------------------------------- 1 | #Decoded Signature To Display Buy and Sell information crucial for copyTrading 2 | 3 | #Fixed this for all type of transction......PREMIUM 4 | 5 | import asyncio 6 | import datetime 7 | import time 8 | import base58 9 | import httpx 10 | import websockets 11 | import json 12 | from solders.signature import Signature 13 | import requests 14 | from solders.pubkey import Pubkey 15 | from solana.rpc.api import Client, Keypair 16 | from borsh_construct import CStruct, U64 17 | from construct import Bytes, Int8ul, Int32ul, Int64ul, Pass, Switch 18 | PUBLIC_KEY_LAYOUT = Bytes(32) 19 | RAYDIUM_AUTHORITY = Pubkey.from_string("5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1") 20 | LAMPORTS = 1000000000 21 | SPL_ACCOUNT_LAYOUT = CStruct( 22 | "mint" / PUBLIC_KEY_LAYOUT, 23 | "owner" / PUBLIC_KEY_LAYOUT, 24 | "amount" / U64, 25 | "delegateOption" / Int32ul, 26 | "delegate" / PUBLIC_KEY_LAYOUT, 27 | "state" / Int8ul, 28 | "isNativeOption" / Int32ul, 29 | "isNative" / U64, 30 | "delegatedAmount" / U64, 31 | "closeAuthorityOption" / Int32ul, 32 | "closeAuthority" / PUBLIC_KEY_LAYOUT 33 | ) 34 | SPL_MINT_LAYOUT = CStruct( 35 | "mintAuthorityOption"/ Int32ul, 36 | 'mintAuthority'/PUBLIC_KEY_LAYOUT, 37 | 'supply'/U64, 38 | 'decimals'/Int8ul, 39 | 'isInitialized'/Int8ul, 40 | 'freezeAuthorityOption'/Int32ul, 41 | 'freezeAuthority'/PUBLIC_KEY_LAYOUT 42 | ) 43 | #sparx78qzrJU1sC2ZnTdWHa3mjZkd4LgaiFgCMavbbH EbNrhZAMjov2jt8tbKqo9KCnUT7iiAaKTDfQ32GAKvsz 44 | #GpDb1yX3o4Zch82qLF7DzvHECQU92SpQ31zESe5QDcHC EbNrhZAMjov2jt8tbKqo9KCnUT7iiAaKTDfQ32GAKvsz 45 | 46 | class style(): 47 | BLACK = '\033[30m' 48 | RED = '\033[31m' 49 | GREEN = '\033[32m' 50 | YELLOW = '\033[33m' 51 | BLUE = '\033[34m' 52 | MAGENTA = '\033[35m' 53 | CYAN = '\033[36m' 54 | WHITE = '\033[37m' 55 | UNDERLINE = '\033[4m' 56 | RESET = '\033[0m' 57 | #DCAK8tuwzsNowVA6eSojLHhHSDQMyECuSbu7KovyvYbm 58 | wallet_address = "DCAK8tuwzsNowVA6eSojLHhHSDQMyECuSbu7KovyvYbm" # 59 | seen_signatures = set() 60 | WRAPPED_SOL_MINT = "So11111111111111111111111111111111111111112" 61 | Pool_raydium="675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" 62 | raydium_V4="5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1" 63 | solana_client= Client("https://api.mainnet-beta.solana.com") 64 | 65 | 66 | def transactionType(Account: str): 67 | data = solana_client.get_account_info(Pubkey.from_string(Account)).value.data 68 | parsed_data = SPL_ACCOUNT_LAYOUT.parse(data) 69 | mint = Pubkey.from_bytes(parsed_data.mint) 70 | if mint == Pubkey.from_string(WRAPPED_SOL_MINT): 71 | return mint 72 | return mint 73 | def getMintInfo(mint: Pubkey): 74 | data = solana_client.get_account_info(mint).value.data 75 | parsed_data = SPL_MINT_LAYOUT.parse(data) 76 | return parsed_data.decimals 77 | def getTimestamp(): 78 | while True: 79 | timeStampData = datetime.datetime.now() 80 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 81 | return currentTimeStamp 82 | 83 | 84 | 85 | class TransactionProcessor: 86 | def __init__(self): 87 | self.queue = asyncio.Queue() 88 | 89 | async def process_transactions(self): 90 | while True: 91 | await asyncio.sleep(5) 92 | 93 | signature = await self.queue.get() 94 | try: 95 | transaction = solana_client.get_transaction(signature, encoding="jsonParsed", 96 | max_supported_transaction_version=0).value 97 | if transaction is None: 98 | print(f"{getTimestamp()} -Transaction not found: {signature}") 99 | 100 | instruction_list = transaction.transaction.meta.inner_instructions 101 | account_signer = transaction.transaction.transaction.message.account_keys[0].pubkey 102 | if account_signer == Pubkey.from_string(wallet_address): 103 | print(f"{getTimestamp()} -New update received: , https://solscan.io/tx/{signature}") 104 | for ui_inner_instructions in instruction_list: 105 | if ui_inner_instructions.instructions[0].program_id == Pubkey.from_string(Pool_raydium): 106 | first_info = ui_inner_instructions.instructions[1].parsed["info"] 107 | second_info = ui_inner_instructions.instructions[2].parsed["info"] 108 | first_token = transactionType(first_info["source"]) 109 | first_amount = int(first_info['amount']) / 10 ** getMintInfo(first_token) 110 | 111 | if first_token == Pubkey.from_string(WRAPPED_SOL_MINT): 112 | print(f"{style.GREEN}BUY {first_amount} SOL {style.RESET} -FOR {int(second_info['amount']) / 10 ** getMintInfo(transactionType(second_info['destination']))} TokenBought= {transactionType(second_info['destination'])} ") 113 | 114 | if transactionType(second_info["destination"]) == Pubkey.from_string(raydium_V4): 115 | print( 116 | f"Buy {int(first_info['amount']) / LAMPORTS} SOL for {int(second_info['amount']) / 10 ** getMintInfo(transactionType(second_info['destination']))} TokenBought= {transactionType(second_info['destination'])}") 117 | 118 | if transactionType(second_info["destination"]) == Pubkey.from_string(WRAPPED_SOL_MINT): 119 | print( 120 | f"{style.RED}SELL{style.RESET} {first_amount} -{first_token}--FOR {style.GREEN}{int(second_info['amount']) / 10 ** getMintInfo(transactionType(second_info['destination']))} {style.RESET}SOL") 121 | 122 | if ui_inner_instructions.instructions[0].program_id != Pubkey.from_string(Pool_raydium): 123 | if ui_inner_instructions.index == 2 and "mint" not in \ 124 | ui_inner_instructions.instructions[0].parsed["info"]: 125 | info = ui_inner_instructions.instructions[0].parsed["info"] 126 | # print(info) 127 | sell_token = transactionType(info["destination"]) 128 | decimal_sell_token = getMintInfo(sell_token) 129 | amount_sold = int(info['amount']) / 10 ** decimal_sell_token 130 | second_info = ui_inner_instructions.instructions[1].parsed["info"] 131 | sol_tokenAccount = second_info['destination'] 132 | sol_decimal = getMintInfo(transactionType(sol_tokenAccount)) 133 | sol_amount = int(second_info['amount']) / LAMPORTS 134 | print(f"Sell {amount_sold} Token= {sell_token} For {sol_amount} SOL ") 135 | 136 | if ui_inner_instructions.index == 3: 137 | info = ui_inner_instructions.instructions[0].parsed["info"] 138 | second_info = ui_inner_instructions.instructions[1].parsed["info"] 139 | tokenBought = transactionType(second_info["source"]) 140 | decimal_tokenBought = getMintInfo(tokenBought) 141 | 142 | # print(info) 143 | if transactionType(info['source']) == Pubkey.from_string(WRAPPED_SOL_MINT): 144 | 145 | print( 146 | f"Buy {int(info['amount']) / LAMPORTS} SOL for {int(second_info['amount']) / 10 ** decimal_tokenBought} TokenBought= {tokenBought} ") 147 | print("=========================================") 148 | 149 | else: 150 | pass 151 | except Exception as e: 152 | # print(e) 153 | print(f"Failed to process transaction {signature}: {e}") 154 | finally: 155 | self.queue.task_done() 156 | 157 | async def enqueue_transaction(self, signature): 158 | await self.queue.put(signature) 159 | 160 | 161 | async def run(): 162 | processor = TransactionProcessor() 163 | asyncio.create_task(processor.process_transactions()) 164 | 165 | uri = "wss://api.mainnet-beta.solana.com" 166 | async with websockets.connect(uri) as websocket: 167 | # Send subscription request 168 | await websocket.send(json.dumps({ 169 | "jsonrpc": "2.0", 170 | "id": 1, 171 | "method": "logsSubscribe", 172 | "params": [ 173 | {"mentions": [wallet_address]}, 174 | {"commitment": "finalized"} #confirmed , finalized, processed 175 | ] 176 | })) 177 | 178 | # Receive the first response 179 | first_resp = await websocket.recv() 180 | print(first_resp) 181 | response_dict = json.loads(first_resp) 182 | if 'result' in response_dict: 183 | print("Subscription successful. Subscription ID: ", response_dict['result']) 184 | 185 | # Continuously read from the WebSocket 186 | async for response in websocket: 187 | 188 | response_dict = json.loads(response) 189 | 190 | if response_dict['params']['result']['value']['err'] == None: 191 | 192 | signature = response_dict['params']['result']['value']['signature'] 193 | if signature not in seen_signatures: 194 | seen_signatures.add(signature) 195 | 196 | 197 | hash_signature = signature 198 | signature = Signature.from_string(hash_signature) 199 | await processor.enqueue_transaction(signature) 200 | 201 | 202 | 203 | else: 204 | pass 205 | 206 | asyncio.run(run()) 207 | -------------------------------------------------------------------------------- /Solana/Monitor/Concurrent-Monitoring-Accounts.py: -------------------------------------------------------------------------------- 1 | 2 | # This script is used to monitor buys and sells of multiple accounts concurrently on Solana. 3 | import asyncio 4 | import websockets 5 | import json 6 | import datetime 7 | from solders.signature import Signature 8 | from solana.rpc.api import Client 9 | from solders.pubkey import Pubkey 10 | 11 | solana_client = Client("https://api.mainnet-beta.solana.com") 12 | #Max 5 addresses else you will get error. 13 | wallet_addresses = ["Account Address1", "Account Address","Account Address 3","Account Address 4","Account Address 5"] 14 | seen_signatures = set() 15 | def getTimestamp(): 16 | while True: 17 | timeStampData = datetime.datetime.now() 18 | currentTimeStamp = "[" + timeStampData.strftime("%H:%M:%S.%f")[:-3] + "]" 19 | return currentTimeStamp 20 | class style(): 21 | BLACK = '\033[30m' 22 | RED = '\033[31m' 23 | GREEN = '\033[32m' 24 | YELLOW = '\033[33m' 25 | BLUE = '\033[34m' 26 | MAGENTA = '\033[35m' 27 | CYAN = '\033[36m' 28 | WHITE = '\033[37m' 29 | UNDERLINE = '\033[4m' 30 | RESET = '\033[0m' 31 | async def run(wallet_address: str): 32 | count = 0 33 | uri = "wss://api.mainnet-beta.solana.com" 34 | async with websockets.connect(uri) as websocket: 35 | await websocket.send(json.dumps({ 36 | "jsonrpc": "2.0", 37 | "id": 1, 38 | "method": "logsSubscribe", 39 | "params": [ 40 | {"mentions": [wallet_address]}, 41 | {"commitment": "finalized"} 42 | ] 43 | })) 44 | 45 | first_resp = await websocket.recv() 46 | #print(first_resp) 47 | response_dict = json.loads(first_resp) 48 | # if 'result' in response_dict: 49 | # print("Subscription successful. Subscription ID: ", response_dict['result']) 50 | 51 | async for response in websocket: 52 | response_dict = json.loads(response) 53 | if response_dict['params']['result']['value']['err'] == None: 54 | signature = response_dict['params']['result']['value']['signature'] 55 | if signature not in seen_signatures: 56 | seen_signatures.add(signature) 57 | hash = Signature.from_string(signature) 58 | hash_Detail = solana_client.get_transaction(hash, encoding="json", max_supported_transaction_version=0) 59 | try: 60 | for ui in hash_Detail.value.transaction.meta.pre_token_balances: 61 | 62 | if ui.owner == Pubkey.from_string(wallet_address) and ui.mint == Pubkey.from_string("So11111111111111111111111111111111111111112"): 63 | pre_amount = ui.ui_token_amount.amount 64 | if ui.owner == Pubkey.from_string(wallet_address) and ui.mint != Pubkey.from_string("So11111111111111111111111111111111111111112"): 65 | token_address = ui.mint 66 | for ui in hash_Detail.value.transaction.meta.post_token_balances: 67 | if ui.owner == Pubkey.from_string(wallet_address) and ui.mint == Pubkey.from_string("So11111111111111111111111111111111111111112"): 68 | post_amount = ui.ui_token_amount.amount 69 | if ui.owner == Pubkey.from_string(wallet_address) and ui.mint != Pubkey.from_string("So11111111111111111111111111111111111111112"): 70 | token_address = ui.mint 71 | if post_amount > pre_amount: 72 | print("**************") 73 | count += 1 74 | print(f"{count}--{getTimestamp()}Account Address: {wallet_address}, {style.YELLOW}[Token SOLD]:{token_address}{style.RESET} , https://solscan.io/tx/{hash}") 75 | else: 76 | count+=1 77 | 78 | print(f"{count}--{getTimestamp()}Account Address: {wallet_address}, {style.GREEN}[Token BOUGHT]:, {token_address}{style.RESET} , https://solscan.io/tx/{hash}") 79 | except Exception as e: 80 | print('Error Occured',e,wallet_address,hash) 81 | continue 82 | 83 | tasks = [run(addr) for addr in wallet_addresses] 84 | 85 | async def main(): 86 | await asyncio.gather(*tasks) 87 | 88 | asyncio.run(main()) 89 | -------------------------------------------------------------------------------- /Solana/Monitor/DifferentTransactionBuilds.py: -------------------------------------------------------------------------------- 1 | # Different Transactions instruction are built differently this script should monitor this different types of interfaces enabling a diverse and dynamic monitoring environment 2 | -------------------------------------------------------------------------------- /Solana/Monitor/MonitorWalletList.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import websockets 3 | import json 4 | 5 | wallet_address = "GHZuLHwS4w7hqF232H8Qg8k4CAUg7Zvr49VdYw3K6mtc" 6 | seen_signatures = set() 7 | 8 | async def run(): 9 | count = 0 10 | uri = "wss://api.mainnet-beta.solana.com" 11 | async with websockets.connect(uri) as websocket: 12 | # Send subscription request 13 | await websocket.send(json.dumps({ 14 | "jsonrpc": "2.0", 15 | "id": 1, 16 | "method": "logsSubscribe", 17 | "params": [ 18 | {"mentions": [wallet_address]}, 19 | {"commitment": "finalized"} 20 | ] 21 | })) 22 | 23 | # Receive the first response 24 | first_resp = await websocket.recv() 25 | print(first_resp) 26 | response_dict = json.loads(first_resp) 27 | if 'result' in response_dict: 28 | print("Subscription successful. Subscription ID: ", response_dict['result']) 29 | 30 | # Continuously read from the WebSocket 31 | async for response in websocket: 32 | # print(response) 33 | response_dict = json.loads(response) 34 | 35 | if response_dict['params']['result']['value']['err'] == None: 36 | 37 | signature = response_dict['params']['result']['value']['signature'] 38 | if signature not in seen_signatures: 39 | seen_signatures.add(signature) 40 | count += 1 41 | print(f"{count}-New update received: , {signature}") 42 | print("=========================================") 43 | 44 | else: 45 | # print("Unexpected response: ", response_dict) 46 | pass 47 | 48 | asyncio.run(run()) 49 | -------------------------------------------------------------------------------- /Solana/NewPairs_Simple.py: -------------------------------------------------------------------------------- 1 | "Detect New Pools Created on Solana Raydium DEX" 2 | 3 | # TODO Add Buys ,Sells price and liquidity pool tracking management 4 | 5 | import asyncio 6 | import sys 7 | 8 | import websockets 9 | import json 10 | from solana.rpc.api import Client 11 | from solders.pubkey import Pubkey 12 | from solders.signature import Signature 13 | import pandas as pd 14 | from tabulate import tabulate 15 | 16 | wallet_address = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" 17 | seen_signatures = set() 18 | solana_client = Client("https://api.mainnet-beta.solana.com") 19 | 20 | 21 | def getTokens(str_signature): 22 | signature = Signature.from_string(str_signature) 23 | transaction = solana_client.get_transaction(signature, encoding="jsonParsed", 24 | max_supported_transaction_version=0).value 25 | instruction_list = transaction.transaction.transaction.message.instructions 26 | 27 | for instructions in instruction_list: 28 | if instructions.program_id == Pubkey.from_string(wallet_address): 29 | print("============NEW POOL DETECTED====================") 30 | Token0 = instructions.accounts[8] 31 | Token1 = instructions.accounts[9] 32 | # Your data 33 | data = {'Token_Index': ['Token0', 'Token1'], 34 | 'Account Public Key': [Token0, Token1]} 35 | 36 | df = pd.DataFrame(data) 37 | table = tabulate(df, headers='keys', tablefmt='fancy_grid') 38 | print(table) 39 | 40 | 41 | async def run(): 42 | uri = "wss://api.mainnet-beta.solana.com" 43 | async with websockets.connect(uri) as websocket: 44 | # Send subscription request 45 | await websocket.send(json.dumps({ 46 | "jsonrpc": "2.0", 47 | "id": 1, 48 | "method": "logsSubscribe", 49 | "params": [ 50 | {"mentions": [wallet_address]}, 51 | {"commitment": "finalized"} 52 | ] 53 | })) 54 | 55 | first_resp = await websocket.recv() 56 | response_dict = json.loads(first_resp) 57 | if 'result' in response_dict: 58 | print("Subscription successful. Subscription ID: ", response_dict['result']) 59 | 60 | # Continuously read from the WebSocket 61 | async for response in websocket: 62 | 63 | response_dict = json.loads(response) 64 | 65 | if response_dict['params']['result']['value']['err'] == None: 66 | signature = response_dict['params']['result']['value']['signature'] 67 | 68 | if signature not in seen_signatures: 69 | seen_signatures.add(signature) 70 | log_messages_set = set(response_dict['params']['result']['value']['logs']) 71 | 72 | search = "initialize2" 73 | if any(search in message for message in log_messages_set): 74 | print(f"True, https://solscan.io/tx/{signature}") 75 | getTokens(signature) 76 | 77 | 78 | else: 79 | pass 80 | 81 | 82 | async def main(): 83 | await run() 84 | 85 | 86 | asyncio.run(main()) -------------------------------------------------------------------------------- /Solana/NewlyCreatedPairs.py: -------------------------------------------------------------------------------- 1 | "Detect New Pools Created on Solana Raydium DEX" 2 | 3 | #MAnually see transactions of new pairs GThUX1Atko4tqhN2NaiTazWSeFWMuiUvfFnyJyUghFMJ under spl transfer section 4 | 5 | from time import sleep 6 | import logging 7 | 8 | import asyncio 9 | from typing import List, AsyncIterator, Tuple 10 | from asyncstdlib import enumerate 11 | 12 | from solders.pubkey import Pubkey 13 | from solders.rpc.config import RpcTransactionLogsFilterMentions 14 | 15 | from solana.rpc.websocket_api import connect 16 | from solana.rpc.commitment import Finalized 17 | from solana.rpc.api import Client 18 | from solana.exceptions import SolanaRpcException 19 | from websockets.exceptions import ConnectionClosedError, ProtocolError 20 | 21 | # Type hinting imports 22 | from solana.rpc.commitment import Commitment 23 | from solana.rpc.websocket_api import SolanaWsClientProtocol 24 | from solders.rpc.responses import RpcLogsResponse, SubscriptionResult, LogsNotification, GetTransactionResp 25 | from solders.signature import Signature 26 | from solders.transaction_status import UiPartiallyDecodedInstruction, ParsedInstruction 27 | 28 | # Raydium Liquidity Pool V4 29 | RaydiumLPV4 = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" 30 | URI = "https://api.mainnet-beta.solana.com" # "https://api.devnet.solana.com" | "https://api.mainnet-beta.solana.com" 31 | WSS = "wss://api.mainnet-beta.solana.com" # "wss://api.devnet.solana.com" | "wss://api.mainnet-beta.solana.com" 32 | solana_client = Client(URI) 33 | # Raydium function call name, look at raydium-amm/program/src/instruction.rs 34 | log_instruction = "initialize2" 35 | 36 | # Init logging 37 | logging.basicConfig(filename='app.log', filemode='a', level=logging.DEBUG) 38 | # Writes responses from socket to messages.json 39 | # Writes responses from http req to transactions.json 40 | 41 | async def main(): 42 | """The client as an infinite asynchronous iterator:""" 43 | async for websocket in connect(WSS): 44 | try: 45 | subscription_id = await subscribe_to_logs( 46 | websocket, 47 | RpcTransactionLogsFilterMentions(RaydiumLPV4), 48 | Finalized 49 | ) 50 | # Change level debugging to INFO 51 | logging.getLogger().setLevel(logging.INFO) # Logging 52 | async for i, signature in enumerate(process_messages(websocket, log_instruction)): # type: ignore 53 | logging.info(f"{i=}") # Logging 54 | try: 55 | get_tokens(signature, RaydiumLPV4) 56 | except SolanaRpcException as err: 57 | # Omitting httpx.HTTPStatusError: Client error '429 Too Many Requests' 58 | # Sleep 5 sec, and try connect again 59 | # Start logging 60 | logging.exception(err) 61 | logging.info("sleep for 5 seconds and try again") 62 | # End logging 63 | sleep(5) 64 | continue 65 | except (ProtocolError, ConnectionClosedError) as err: 66 | # Restart socket connection if ProtocolError: invalid status code 67 | logging.exception(err) # Logging 68 | print(f"Danger! Danger!", err) 69 | continue 70 | except KeyboardInterrupt: 71 | if websocket: 72 | await websocket.logs_unsubscribe(subscription_id) 73 | 74 | 75 | async def subscribe_to_logs(websocket: SolanaWsClientProtocol, 76 | mentions: RpcTransactionLogsFilterMentions, 77 | commitment: Commitment) -> int: 78 | await websocket.logs_subscribe( 79 | filter_=mentions, 80 | commitment=commitment 81 | ) 82 | first_resp = await websocket.recv() 83 | return get_subscription_id(first_resp) # type: ignore 84 | 85 | 86 | def get_subscription_id(response: SubscriptionResult) -> int: 87 | return response[0].result 88 | 89 | 90 | async def process_messages(websocket: SolanaWsClientProtocol, 91 | instruction: str) -> AsyncIterator[Signature]: 92 | """Async generator, main websocket's loop""" 93 | async for idx, msg in enumerate(websocket): 94 | value = get_msg_value(msg) 95 | if not idx % 100: 96 | print(f"{idx=}") 97 | for log in value.logs: 98 | if instruction not in log: 99 | continue 100 | # Start logging 101 | logging.info(value.signature) 102 | logging.info(log) 103 | # Logging to messages.json 104 | with open("messages.json", 'a', encoding='utf-8') as raw_messages: 105 | raw_messages.write(f"signature: {value.signature} \n") 106 | raw_messages.write(msg[0].to_json()) 107 | raw_messages.write("\n ########## \n") 108 | # End logging 109 | yield value.signature 110 | 111 | 112 | def get_msg_value(msg: List[LogsNotification]) -> RpcLogsResponse: 113 | return msg[0].result.value 114 | 115 | 116 | def get_tokens(signature: Signature, RaydiumLPV4: Pubkey) -> None: 117 | """httpx.HTTPStatusError: Client error '429 Too Many Requests' 118 | for url 'https://api.mainnet-beta.solana.com' 119 | For more information check: https://httpstatuses.com/429 120 | """ 121 | transaction = solana_client.get_transaction( 122 | signature, 123 | encoding="jsonParsed", 124 | max_supported_transaction_version=0 125 | ) 126 | # Start logging to transactions.json 127 | with open("transactions.json", 'a', encoding='utf-8') as raw_transactions: 128 | raw_transactions.write(f"signature: {signature}\n") 129 | raw_transactions.write(transaction.to_json()) 130 | raw_transactions.write("\n ########## \n") 131 | # End logging 132 | instructions = get_instructions(transaction) 133 | filtred_instuctions = instructions_with_program_id(instructions, RaydiumLPV4) 134 | logging.info(filtred_instuctions) 135 | for instruction in filtred_instuctions: 136 | tokens = get_tokens_info(instruction) 137 | print_table(tokens) 138 | print(f"True, https://solscan.io/tx/{signature}") 139 | 140 | 141 | def get_instructions( 142 | transaction: GetTransactionResp 143 | ) -> List[UiPartiallyDecodedInstruction | ParsedInstruction]: 144 | instructions = transaction \ 145 | .value \ 146 | .transaction \ 147 | .transaction \ 148 | .message \ 149 | .instructions 150 | return instructions 151 | 152 | 153 | def instructions_with_program_id( 154 | instructions: List[UiPartiallyDecodedInstruction | ParsedInstruction], 155 | program_id: str 156 | ) -> Iterator[UiPartiallyDecodedInstruction | ParsedInstruction]: 157 | return (instruction for instruction in instructions 158 | if instruction.program_id == program_id) 159 | 160 | 161 | def get_tokens_info( 162 | instruction: UiPartiallyDecodedInstruction | ParsedInstruction 163 | ) -> Tuple[Pubkey, Pubkey, Pubkey]: 164 | accounts = instruction.accounts 165 | Pair = accounts[4] 166 | Token0 = accounts[8] 167 | Token1 = accounts[9] 168 | # Start logging 169 | logging.info("find LP !!!") 170 | logging.info(f"\n Token0: {Token0}, \n Token1: {Token1}, \n Pair: {Pair}") 171 | # End logging 172 | return (Token0, Token1, Pair) 173 | 174 | 175 | def print_table(tokens: Tuple[Pubkey, Pubkey, Pubkey]) -> None: 176 | data = [ 177 | {'Token_Index': 'Token0', 'Account Public Key': tokens[0]}, # Token0 178 | {'Token_Index': 'Token1', 'Account Public Key': tokens[1]}, # Token1 179 | {'Token_Index': 'LP Pair', 'Account Public Key': tokens[2]} # LP Pair 180 | ] 181 | print("============NEW POOL DETECTED====================") 182 | header = ["Token_Index", "Account Public Key"] 183 | print("│".join(f" {col.ljust(15)} " for col in header)) 184 | print("|".rjust(18)) 185 | for row in data: 186 | print("│".join(f" {str(row[col]).ljust(15)} " for col in header)) 187 | 188 | 189 | if __name__ == "__main__": 190 | RaydiumLPV4 = Pubkey.from_string(RaydiumLPV4) 191 | asyncio.run(main()) 192 | -------------------------------------------------------------------------------- /Solana/Solana Dev Resources.txt: -------------------------------------------------------------------------------- 1 | https://anchor-lang.com/docs/intro-to-solana 2 | https://kevinheavey.github.io/anchorpy/ 3 | https://kevinheavey.github.io/solders/tutorials/index.html 4 | 5 | 6 | #Contrast with Ethereum 7 | https://solana.wiki/zh-cn/docs/ethereum-comparison/ 8 | 9 | #Explaination of accounts 10 | https://medium.com/@jorge_londono_31005/understanding-solanas-mint-account-and-token-accounts-546c0590e8e 11 | 12 | https://medium.com/coinmonks/how-to-become-a-solana-blockchain-developer-in-2022-cfc38f1370b9 13 | https://github.com/SolanaNatives/Solana-Programming-Resources 14 | -------------------------------------------------------------------------------- /Solana/Solana-Web3JS/DecodeMarketBid.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import { LiquidityPoolKeysV4, MARKET_STATE_LAYOUT_V3, Market, TOKEN_PROGRAM_ID } from "@raydium-io/raydium-sdk"; 3 | import { Connection, Logs, ParsedInnerInstruction, ParsedInstruction, ParsedTransactionWithMeta, PartiallyDecodedInstruction, PublicKey } from "@solana/web3.js"; 4 | const RPC_ENDPOINT = 'https://api.mainnet-beta.solana.com'; 5 | const connection = new Connection(RPC_ENDPOINT); 6 | 7 | const getAccount = async (address: string) => { 8 | const publicKey = new PublicKey(address); 9 | const accountInfo = await connection.getAccountInfo(publicKey); 10 | // return accountInfo?.data; 11 | if (accountInfo && accountInfo.data) { 12 | return MARKET_STATE_LAYOUT_V3.decode(accountInfo.data); 13 | } 14 | } 15 | //Example of a Market Bid. This information is necessary to build up instruction for a swap 16 | // Get this and complete your instruction swap and you will not need to use any API 17 | (async () => { 18 | console.log(await getAccount('8Gr1yE4ga8FFovvvTybYq2kSPfrGh9Jimso63bENXsKg')); 19 | })(); 20 | -------------------------------------------------------------------------------- /Solana/Solana-Web3JS/NewPoolRaydium.js: -------------------------------------------------------------------------------- 1 | import { Connection,PublicKey } from "@solana/web3.js"; 2 | const RAYDIUM_PUBLIC_KEY = ('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8'); 3 | const raydium = new PublicKey(RAYDIUM_PUBLIC_KEY); 4 | const connection = new Connection('https://api.mainnet-beta.solana.com',{ 5 | wsEndpoint: 'wss://api.mainnet-beta.solana.com' 6 | 7 | }); 8 | 9 | let processedSignatures = new Set(); 10 | 11 | async function main(connection,raydium){ 12 | console.log('Monitoring logs...',raydium.toString()); 13 | connection.onLogs(raydium,({logs,err,signature})=>{ 14 | if(err) return; 15 | if(logs && logs.some(log=> log.includes('initialize2') && !processedSignatures.has(signature))){ 16 | processedSignatures.add(signature); 17 | console.log('Signature for Initialize2:',signature); 18 | fetchRaydiumAccounts(signature,connection); 19 | } 20 | }, "finalized"); 21 | } 22 | 23 | async function fetchRaydiumAccounts(signature,connection){ 24 | const txId = signature; 25 | const tx = await connection.getParsedTransaction(txId, {maxSupportedTransactionVersion:0, commitment:"confirmed"}); 26 | const accounts = tx?.transaction?.message?.instructions.find(ix=>ix.programId.toBase58()===RAYDIUM_PUBLIC_KEY).accounts; 27 | 28 | if(!accounts){ 29 | console.log('No accounts found'); 30 | return; 31 | } 32 | const tokenAIndex=8; 33 | const tokenBIndex=9; 34 | 35 | const tokeAAccount = accounts[tokenAIndex]; 36 | const tokenBAccount = accounts[tokenBIndex]; 37 | const displayData=[ 38 | {Token:'Token A',account:tokeAAccount}, 39 | {Token:'Token B',account:tokenBAccount}, 40 | ]; 41 | console.log("New Raydium Liquidity Pool Created Found"); 42 | console.log(generateExplorerUrl(txId)); 43 | console.table(displayData); 44 | // await sleep(2000); 45 | } 46 | 47 | function generateExplorerUrl(txId){ 48 | return `https://solscan.io/tx/${txId}?cluster=mainnet`; 49 | } 50 | 51 | function sleep(ms) { 52 | return new Promise(resolve => setTimeout(resolve, ms)); 53 | } 54 | 55 | 56 | // main(connection,raydium).catch(console.error); 57 | async function runProgram() { 58 | try { 59 | await main(connection, raydium); 60 | } catch (error) { 61 | console.error(`Error occurred: ${error}`); 62 | console.log('Restarting the program...'); 63 | runProgram(); 64 | } 65 | } 66 | 67 | runProgram().catch(console.error); -------------------------------------------------------------------------------- /Solana/TokenAnalysis.py: -------------------------------------------------------------------------------- 1 | #METADATA, LP LOCKED , TOKEN DISTRIBUTION , MARKETCAP. 2 | -------------------------------------------------------------------------------- /Solana/TrackBots.py: -------------------------------------------------------------------------------- 1 | #Track telegram bots eg HEPL5rTb6n1Ax6jt9z2XMPFJcDe9bSWvWQpsK7AMcbZg----soltradingbot.sol What are all these degens buying 2 | 3 | 4 | #Build a streamflow analytics solution and find the most profitable traders. 5 | -------------------------------------------------------------------------------- /Solana/Trade/Buy.py: -------------------------------------------------------------------------------- 1 | 2 | from spl.token.instructions import create_associated_token_account, get_associated_token_address 3 | from spl.token.instructions import close_account, CloseAccountParams 4 | from spl.token.client import Token 5 | from solders.pubkey import Pubkey 6 | from solders.instruction import Instruction 7 | from solana.rpc.types import TokenAccountOpts 8 | from solana.transaction import AccountMeta 9 | from construct import Bytes, Int8ul, Int64ul, BytesInteger 10 | from construct import Struct as cStruct 11 | from spl.token.core import _TokenCore 12 | 13 | from solana.rpc.commitment import Commitment 14 | from solana.rpc.api import RPCException 15 | from solana.rpc.api import Client, Keypair 16 | import base58 17 | 18 | from solders.signature import Signature 19 | from dexscreener import getSymbol 20 | from layouts import SWAP_LAYOUT 21 | 22 | 23 | solana_client = Client("https://api.mainnet-beta.solana.com") 24 | 25 | LAMPORTS_PER_SOL = 1000000000 26 | AMM_PROGRAM_ID = Pubkey.from_string('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8') 27 | SERUM_PROGRAM_ID = Pubkey.from_string('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX') 28 | 29 | 30 | 31 | def get_token_account(ctx, 32 | owner: Pubkey.from_string, 33 | mint: Pubkey.from_string): 34 | try: 35 | account_data = ctx.get_token_accounts_by_owner(owner, TokenAccountOpts(mint)) 36 | return account_data.value[0].pubkey, None 37 | except: 38 | swap_associated_token_address = get_associated_token_address(owner, mint) 39 | swap_token_account_Instructions = create_associated_token_account(owner, owner, mint) 40 | return swap_associated_token_address, swap_token_account_Instructions 41 | 42 | myWallet= Pubkey.from_string("En5z1QWHbUtWdd54mdK1QVEBSpvDwejZDkroFAbccXbD") 43 | mint_address= Pubkey.from_string("Gzwy4DrmumZAG4Mu5m6S2uSKVyZ9GQ3GMAgmTsX4a1kq") #Tyler token 44 | accountProgramId = solana_client.get_account_info_json_parsed(Pubkey.from_string("Gzwy4DrmumZAG4Mu5m6S2uSKVyZ9GQ3GMAgmTsX4a1kq")) 45 | # print(accountProgramId.value.owner) 46 | # print(get_token_account(solana_client, myWallet, mint_address)) 47 | 48 | from create_close_account import get_token_account, fetch_pool_keys, get_token_account, make_swap_instruction 49 | from dexscreener import getSymbol 50 | # from webhook import sendWebhook 51 | 52 | import time 53 | 54 | LAMPORTS_PER_SOL = 1000000000 55 | 56 | 57 | def buy(solana_client, TOKEN_TO_SWAP_BUY, payer, amount): 58 | token_symbol, SOl_Symbol = getSymbol(TOKEN_TO_SWAP_BUY) 59 | 60 | mint = Pubkey.from_string(TOKEN_TO_SWAP_BUY) 61 | 62 | pool_keys = fetch_pool_keys(str(mint)) 63 | # print("Pool Keys: ", pool_keys) 64 | if pool_keys == "failed": 65 | print(f"a|BUY Pool ERROR {token_symbol} ", f"[Raydium]: Pool Key Not Found") 66 | return "failed" 67 | 68 | """ 69 | Calculate amount 70 | """ 71 | amount_in = int(amount * LAMPORTS_PER_SOL) 72 | # slippage = 0.1 73 | # lamports_amm = amount * LAMPORTS_PER_SOL 74 | # amount_in = int(lamports_amm - (lamports_amm * (slippage/100))) 75 | 76 | txnBool = True 77 | while txnBool: 78 | 79 | """Get swap token program id""" 80 | print("1. Get TOKEN_PROGRAM_ID...") 81 | accountProgramId = solana_client.get_account_info_json_parsed(mint) 82 | TOKEN_PROGRAM_ID = accountProgramId.value.owner 83 | 84 | """ 85 | Set Mint Token accounts addresses 86 | """ 87 | print("2. Get Mint Token accounts addresses...") 88 | swap_associated_token_address, swap_token_account_Instructions = get_token_account(solana_client, 89 | payer.pubkey(), mint) 90 | 91 | """ 92 | Create Wrap Sol Instructions 93 | """ 94 | print("3. Create Wrap Sol Instructions...") 95 | balance_needed = Token.get_min_balance_rent_for_exempt_for_account(solana_client) 96 | WSOL_token_account, swap_tx, payer, Wsol_account_keyPair, opts, = _TokenCore._create_wrapped_native_account_args( 97 | TOKEN_PROGRAM_ID, payer.pubkey(), payer, amount_in, 98 | False, balance_needed, Commitment("confirmed")) 99 | """ 100 | Create Swap Instructions 101 | """ 102 | print("4. Create Swap Instructions...") 103 | instructions_swap = make_swap_instruction(amount_in, 104 | WSOL_token_account, 105 | swap_associated_token_address, 106 | pool_keys, 107 | mint, 108 | solana_client, 109 | payer 110 | ) 111 | # print(instructions_swap) 112 | 113 | print("5. Create Close Account Instructions...") 114 | params = CloseAccountParams(account=WSOL_token_account, dest=payer.pubkey(), owner=payer.pubkey(), 115 | program_id=TOKEN_PROGRAM_ID) 116 | closeAcc = (close_account(params)) 117 | 118 | print("6. Add instructions to transaction...") 119 | if swap_token_account_Instructions != None: 120 | swap_tx.add(swap_token_account_Instructions) 121 | swap_tx.add(instructions_swap) 122 | swap_tx.add(closeAcc) 123 | 124 | try: 125 | print("7. Execute Transaction...") 126 | start_time = time.time() 127 | txn = solana_client.send_transaction(swap_tx, payer, Wsol_account_keyPair) 128 | txid_string_sig = txn.value 129 | print("Here is the Transaction Signature NB Confirmation is just to wat for confirmation: ", txid_string_sig) 130 | 131 | print("8. Confirm transaction...") 132 | break 133 | checkTxn = True 134 | while checkTxn: 135 | # status = solana_client.get_transaction(txid_string_sig, "json") 136 | # print( status.value.transaction.meta.err ) 137 | 138 | 139 | try: 140 | status = solana_client.get_transaction(txid_string_sig, "json") 141 | FeesUsed = (status.value.transaction.meta.fee) / 1000000000 142 | # print(status.value.transaction) 143 | # print("STATUS", status.value.transaction.meta.err) 144 | 145 | if status.value.transaction.meta.err==None: 146 | print("[create_account] Transaction Success", txn.value) 147 | print(f"[create_account] Transaction Fees: {FeesUsed:.10f} SOL") 148 | 149 | end_time = time.time() 150 | execution_time = end_time - start_time 151 | print(f"Execution time: {execution_time} seconds") 152 | 153 | txnBool = False 154 | checkTxn = False 155 | return txid_string_sig 156 | 157 | else: 158 | print("Transaction Failed") 159 | end_time = time.time() 160 | execution_time = end_time - start_time 161 | print(f"Execution time: {execution_time} seconds") 162 | checkTxn = False 163 | 164 | except Exception as e: 165 | print(f"e|BUY ERROR {token_symbol}", f"[Raydium]: {e}") 166 | # print("STATUS",status.value.transaction.meta.err) 167 | print("Sleeping...", e) 168 | time.sleep(0.500) 169 | print("Retrying...") 170 | 171 | except RPCException as e: 172 | print(f"Error: [{e.args[0].message}]...\nRetrying...") 173 | 174 | print(f"e|BUY ERROR ", f"[Raydium]: {e.args[0].message}") 175 | time.sleep(1) 176 | 177 | except Exception as e: 178 | print(f"e|BUY Exception ERROR {token_symbol} ", f"[Raydium]: {e}") 179 | print(f"Error: [{e}]...\nEnd...") 180 | txnBool = False 181 | return "failed" 182 | 183 | token_toBuy=input("Enter token to buy: ") 184 | payer = Keypair.from_base58_string("Enter String Private Key") 185 | print(payer.pubkey()) 186 | #0.004960 187 | #0.0001 188 | buy(solana_client, token_toBuy, payer, 0.004960) 189 | -------------------------------------------------------------------------------- /Solana/Trade/Sell.py: -------------------------------------------------------------------------------- 1 | from spl.token.instructions import close_account, CloseAccountParams 2 | 3 | from solana.rpc.types import TokenAccountOpts 4 | from solana.rpc.api import RPCException 5 | from solana.transaction import Transaction 6 | 7 | from solders.pubkey import Pubkey 8 | from solana.rpc.api import Client, Keypair 9 | import base58 10 | 11 | 12 | from create_close_account import fetch_pool_keys, sell_get_token_account, get_token_account, \ 13 | make_swap_instruction 14 | from dexscreener import getSymbol 15 | # from webhook import sendWebhook 16 | 17 | import time 18 | 19 | LAMPORTS_PER_SOL = 1000000000 20 | 21 | 22 | # ctx , TOKEN_TO_SWAP_SELL, keypair 23 | def sell(solana_client, TOKEN_TO_SWAP_SELL, payer): 24 | token_symbol, SOl_Symbol = getSymbol(TOKEN_TO_SWAP_SELL) 25 | 26 | mint = Pubkey.from_string(TOKEN_TO_SWAP_SELL) 27 | sol = Pubkey.from_string("So11111111111111111111111111111111111111112") 28 | 29 | """Get swap token program id""" 30 | print("1. Get TOKEN_PROGRAM_ID...") 31 | TOKEN_PROGRAM_ID = solana_client.get_account_info_json_parsed(mint).value.owner 32 | 33 | """Get Pool Keys""" 34 | print("2. Get Pool Keys...") 35 | pool_keys = fetch_pool_keys(str(mint)) 36 | if pool_keys == "failed": 37 | print(f"a|Sell Pool ERROR {token_symbol}", f"[Raydium]: Pool Key Not Found") 38 | return "failed" 39 | 40 | txnBool = True 41 | while txnBool: 42 | """Get Token Balance from wallet""" 43 | print("3. Get oken Balance from wallet...") 44 | 45 | balanceBool = True 46 | while balanceBool: 47 | tokenPk = mint 48 | 49 | accountProgramId = solana_client.get_account_info_json_parsed(tokenPk) 50 | programid_of_token = accountProgramId.value.owner 51 | 52 | accounts = solana_client.get_token_accounts_by_owner_json_parsed(payer.pubkey(), TokenAccountOpts( 53 | program_id=programid_of_token)).value 54 | for account in accounts: 55 | mint_in_acc = account.account.data.parsed['info']['mint'] 56 | if mint_in_acc == str(mint): 57 | amount_in = int(account.account.data.parsed['info']['tokenAmount']['amount']) 58 | print("3.1 Token Balance [Lamports]: ", amount_in) 59 | break 60 | if int(amount_in) > 0: 61 | balanceBool = False 62 | else: 63 | print("No Balance, Retrying...") 64 | time.sleep(2) 65 | 66 | """Get token accounts""" 67 | print("4. Get token accounts for swap...") 68 | swap_token_account = sell_get_token_account(solana_client, payer.pubkey(), mint) 69 | WSOL_token_account, WSOL_token_account_Instructions = get_token_account(solana_client, payer.pubkey(), sol) 70 | 71 | if swap_token_account == None: 72 | print("swap_token_account not found...") 73 | return "failed" 74 | 75 | else: 76 | """Make swap instructions""" 77 | print("5. Create Swap Instructions...") 78 | instructions_swap = make_swap_instruction(amount_in, 79 | swap_token_account, 80 | WSOL_token_account, 81 | pool_keys, 82 | mint, 83 | solana_client, 84 | payer 85 | ) 86 | 87 | """Close wsol account""" 88 | print("6. Create Instructions to Close WSOL account...") 89 | params = CloseAccountParams(account=WSOL_token_account, dest=payer.pubkey(), owner=payer.pubkey(), 90 | program_id=TOKEN_PROGRAM_ID) 91 | closeAcc = (close_account(params)) 92 | 93 | """Create transaction and add instructions""" 94 | print("7. Create transaction and add instructions to Close WSOL account...") 95 | swap_tx = Transaction() 96 | signers = [payer] 97 | if WSOL_token_account_Instructions != None: 98 | swap_tx.add(WSOL_token_account_Instructions) 99 | swap_tx.add(instructions_swap) 100 | swap_tx.add(closeAcc) 101 | 102 | """Send transaction""" 103 | try: 104 | print("8. Execute Transaction...") 105 | start_time = time.time() 106 | txn = solana_client.send_transaction(swap_tx, *signers) 107 | 108 | """Confirm it has been sent""" 109 | txid_string_sig = txn.value 110 | print("9. Confirm it has been sent...") 111 | print("Transaction Signature: ", txid_string_sig) 112 | break 113 | checkTxn = True 114 | while checkTxn: 115 | try: 116 | status = solana_client.get_transaction(txid_string_sig, "json") 117 | FeesUsed = (status.value.transaction.meta.fee) / 1000000000 118 | if status.value.transaction.meta.err == None: 119 | print("[create_account] Transaction Success", txn.value) 120 | print(f"[create_account] Transaction Fees: {FeesUsed:.10f} SOL") 121 | 122 | end_time = time.time() 123 | execution_time = end_time - start_time 124 | print(f"Execution time: {execution_time} seconds") 125 | 126 | txnBool = False 127 | checkTxn = False 128 | return txid_string_sig 129 | else: 130 | 131 | print("Transaction Failed") 132 | 133 | end_time = time.time() 134 | execution_time = end_time - start_time 135 | print(f"Execution time: {execution_time} seconds") 136 | 137 | checkTxn = False 138 | 139 | except Exception as e: 140 | print(f"e|Sell ERROR {token_symbol}", f"[Raydium]: {e}") 141 | 142 | print("Sleeping...", e) 143 | time.sleep(0.500) 144 | print("Retrying...") 145 | 146 | except RPCException as e: 147 | print(f"Error: [{e.args[0].message}]...\nRetrying...") 148 | print(f"e|SELL ERROR {token_symbol}", f"[Raydium]: {e.args[0].message}") 149 | 150 | except Exception as e: 151 | print(f"Error: [{e}]...\nEnd...") 152 | print(f"e|SELL Exception ERROR {token_symbol}", f"[Raydium]: {e.args[0].message}") 153 | txnBool = False 154 | return "failed" 155 | 156 | solana_client = Client("https://api.mainnet-beta.solana.com") 157 | 158 | token_toSell= input("Enter Token Address to Sell : ") 159 | private_key_string = "Enter Your Private Key" 160 | private_key_bytes = base58.b58decode(private_key_string) 161 | payer = Keypair.from_bytes(private_key_bytes) 162 | print(f"Your Wallet Address : {payer.pubkey()}") 163 | sell(solana_client,token_toSell,payer) -------------------------------------------------------------------------------- /Solana/Trade/create_close_account.py: -------------------------------------------------------------------------------- 1 | from spl.token.instructions import create_associated_token_account, get_associated_token_address 2 | 3 | from solders.pubkey import Pubkey 4 | from solders.instruction import Instruction 5 | 6 | from solana.rpc.types import TokenAccountOpts 7 | from solana.transaction import AccountMeta 8 | 9 | from layouts import SWAP_LAYOUT 10 | 11 | import json, requests 12 | 13 | LAMPORTS_PER_SOL = 1000000000 14 | AMM_PROGRAM_ID = Pubkey.from_string('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8') 15 | SERUM_PROGRAM_ID = Pubkey.from_string('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX') 16 | 17 | 18 | def make_swap_instruction(amount_in: int, token_account_in: Pubkey.from_string, token_account_out: Pubkey.from_string, 19 | accounts: dict, mint, ctx, owner) -> Instruction: 20 | tokenPk = mint 21 | accountProgramId = ctx.get_account_info_json_parsed(tokenPk) 22 | TOKEN_PROGRAM_ID = accountProgramId.value.owner 23 | 24 | keys = [ 25 | AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False), 26 | AccountMeta(pubkey=accounts["amm_id"], is_signer=False, is_writable=True), 27 | AccountMeta(pubkey=accounts["authority"], is_signer=False, is_writable=False), 28 | AccountMeta(pubkey=accounts["open_orders"], is_signer=False, is_writable=True), 29 | AccountMeta(pubkey=accounts["target_orders"], is_signer=False, is_writable=True), 30 | AccountMeta(pubkey=accounts["base_vault"], is_signer=False, is_writable=True), 31 | AccountMeta(pubkey=accounts["quote_vault"], is_signer=False, is_writable=True), 32 | AccountMeta(pubkey=SERUM_PROGRAM_ID, is_signer=False, is_writable=False), 33 | AccountMeta(pubkey=accounts["market_id"], is_signer=False, is_writable=True), 34 | AccountMeta(pubkey=accounts["bids"], is_signer=False, is_writable=True), 35 | AccountMeta(pubkey=accounts["asks"], is_signer=False, is_writable=True), 36 | AccountMeta(pubkey=accounts["event_queue"], is_signer=False, is_writable=True), 37 | AccountMeta(pubkey=accounts["market_base_vault"], is_signer=False, is_writable=True), 38 | AccountMeta(pubkey=accounts["market_quote_vault"], is_signer=False, is_writable=True), 39 | AccountMeta(pubkey=accounts["market_authority"], is_signer=False, is_writable=False), 40 | AccountMeta(pubkey=token_account_in, is_signer=False, is_writable=True), # UserSourceTokenAccount 41 | AccountMeta(pubkey=token_account_out, is_signer=False, is_writable=True), # UserDestTokenAccount 42 | AccountMeta(pubkey=owner.pubkey(), is_signer=True, is_writable=False) # UserOwner 43 | ] 44 | 45 | data = SWAP_LAYOUT.build( 46 | dict( 47 | instruction=9, 48 | amount_in=int(amount_in), 49 | min_amount_out=0 50 | ) 51 | ) 52 | return Instruction(AMM_PROGRAM_ID, data, keys) 53 | 54 | 55 | def get_token_account(ctx, 56 | owner: Pubkey.from_string, 57 | mint: Pubkey.from_string): 58 | try: 59 | account_data = ctx.get_token_accounts_by_owner(owner, TokenAccountOpts(mint)) 60 | return account_data.value[0].pubkey, None 61 | except: 62 | swap_associated_token_address = get_associated_token_address(owner, mint) 63 | swap_token_account_Instructions = create_associated_token_account(owner, owner, mint) 64 | return swap_associated_token_address, swap_token_account_Instructions 65 | 66 | 67 | def sell_get_token_account(ctx, 68 | owner: Pubkey.from_string, 69 | mint: Pubkey.from_string): 70 | try: 71 | account_data = ctx.get_token_accounts_by_owner(owner, TokenAccountOpts(mint)) 72 | return account_data.value[0].pubkey 73 | except: 74 | print("Mint Token Not found") 75 | return None 76 | 77 | 78 | def extract_pool_info(pools_list: list, mint: str) -> dict: 79 | for pool in pools_list: 80 | 81 | if pool['baseMint'] == mint and pool['quoteMint'] == 'So11111111111111111111111111111111111111112': 82 | return pool 83 | elif pool['quoteMint'] == mint and pool['baseMint'] == 'So11111111111111111111111111111111111111112': 84 | return pool 85 | raise Exception(f'{mint} pool not found!') 86 | 87 | # TODO Fix this to get swap instruction without an API 88 | #SOLVED!!!! DUE TO COMPETION I"M NOT GONNA OPEN SOURCE IT CONTACT ME--- FOR PURCHASE OR SUBSCRIBE to my site to get ready to use my solana bot 89 | def fetch_pool_keys(mint: str): 90 | amm_info = {} 91 | all_pools = {} 92 | try: 93 | # Using this so it will be faster else no option, we go the slower way. 94 | with open('all_pools.json', 'r') as file: 95 | all_pools = json.load(file) 96 | amm_info = extract_pool_info(all_pools, mint) 97 | except: 98 | resp = requests.get('https://api.raydium.io/v2/sdk/liquidity/mainnet.json', stream=True) 99 | pools = resp.json() 100 | official = pools['official'] 101 | unofficial = pools['unOfficial'] 102 | all_pools = official + unofficial 103 | 104 | # Store all_pools in a JSON file 105 | with open('all_pools.json', 'w') as file: 106 | json.dump(all_pools, file) 107 | try: 108 | amm_info = extract_pool_info(all_pools, mint) 109 | except: 110 | return "failed" 111 | 112 | return { 113 | 'amm_id': Pubkey.from_string(amm_info['id']), 114 | 'authority': Pubkey.from_string(amm_info['authority']), 115 | 'base_mint': Pubkey.from_string(amm_info['baseMint']), 116 | 'base_decimals': amm_info['baseDecimals'], 117 | 'quote_mint': Pubkey.from_string(amm_info['quoteMint']), 118 | 'quote_decimals': amm_info['quoteDecimals'], 119 | 'lp_mint': Pubkey.from_string(amm_info['lpMint']), 120 | 'open_orders': Pubkey.from_string(amm_info['openOrders']), 121 | 'target_orders': Pubkey.from_string(amm_info['targetOrders']), 122 | 'base_vault': Pubkey.from_string(amm_info['baseVault']), 123 | 'quote_vault': Pubkey.from_string(amm_info['quoteVault']), 124 | 'market_id': Pubkey.from_string(amm_info['marketId']), 125 | 'market_base_vault': Pubkey.from_string(amm_info['marketBaseVault']), 126 | 'market_quote_vault': Pubkey.from_string(amm_info['marketQuoteVault']), 127 | 'market_authority': Pubkey.from_string(amm_info['marketAuthority']), 128 | 'bids': Pubkey.from_string(amm_info['marketBids']), 129 | 'asks': Pubkey.from_string(amm_info['marketAsks']), 130 | 'event_queue': Pubkey.from_string(amm_info['marketEventQueue']) 131 | } 132 | -------------------------------------------------------------------------------- /Solana/Trade/dexscreener.py: -------------------------------------------------------------------------------- 1 | import requests, json, os, sys 2 | from configparser import ConfigParser 3 | 4 | config = ConfigParser() 5 | config.read(os.path.join(sys.path[0], 'data', 'config.ini')) 6 | # birdeye_api = config.get("BIRDEYE", "API") 7 | 8 | """I modified it to dexscreener, forgot to change the filename""" 9 | 10 | 11 | def getBaseToken(token_address): 12 | url = f"https://api.dexscreener.com/latest/dex/pairs/solana/{token_address}" 13 | response = requests.get(url).json() 14 | return response['pair']['baseToken']['address'] 15 | 16 | 17 | """ 18 | USDT and USDC prices will be excluded 19 | """ 20 | 21 | 22 | def get_price(token_address): 23 | url = f"https://api.dexscreener.com/latest/dex/tokens/{token_address}" 24 | exclude = ['EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'] 25 | response = requests.get(url).json() 26 | 27 | if token_address not in exclude: 28 | for pair in response['pairs']: 29 | if pair['quoteToken']['address'] == 'So11111111111111111111111111111111111111112': 30 | return float(pair['priceUsd']) 31 | else: 32 | return response['pairs'][0]['priceUsd'] 33 | return None 34 | 35 | 36 | """Common addresses like usdc and usdt will be excluded as we know their symbols""" 37 | 38 | 39 | def getSymbol(token): 40 | # usdc and usdt 41 | exclude = ['EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'] 42 | 43 | if token not in exclude: 44 | url = f"https://api.dexscreener.com/latest/dex/tokens/{token}" 45 | 46 | Token_Symbol = "" 47 | Sol_symbol = "" 48 | try: 49 | response = requests.get(url) 50 | 51 | # Check if the request was successful (status code 200) 52 | if response.status_code == 200: 53 | resp = response.json() 54 | print("Response:", resp['pairs'][0]['baseToken']['symbol']) 55 | for pair in resp['pairs']: 56 | quoteToken = pair['quoteToken']['symbol'] 57 | 58 | if quoteToken == 'SOL': 59 | Token_Symbol = pair['baseToken']['symbol'] 60 | Sol_symbol = quoteToken 61 | return Token_Symbol, Sol_symbol 62 | 63 | 64 | else: 65 | print(f"[getSymbol] Request failed with status code {response.status_code}") 66 | 67 | except requests.exceptions.RequestException as e: 68 | print(f"[getSymbol] error occurred: {e}") 69 | except: 70 | a = 1 71 | 72 | return Token_Symbol, Sol_symbol 73 | else: 74 | if token == 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v': 75 | return "USDC", "SOL" 76 | elif token == 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v': 77 | return "USDT", "SOL" 78 | -------------------------------------------------------------------------------- /Solana/Trade/layouts.py: -------------------------------------------------------------------------------- 1 | from construct import Bytes, Int8ul, Int64ul, BytesInteger 2 | from construct import Struct as cStruct 3 | 4 | """Thanks to v0idum for creating layouts in python""" 5 | 6 | 7 | POOL_INFO_LAYOUT = cStruct( 8 | "instruction" / Int8ul, 9 | "simulate_type" / Int8ul 10 | ) 11 | 12 | SWAP_LAYOUT = cStruct( 13 | "instruction" / Int8ul, 14 | "amount_in" / Int64ul, 15 | "min_amount_out" / Int64ul 16 | ) 17 | 18 | # Not in use right now, might be useful in future 19 | AMM_INFO_LAYOUT_V4 = cStruct( 20 | 'status' / Int64ul, 21 | 'nonce' / Int64ul, 22 | 'order_num' / Int64ul, 23 | 'depth' / Int64ul, 24 | 'base_decimal' / Int64ul, 25 | 'quote_decimal' / Int64ul, 26 | 'state' / Int64ul, 27 | 'reset_flag' / Int64ul, 28 | 'min_size' / Int64ul, 29 | 'vol_max_cut_ratio' / Int64ul, 30 | 'amount_wave_ratio' / Int64ul, 31 | 'base_lot_size' / Int64ul, 32 | 'quote_lot_size' / Int64ul, 33 | 'min_price_multiplier' / Int64ul, 34 | 'max_price_multiplier' / Int64ul, 35 | 'system_decimal_value' / Int64ul, 36 | # Fees 37 | 'min_separate_numerator' / Int64ul, 38 | 'min_separate_denominator' / Int64ul, 39 | 'trade_fee_numerator' / Int64ul, 40 | 'trade_fee_denominator' / Int64ul, 41 | 'pnl_numerator' / Int64ul, 42 | 'pnl_denominator' / Int64ul, 43 | 'swap_fee_numerator' / Int64ul, 44 | 'swap_fee_denominator' / Int64ul, 45 | # OutPutData 46 | 'base_need_take_pnl' / Int64ul, 47 | 'quote_need_take_pnl' / Int64ul, 48 | 'quote_total_pnl' / Int64ul, 49 | 'base_total_pnl' / Int64ul, 50 | # 128 51 | 'quote_total_deposited' / BytesInteger(16, signed=False, swapped=True), 52 | 'base_total_deposited' / BytesInteger(16, signed=False, swapped=True), 53 | 'swap_base_in_amount' / BytesInteger(16, signed=False, swapped=True), 54 | 'swap_quote_out_amount' / BytesInteger(16, signed=False, swapped=True), 55 | 56 | 'swap_base2_quote_fee' / Int64ul, 57 | # 128 58 | 'swap_quote_in_amount' / BytesInteger(16, signed=False, swapped=True), 59 | 'swap_base_out_amount' / BytesInteger(16, signed=False, swapped=True), 60 | 61 | 'swap_quote2_base_fee' / Int64ul, 62 | # AMM Vault 63 | 'base_vault' / Bytes(32), 64 | 'quote_vault' / Bytes(32), 65 | # Mint 66 | 'base_mint' / Bytes(32), 67 | 'quote_mint' / Bytes(32), 68 | 'lp_mint' / Bytes(32), 69 | # Market 70 | 'open_orders' / Bytes(32), 71 | 'market_id' / Bytes(32), 72 | 'serum_program_id' / Bytes(32), 73 | 'target_orders' / Bytes(32), 74 | 'withdraw_queue' / Bytes(32), 75 | 'lp_vault' / Bytes(32), 76 | 'amm_owner' / Bytes(32), 77 | 78 | 'lpReserve' / Int64ul, 79 | ) -------------------------------------------------------------------------------- /Solana/Wallet/.env: -------------------------------------------------------------------------------- 1 | RPC_URL="Enter Your Alchemy RPC URL" -------------------------------------------------------------------------------- /Solana/Wallet/Create_WalletAddress.py: -------------------------------------------------------------------------------- 1 | from solana.rpc.api import Client, Keypair 2 | import base58 3 | from dotenv import dotenv_values 4 | 5 | config = dotenv_values(".env") 6 | client = Client(config["RPC_URL"]) #You can directly use the RPC_URL here without using dotenv 7 | 8 | new_account = Keypair() 9 | wallet_address = new_account.pubkey() 10 | 11 | private_key_bytes = new_account.secret() 12 | public_key_bytes = bytes(new_account.pubkey()) 13 | encoded_keypair= private_key_bytes+public_key_bytes 14 | private_key= base58.b58encode(encoded_keypair).decode() 15 | print("Wallet Address: ",wallet_address) 16 | print("Private Key : ",private_key) #import in phantom wallet 17 | 18 | -------------------------------------------------------------------------------- /Solana/Wallet/WalletFrom_PrivateKey.py: -------------------------------------------------------------------------------- 1 | import base58 2 | from base58 import b58decode, b58encode 3 | from solana.rpc.api import Keypair 4 | 5 | #Wallet Address: FTvNm4CQPkqcUB6AL9SE5TS8KswCfr9xGj47dzTT24CU 6 | #Private Key: 21T8iLRJpWterSN1ozw4sEoaZ1aYVAQWcWmESisiyjQuEitXNF3PcDJqNxdbx7bTqL9wGQKhAhaMB7JFekmKK2Lk 7 | 8 | 9 | encoded_pair= "21T8iLRJpWterSN1ozw4sEoaZ1aYVAQWcWmESisiyjQuEitXNF3PcDJqNxdbx7bTqL9wGQKhAhaMB7JFekmKK2Lk" 10 | key_pair= b58decode(encoded_pair) 11 | 12 | private_key_bytes = base58.b58decode(encoded_pair) 13 | # Create a Keypair object from the secret key bytes 14 | keypair = Keypair.from_bytes(private_key_bytes) 15 | print(keypair.pubkey()) 16 | 17 | # private_key= key_pair[:32] 18 | # public_key= key_pair[32:] 19 | # 20 | # print("Wallet Address: ",b58encode(public_key).decode()) 21 | # 22 | # # To get the private key from the keypair, 23 | # _keypair= private_key+public_key 24 | # _encoded_keypair= b58encode(_keypair).decode() 25 | # print("Private Key: ",_encoded_keypair) -------------------------------------------------------------------------------- /Solana/Wallet_AddressAnalytics.py: -------------------------------------------------------------------------------- 1 | #This script will show you the most profitable trade of a wallet address in ascending order----PREMIUM 2 | -------------------------------------------------------------------------------- /Solana/copyTrade.py: -------------------------------------------------------------------------------- 1 | #DONE I"M NOT GONNA OPEN SOURCE IT FOR NOW>>>> WORKS FOR NEW POOLS AND HIGH FREQUENCY TRADES 2 | 3 | #PREMIUM ---Contact to buy 4 | -------------------------------------------------------------------------------- /Solana/progam.py: -------------------------------------------------------------------------------- 1 | #SOlana prograam User Buy via your program and you charge x amount of fees ---can be interface to telegram as a bot-----KUVI BOT COMING SOON 2 | -------------------------------------------------------------------------------- /Solana/spl-token-Analytics.py: -------------------------------------------------------------------------------- 1 | # View All transactions of an spl token and do some blockchain analytics 2 | -------------------------------------------------------------------------------- /Subgraphs/NewlyCreatedPairs.py: -------------------------------------------------------------------------------- 1 | "Get newly Created pairs using subgraph Filter volume,liquidity and makers and make a buying decison" -------------------------------------------------------------------------------- /Telegram Bot/snipe_telegram.py: -------------------------------------------------------------------------------- 1 | #Snipe listings from your favourite telegram Channels 2 | -------------------------------------------------------------------------------- /Telegram Bot/tg.py: -------------------------------------------------------------------------------- 1 | #TODO --------------------------------------------------------------------------------