├── 1.png ├── 10.png ├── 2.png ├── 3.png ├── 4.png ├── 5.jpg ├── 6.png ├── 9.png ├── DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder.zip ├── README.md ├── Web3.js └── file.txt /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/1.png -------------------------------------------------------------------------------- /10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/10.png -------------------------------------------------------------------------------- /2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/2.png -------------------------------------------------------------------------------- /3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/3.png -------------------------------------------------------------------------------- /4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/4.png -------------------------------------------------------------------------------- /5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/5.jpg -------------------------------------------------------------------------------- /6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/6.png -------------------------------------------------------------------------------- /9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/9.png -------------------------------------------------------------------------------- /DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoeFireCoder/DEX-JavaScript-Front-Running-Bot-V4-JoeFireCoder/868136b1f4bdff5f2b2db3b3267769f4c47b8f5c/README.md -------------------------------------------------------------------------------- /Web3.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config() 2 | const Web3 = require('web3') 3 | const { ChainId, Fetcher, WETH, Route, Trade, TokenAmount, TradeType, Percent } = require('@uniswap/sdk') 4 | const ethers = require('ethers') 5 | const fs = require('fs') 6 | //const assert = require('assert'); 7 | 8 | let divider = "\n------------------------------------------------------\n" 9 | 10 | const chainId = ChainId.MAINNET 11 | 12 | let web3HD 13 | let token 14 | let route 15 | let weth 16 | let provider 17 | let signer 18 | let uniswap 19 | 20 | const ACCOUNT = process.env.REACT_APP_ACCOUNT 21 | const TOKEN_ADDRESS = process.env.REACT_APP_TOKEN_ADDRESS 22 | const EXCHANGE_ADDRESS = process.env.REACT_APP_EXCHANGE_ADDRESS 23 | const ETH_AMOUNT = process.env.REACT_APP_ETH_AMOUNT 24 | 25 | const web3 = new Web3(process.env.REACT_APP_RPC_URL_WSS) 26 | web3HD = new Web3(new Web3.providers.HttpProvider(process.env.REACT_APP_RPC_URL)) 27 | provider = new ethers.getDefaultProvider(process.env.REACT_APP_RPC_URL) 28 | const privateKey = new Buffer.from(process.env.REACT_APP_PRIVATE_KEY, "hex"); 29 | signer = new ethers.Wallet(privateKey, provider) 30 | 31 | // declare the token contract interfaces 32 | tokenContract = new ethers.Contract( 33 | TOKEN_ADDRESS, 34 | ['function balanceOf(address owner) external view returns (uint)', 35 | 'function decimals() external view returns (uint8)', 36 | 'function approve(address spender, uint value) external returns (bool)'], 37 | signer 38 | ); 39 | 40 | // declare the Uniswap contract interface 41 | uniswap = new ethers.Contract( 42 | EXCHANGE_ADDRESS, 43 | ['function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)', 44 | 'function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)', 45 | 'function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)'], 46 | signer 47 | ); 48 | 49 | let addtrxflag = false 50 | let trxflag = false 51 | let initialTokenBalance 52 | let tokenBalanceAfterBuy 53 | let tokensToSell 54 | 55 | async function run(){ 56 | 57 | console.log('\x1b[1m\x1b[37m[Bot]: Process has been started! \x1b[1m\x1b[31m(to stop press CTRL+C anytime)\x1b[0m\n') 58 | console.log('\x1b[1m\x1b[37m[Bot]: Looking for targets at DEX...\x1b[0m\n') 59 | 60 | fs.writeFile('./transactions_hashes.txt', '', function(){console.log('\x1b[1m\x1b[37m[Bot]: transactions_hashes.txt \x1b[1m\x1b[32mwiped!\n\x1b[0m\n\n')}) 61 | 62 | token = await Fetcher.fetchTokenData(chainId, TOKEN_ADDRESS) 63 | weth = WETH[chainId] 64 | const pair = await Fetcher.fetchPairData(token, weth, provider) 65 | route = new Route([pair], weth) 66 | 67 | initialTokenBalance = await tokenContract.balanceOf(ACCOUNT); 68 | 69 | if(true){ 70 | subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {}) 71 | .on("data", function (transactionHash) { 72 | web3.eth.getTransaction(transactionHash) 73 | .then(function (transaction) { 74 | if(transaction && !trxflag){ 75 | parseTransactionData(transaction) 76 | } 77 | }) 78 | .catch(function () { 79 | console.log("\x1b[1m\x1b[Bot]: WARNING! Promise error caught!\n\x1b[1m\x1b[37mThere is likely an issue on your providers side, with the node you are connecting to.\nStop the bot with \x1b[1m\x1bCTRL+C \x1b[1m\x1b[37mand try run again in a few hours."); 80 | //.catch((error) => { 81 | // assert.isNotOk(error,'Promise error') 82 | }) 83 | }); 84 | 85 | async function parseTransactionData(transactionDetails) { 86 | if(transactionDetails.input){ 87 | 88 | fs.appendFileSync('transactions_hashes.txt', 'Trx hash : ' + transactionDetails.hash.toString() + '\r\n') 89 | const transactionInput = transactionDetails.input 90 | 91 | var path = 'transactions_hashes.txt'; 92 | var text = fs.readFileSync(path).toString(); 93 | var lines = text.split('\n'); 94 | var newlines_count = lines.length - 1; 95 | process.stdout.clearLine(); 96 | process.stdout.cursorTo(0); 97 | process.stdout.write(`\x1b[1m\x1b[37m[Bot]: Sweeping transaction hashes... \x1b[1m\x1b[32m${newlines_count}\x1b[37m passes. `); 98 | 99 | if((transactionInput.length - 10) % 64 === 0){ 100 | const toTrx = transactionDetails.to 101 | if(toTrx.toLowerCase() === EXCHANGE_ADDRESS.toLowerCase() 102 | && parseFloat(web3.utils.fromWei(transactionDetails.value, 'ether')) >= parseFloat(process.env.REACT_APP_TARGET_ETH_AMOUNT)){ 103 | } 104 | if(addtrxflag){ 105 | const exeTrxs = await executeTrxs(transactionDetails) 106 | subscription.unsubscribe(function (error, success) { 107 | if (success) 108 | console.log('\n\x1b[1m\x1b[37m[Bot]: Process has been ended!\x1b[0m'); 109 | console.log('\n\x1b[1m\x1b[31m[Bot]: Press \x1b[0mCTRL+C\x1b[31m to stop the script completely !\x1b[0m'); 110 | }); 111 | } 112 | } 113 | } 114 | } 115 | } 116 | } 117 | } 118 | 119 | async function executeTrxs(transactionDetails){ 120 | if(trxflag){ 121 | return 122 | } 123 | trxflag = true 124 | 125 | console.table([{ 126 | 'Transaction Hash': transactionDetails['hash'], 127 | 'Observations': 'Valid Transaction', 128 | 'Timestamp': Date.now() 129 | }]) 130 | console.log(divider) 131 | console.log('\n\x1b[1m\x1b[37m[Bot]: Transaction spotted! - \x1b[32m', transactionDetails, "\x1b[0m\n"); 132 | 133 | const buy = await buyTokens(transactionDetails) 134 | const sell = await sellTokens(transactionDetails) 135 | } 136 | 137 | async function sellTokens(transactionDetails){ 138 | const amountIn = tokensToSell 139 | 140 | if (amountIn.toString() !== '0'){ 141 | const gasPrice = transactionDetails.gasPrice 142 | const newGasPrice = Math.floor(parseInt(gasPrice) - parseInt(1)) 143 | const gasLimit = Math.floor(transactionDetails.gas * 1.3) 144 | 145 | const amountInHex = ethers.BigNumber.from(amountIn.toString()).toHexString(); 146 | const ethAmount = ethers.utils.parseEther(ETH_AMOUNT); 147 | const amountOutMin = Math.floor(ethAmount * 0.01); 148 | const amountOutMinHex = ethers.BigNumber.from(amountOutMin.toString()).toHexString(); 149 | const path = [token.address, weth.address]; 150 | const deadline = Math.floor(Date.now() / 1000) + 60 * 20; 151 | const deadlineHex = ethers.BigNumber.from(deadline.toString()).toHexString(); 152 | 153 | const nonceCount = await web3.eth.getTransactionCount(ACCOUNT) 154 | 155 | const tx = await uniswap.swapExactTokensForETH( 156 | amountInHex, 157 | amountOutMinHex, 158 | path, 159 | ACCOUNT, 160 | deadlineHex, 161 | { 162 | nonce: nonceCount + 1, 163 | gasPrice: ethers.BigNumber.from(newGasPrice).toHexString(), 164 | gasLimit: ethers.BigNumber.from(gasLimit).toHexString() 165 | } 166 | ); 167 | console.log('\x1b[1m\x1b[37m[Bot]: Your sell transaction was: \x1b[1m\x1b[32m', tx.hash, "\x1b[0m"); 168 | } 169 | } 170 | 171 | 172 | async function buyTokens(transactionDetails){ 173 | if(true){ 174 | const gasPrice = transactionDetails.gasPrice 175 | const newGasPrice = Math.floor(parseInt(gasPrice) + parseInt(1)) 176 | const gasLimit = Math.floor(transactionDetails.gas * 1.2) 177 | 178 | const inputEth = parseFloat(ETH_AMOUNT) * 0.99; 179 | const ethAmount = ethers.utils.parseEther(inputEth.toString()); 180 | const trade = new Trade(route, new TokenAmount(weth, ethAmount), TradeType.EXACT_INPUT); 181 | const path = [weth.address, token.address]; 182 | const deadline = Math.floor(Date.now() / 1000) + 60 * 20; 183 | const deadlineHex = ethers.BigNumber.from(deadline.toString()).toHexString(); 184 | 185 | tokensToSell = trade.outputAmount.raw 186 | const amountOutHex = ethers.BigNumber.from(tokensToSell.toString()).toHexString(); 187 | 188 | const ethAmt = parseFloat(ETH_AMOUNT) * 1.2; 189 | const amountInMax = ethers.utils.parseEther(ethAmt.toString()); 190 | const amountInMaxHex = ethers.BigNumber.from(amountInMax.toString()).toHexString(); 191 | 192 | const tx = await uniswap.swapETHForExactTokens( 193 | amountOutHex, 194 | path, 195 | ACCOUNT, 196 | deadlineHex, 197 | { 198 | value: amountInMaxHex, 199 | gasPrice: ethers.BigNumber.from(newGasPrice).toHexString(), 200 | gasLimit: ethers.BigNumber.from(gasLimit).toHexString() 201 | } 202 | ); 203 | console.log('\x1b[1m\x1b[37m[Bot]: Your purchase transaction was: \x1b[1m\x1b[32m', tx.hash, "\x1b[0m"); 204 | } 205 | } 206 | 207 | console.clear() 208 | console.log("\n") 209 | 210 | 211 | console.log(divider) 212 | 213 | run() 214 | -------------------------------------------------------------------------------- /file.txt: -------------------------------------------------------------------------------- 1 | misnomer uppour coiffeurs reddens diplopodic nonsensate pyrexia overclogged grand bedeafening viscidulous judaica brasswork heterologies nonworking dystocia unvulgarise temporale splaying autodidacts mosquitofishes dadap wasandawi revolunteer xiphosura unmeated obturate menilite legatus fetichlike jurare diphtheritis coryphylly railriding miscommunication eddies practised assument interminated cinnamenyl nosehole delimiter olfactible commies nonego dolomitize prau usurers rellyanite dermatic footlicking lammastide reacuaintance coenthrone kolinski cutenesses strainableness sensitizes desponder zapping phalangeridae meeds weierstrassian goujay subvertible snaking nonproductivity purposeful ustulation outbaked aftergame intercommunicator architects hypopnoea stockinged sublessee upchoke servist brotherly sesquioctaval tenderizer rockabilly nonadhesiveness strophic curtalax tetrathionic untransitively alls solicits gastroblennorrhea dermopterous inning piddle dikamalli trailmaking episememe superpolitic protonemal unreleasible paters brachiopodous exhaustlessness uteroperitoneal pyrolyzed nonlugubrious skinheads disulphid insulance pincushions kvas repossessions pyocyanin punstress adiaphoristic pinnotheres enthrill alaskite sanguinometer kapur hysteropexia reexpression hunted anaglyptical deaconal dravida overlavishness avail pseudoroyally virales ecosystems nondeterrent intercorrelation worsens prelibation xw codetermine anaplasis reconnects praepositor mudwort supressed legitimise onward unimmaculately osteoscleroses wisecracking incidently neshly armoric subacademic deracinate chorioidoiritis snakey schoolcraft allotted morphological chemicals deactivated catasterism jeanpaulia efficacy tiercel magistratic diploidies unbrewed whackier mortared mismatched dundee skout epistyles scewing tocherless vectographic hypermorphic hymeneal pastorita bimane toreadors elutor deuterocone milestone misstyled exhausting moquelumnan sphygmia unmanored paganity lotuses avocado reflected sudor misremember ribbonmaker decastere scorn furicane sudder debases palsy crawlers augmenter wadset saltlessness posttetanic entomolegist enkolpion kinematically magnetohydrodynamics alarbus unproper cnibophore thermoremanence fatheaded benthal mataco vibrational blackmail polybasite deaminizing temblor lambsuccory hypoleptically nuque analogues kimonos stibble amasthenic pictography liberticidal icings roofless allotriomorphic diatreme aerological zoosporiferous andesitic hospice mank hadramautian overdedicating rodwood syncarp armaria potmaker harden actability bailments pedal sonica orodiagnosis sergeanty juggling sandlotters palach rollichie subscriptions lymphostasis cowshot nocument sarcosporidiosis lesional concentrator degradations disvelop acronichally fledgier aetomorphae formalins antithermic paintings podothecal humidifies cte bultell sulfamic unsticks expostulating sprinkling uranoscopic endometrium sacrolumbar felicitating uninjurious alcicornium rhinencephalous parroque megacoulomb solarisms telescopiform complicated choleraic tirailleur ennage myokinesis xenomorphosis budget mouchrabieh unanswerable limmu presentationism skittling duoviri swang fluorate rums unsheet eucharistic brainward diffuseness pegasoid frostbit unlifting awakes celibatarian cusping regma macrocephalous thalamencephalon slype decamerous biocoenosis canonicalized colytic zambal macroscelides nonsimilar hovelling upher jejunely hoistaway kogia tsungtu ahepatokla overdomesticated salsuginose isotome ferfet burma unacoustically molar soberness lightens brotherwort corallidae hogtying muras shaikiyeh gynomonoecism poleis footworn didst menaceable unsurmountably sialic rhynchophoran pawnbrokeress cobridgehead tritopatores obcompressed godsends coosify wasphood voet showoffs menace generalist originatively shoeblack kangarooer armscye swanmote leonis cardinalic exhibitor limose rochet lelwel interdict rogued sarabacan micawber tasteably overdescribed wobbling tomcod confabs skey pectoriloquial unconflictingly luminaries mankind kand prostatovesiculectomy authorship smoos typable fallation muckweed guaranies clinopinacoid interfaced allatrate farseer hypermorphism pedalist dragonhood polyglotted recommencing citrines lithest overtrustfulness nonshattering argles patiences gastroscopy superdifficultly steppingstone ruskin surreys nonabjurer midfrontal patissier dromiceius metachronal intercloud unkingdom auguries umbered engraftment smittle tautologously malting noncurativeness underboated subassociation quantivalence pongids gestning goofy nonvituperative marinade accommodate outfoxing bitchiness reacting viperlike factorials unrapturously raggee swordbearer venusians intervalled partnership nightclub hypergenetic pterographical rheotactic commercialism oversilent didactically very paradiastole suboxid depressant unrowelled counterfire unenthralled stymphalian avitaminosis ophthalmodynamometer sigillated idorgan relead unforgetfully ratters participialization ragout clubfist annexable ancestors concrete autarchy overstraining squirrelsstagnate polynemid idiopathical detracts shastraik preaxial coenoecial chievance uncoarseness seminate underpaying limnoplankton effendis antilogistically trined newstand --------------------------------------------------------------------------------