jklepatch / eattheblocks

Source code for Eat The Blocks, a screencast for Ethereum Dapp Developers

Home Page:https://eattheblocks.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checking tokens with adresses.BNB

geoffsmiths opened this issue · comments

Bot.js does not executes transactions because of a simple check should be changed in the factory.on() body.

The factory returns token0 and token1 and the WBNB address contains uppercased letters which are different as hardcoded in the adresses.WBNB.

in Bot.js in the body of factory.on() there is a check:

if(token0 === addresses.WBNB)...
if(token1 === addresses.WBNB)...

should be:

if(token0.toUpperCase() === addresses.WBNB.toUpperCase())...
if(token1.toUpperCase() === addresses.WBNB.toUpperCase())...

The === is an explicit check that checks the data, as well as the datatype. But the letter 'a' is not equal to 'A'. If we uppercase all letters, then this issue is fixed.

The reason for this is that when you receive token0 and token1, the WBNB address contains letters that are uppercased and lowercased while adresses.WBNB contains all lowercase letters.

Hope this helps other devs out.

if ı changed ; I had this error ;


C:\Users\ozgur\348-pancakeswap-trading-bot>node bot.js
C:\Users\ozgur\348-pancakeswap-trading-bot\bot.js:59
if(token0.toUpperCase() === addresses.WBNB.toUpperCase() {
^

SyntaxError: Unexpected token '{'
←[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m

You're missing a ')' before the opening bracket '{'

So, the code should result in:

if(token0.toUpperCase() === addresses.WBNB.toUpperCase()) {

ezoic increase your site revenue