Giter VIP home page Giter VIP logo

Comments (34)

 avatar commented on March 28, 2024

Hi is it possible to somehow snipe specific projects instead of every project out there?

from eattheblocks.

tuxforensics avatar tuxforensics commented on March 28, 2024

from eattheblocks.

agyenes75 avatar agyenes75 commented on March 28, 2024

It is not working. Some console log messages are wrong in syntax, and there are some promise errors too...

from eattheblocks.

ShibaSaur avatar ShibaSaur commented on March 28, 2024

hi @tuxforensics whenever i run node bot.js, i get this error

const ethers = require(‘ethers’);

SyntaxError: Invalid or unexpected token
←[90m at wrapSafe (node:internal/modules/cjs/loader:1024:16)←[39m
←[90m at Module._compile (node:internal/modules/cjs/loader:1072:27)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:973:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:813:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)←[39m
←[90m at node:internal/main/run_main_module:17:47←[39m

from eattheblocks.

ozgurk78 avatar ozgurk78 commented on March 28, 2024

ıt not working ;

const ethers = require(‘ethers’);
SyntaxError: Invalid or unexpected token

from eattheblocks.

kryptokatinai avatar kryptokatinai commented on March 28, 2024

hi @tuxforensics whenever i run node bot.js, i get this error

const ethers = require(‘ethers’);

SyntaxError: Invalid or unexpected token
←[90m at wrapSafe (node:internal/modules/cjs/loader:1024:16)←[39m
←[90m at Module._compile (node:internal/modules/cjs/loader:1072:27)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:973:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:813:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)←[39m
←[90m at node:internal/main/run_main_module:17:47←[39m

You have to install 'ethers' package. Reference here: https://www.npmjs.com/package/ethers

from eattheblocks.

kryptokatinai avatar kryptokatinai commented on March 28, 2024

ıt not working ;

const ethers = require(‘ethers’);
SyntaxError: Invalid or unexpected token

You have to install 'ethers' package. Reference here: https://www.npmjs.com/package/ethers

from eattheblocks.

condor-webdev avatar condor-webdev commented on March 28, 2024

I've found some errors in the code, you forgot the '' in all console.log but I have a problem with one of your const
const privateKey = '';
Should this not be the mnemonic phrase ?

from eattheblocks.

ozgurk78 avatar ozgurk78 commented on March 28, 2024

yess
this must be privatekey, also orginal is mnemonic phrase
const privateKey = '';

from eattheblocks.

condor-webdev avatar condor-webdev commented on March 28, 2024

yess
this must be privatekey, also orginal is mnemonic phrase
const privateKey = '';

Yes finally it's what I've done but still getting an error, the same in that one and the original one.
It comes from Ankr url.
Any good advice what to use for the websocket ?

from eattheblocks.

tuxforensics avatar tuxforensics commented on March 28, 2024

from eattheblocks.

condor-webdev avatar condor-webdev commented on March 28, 2024

I switched to a paid service at https://www.quicknode.com/

On Sun, May 23, 2021 at 12:46 PM Stéphane METZ @.***> wrote: yess this must be privatekey, also orginal is mnemonic phrase const privateKey = ''; Yes finally it's what I've done but still getting an error, the same in that one and the original one. It comes from Ankr url. Any good advice what to use for the websocket ? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#67 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATE52ODHWATK45WQEKKIQMLTPE5RBANCNFSM45HR6ZHA .

Ok I'll give it a try as they have a week trial, thanks

from eattheblocks.

condor-webdev avatar condor-webdev commented on March 28, 2024

I switched to a paid service at https://www.quicknode.com/

On Sun, May 23, 2021 at 12:46 PM Stéphane METZ @.***> wrote: yess this must be privatekey, also orginal is mnemonic phrase const privateKey = ''; Yes finally it's what I've done but still getting an error, the same in that one and the original one. It comes from Ankr url. Any good advice what to use for the websocket ? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#67 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATE52ODHWATK45WQEKKIQMLTPE5RBANCNFSM45HR6ZHA .

Ok I'll give it a try as they have a week trial, thanks

Finally I tried it already but unfortunately the don't have the testnet.
Any idea where to look ?

from eattheblocks.

agyenes75 avatar agyenes75 commented on March 28, 2024

Guys: Ankr is perfectly working. WHen you create the API endpoint, it is asking you either to have a classic or tokenized authentication. Choose tokenized, and you will have no problem with yous ANkr wss endpoint...

from eattheblocks.

tuxforensics avatar tuxforensics commented on March 28, 2024

Guys: Ankr is perfectly working. WHen you create the API endpoint, it is asking you either to have a classic or tokenized authentication. Choose tokenized, and you will have no problem with yous ANkr wss endpoint...

Ankr isn't returning the proper cost from pancake but quicknode just works.

from eattheblocks.

condor-webdev avatar condor-webdev commented on March 28, 2024

Guys: Ankr is perfectly working. WHen you create the API endpoint, it is asking you either to have a classic or tokenized authentication. Choose tokenized, and you will have no problem with yous ANkr wss endpoint...

It's what I have done, did you tested on mainnet or testnet ?
Anyway actually wss is dead

from eattheblocks.

mojobdev avatar mojobdev commented on March 28, 2024

put your wallet address in

put your private key in

put your wss provider in

add bnb and wbnb to your wallet and have fun buying all of the shit coins every 3 secs…

-Mike

const ethers = require(‘ethers’);

const addresses = {

WBNB: ‘0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c’,

BUSD: ‘0xe9e7cea3dedca5984780bafc599bd69add087d56’,

factory: ‘0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73’,

router: ‘0x10ed43c718714eb63d5aa57b78b54704e256024e’,

recipient: ‘’

}

//First address of this mnemonic must have enough BNB to pay for tx fess

const privateKey = ‘’;

const mygasPrice = ethers.utils.parseUnits(‘5’, ‘gwei’);

const provider = new ethers.providers.WebSocketProvider(‘wss://muddy-young-frost.bsc.quiknode.pro/’);

const wallet = new ethers.Wallet(privateKey);

const account = wallet.connect(provider);

const factory = new ethers.Contract(

addresses.factory,

[‘event PairCreated(address indexed token0, address indexed token1, address pair, uint)’],

account

);

const router = new ethers.Contract(

addresses.router,

[

‘function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)’,

‘function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)’

],

account

);

const wbnb = new ethers.Contract(

addresses.WBNB,

[

‘function approve(address spender, uint amount) public returns(bool)’,

],

account

);

console.log(Before Approve);

const valueToapprove = ethers.utils.parseUnits(‘0.1’, ‘ether’);

const init = async () => {

const tx = await wbnb.approve(

router.address,

valueToapprove,

{

gasPrice: mygasPrice,

gasLimit: ‘162445’

}

);

console.log(After Approve);

const receipt = await tx.wait();

console.log(‘Transaction receipt’);

console.log(receipt);

}

factory.on(‘PairCreated’, async (token0, token1, pairAddress) => {

console.log(after factory.on:);

console.log( New pair detected ================= token0: ${token0} token1: ${token1} pairAddress: ${pairAddress} );

//The quote currency needs to be WBNB (we will pay with WBNB)

let tokenIn, tokenOut;

if(token0 === addresses.WBNB) {

tokenIn = token0;

tokenOut = token1;

}

if(token1 == addresses.WBNB) {

tokenIn = token1;

tokenOut = token0;

}

//The quote currency is not WBNB

if(typeof tokenIn === ‘undefined’) {

return;

}

//We buy for 0.1 BNB of the new token

//ethers was originally created for Ethereum, both also work for BSC

//‘ether’ === ‘bnb’ on BSC

console.log(line 87);

const amountIn = ethers.utils.parseUnits(‘0.01’, ‘ether’);

const amounts = await router.getAmountsOut(amountIn, [tokenIn, tokenOut]);

//Our execution price will be a bit different, we need some flexbility

const amountOutMin = amounts[1].sub(amounts[1].div(10));

console.log(line 92);

console.log( Buying new token ================= tokenIn: ${amountIn} ${tokenIn} (WBNB) tokenOut: ${amountOutMin} ${tokenOut} );

console.log(line 101);

const tx = await router.swapExactTokensForTokens(

amountIn,

amountOutMin,

[tokenIn, tokenOut],

addresses.recipient,

Math.floor(Date.now() / 1000) + 60 * 20, // 20 minutes from the current Unix time

{

gasPrice: mygasPrice,

gasLimit: 162445

}

);

console.log(line 117);

const receipt = await tx.wait();

console.log(‘Transaction receipt’);

console.log(receipt);

});

init();

from eattheblocks.

ozgurk78 avatar ozgurk78 commented on March 28, 2024

put your wallet address in
put your private key in
put your wss provider in
add bnb and wbnb to your wallet and have fun buying all of the shit coins every 3 secs…
-Mike
const ethers = require(‘ethers’);
const addresses = {
WBNB: ‘0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c’,
BUSD: ‘0xe9e7cea3dedca5984780bafc599bd69add087d56’,
factory: ‘0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73’,
router: ‘0x10ed43c718714eb63d5aa57b78b54704e256024e’,
recipient: ‘’
}
//First address of this mnemonic must have enough BNB to pay for tx fess
const privateKey = ‘’;
const mygasPrice = ethers.utils.parseUnits(‘5’, ‘gwei’);
const provider = new ethers.providers.WebSocketProvider(‘wss://muddy-young-frost.bsc.quiknode.pro/’);
const wallet = new ethers.Wallet(privateKey);
const account = wallet.connect(provider);
const factory = new ethers.Contract(
addresses.factory,
[‘event PairCreated(address indexed token0, address indexed token1, address pair, uint)’],
account
);
const router = new ethers.Contract(
addresses.router,
[
‘function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)’,
‘function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)’
],
account
);
const wbnb = new ethers.Contract(
addresses.WBNB,
[
‘function approve(address spender, uint amount) public returns(bool)’,
],
account
);
console.log(Before Approve);
const valueToapprove = ethers.utils.parseUnits(‘0.1’, ‘ether’);
const init = async () => {
const tx = await wbnb.approve(
router.address,
valueToapprove,
{
gasPrice: mygasPrice,
gasLimit: ‘162445’
}
);
console.log(After Approve);
const receipt = await tx.wait();
console.log(‘Transaction receipt’);
console.log(receipt);
}
factory.on(‘PairCreated’, async (token0, token1, pairAddress) => {
console.log(after factory.on:);
console.log( New pair detected ================= token0: ${token0} token1: ${token1} pairAddress: ${pairAddress} );
//The quote currency needs to be WBNB (we will pay with WBNB)
let tokenIn, tokenOut;
if(token0 === addresses.WBNB) {
tokenIn = token0;
tokenOut = token1;
}
if(token1 == addresses.WBNB) {
tokenIn = token1;
tokenOut = token0;
}
//The quote currency is not WBNB
if(typeof tokenIn === ‘undefined’) {
return;
}
//We buy for 0.1 BNB of the new token
//ethers was originally created for Ethereum, both also work for BSC
//‘ether’ === ‘bnb’ on BSC
console.log(line 87);
const amountIn = ethers.utils.parseUnits(‘0.01’, ‘ether’);
const amounts = await router.getAmountsOut(amountIn, [tokenIn, tokenOut]);
//Our execution price will be a bit different, we need some flexbility
const amountOutMin = amounts[1].sub(amounts[1].div(10));
console.log(line 92);
console.log( Buying new token ================= tokenIn: ${amountIn} ${tokenIn} (WBNB) tokenOut: ${amountOutMin} ${tokenOut} );
console.log(line 101);
const tx = await router.swapExactTokensForTokens(
amountIn,
amountOutMin,
[tokenIn, tokenOut],
addresses.recipient,
Math.floor(Date.now() / 1000) + 60 * 20, // 20 minutes from the current Unix time
{
gasPrice: mygasPrice,
gasLimit: 162445
}
);
console.log(line 117);
const receipt = await tx.wait();
console.log(‘Transaction receipt’);
console.log(receipt);
});
init();

But : I have this error :

[‘event PairCreated(address indexed token0, address indexed token1, address pair, uint)’],

SyntaxError: Invalid or 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

from eattheblocks.

Tomix3D avatar Tomix3D commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

from eattheblocks.

vlbhtcno1 avatar vlbhtcno1 commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

from eattheblocks.

Tomix3D avatar Tomix3D commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks!

from eattheblocks.

vlbhtcno1 avatar vlbhtcno1 commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks!

gas limit is the maximum gas you ready to pay. It's not mean that every transaction takes 500.000.
btw, can you send me the script buying tokens?
My email: [email protected]
Thanks

from eattheblocks.

vlbhtcno1 avatar vlbhtcno1 commented on March 28, 2024

Following your code, I got the issue
UnhandledPromiseRejectionWarning: Error: insufficient funds for intrinsic transaction cost
maybe the issue come from the gasPrice and gasLimit as well

from eattheblocks.

Tomix3D avatar Tomix3D commented on March 28, 2024

And is there a way how to predict gas used for tx?

My code is here btw: ethers-io/ethers.js#1635

from eattheblocks.

geoffsmiths avatar geoffsmiths commented on March 28, 2024

Hi, do you also know how to sell tokens that is bought in nodejs?

from eattheblocks.

geoffsmiths avatar geoffsmiths commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks!

The optimal setting would be 400.000 and 6 wei.

Could you please share the script for selling? I am able to buy, but not to sell

Thanks in advance!

from eattheblocks.

vlbhtcno1 avatar vlbhtcno1 commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks!

The optimal setting would be 400.000 and 6 wei.

Could you please share the script for selling? I am able to buy, but not to sell

Thanks in advance!

Maybe you need 2 changes.

  1. Change the approved address from WBNB to your token which you want to sell
  2. Change the index of token in swapExactTokensForTokens. For buying a token, the index is [WBNB, token address], for selling maybe it's [tokenaddress,WBNB].

I'm not sure that my solution will work or not. But from the view of a developer, I think it work.

from eattheblocks.

geoffsmiths avatar geoffsmiths commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks!

The optimal setting would be 400.000 and 6 wei.
Could you please share the script for selling? I am able to buy, but not to sell
Thanks in advance!

Maybe you need 2 changes.

1. Change the approved address from WBNB to your token which you want to sell

2. Change the index of token in **swapExactTokensForTokens**. For buying a token, the index is [WBNB, token address], for selling maybe it's [tokenaddress,WBNB].

I'm not sure that my solution will work or not. But from the view of a developer, I think it work.

Hey, thanks for your reply!

I will try that. But my major concern is that not all tokens have the same amount of decimals. WBNB has 18, safemoon for example has 9 decimals. Slippage would be 12% or more in this case but my script does not work.

from eattheblocks.

vlbhtcno1 avatar vlbhtcno1 commented on March 28, 2024

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

Can you give me your source code?

I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks!

The optimal setting would be 400.000 and 6 wei.
Could you please share the script for selling? I am able to buy, but not to sell
Thanks in advance!

Maybe you need 2 changes.

1. Change the approved address from WBNB to your token which you want to sell

2. Change the index of token in **swapExactTokensForTokens**. For buying a token, the index is [WBNB, token address], for selling maybe it's [tokenaddress,WBNB].

I'm not sure that my solution will work or not. But from the view of a developer, I think it work.

Hey, thanks for your reply!

I will try that. But my major concern is that not all tokens have the same amount of decimals. WBNB has 18, safemoon for example has 9 decimals. Slippage would be 12% or more in this case but my script does not work.

Don't have any way to set specific slippage for specific token like SafeMoon. decimal value and slippage must be added manually.

from eattheblocks.

BlockEmpire avatar BlockEmpire commented on March 28, 2024

#67 (comment)

Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails.

hey @Tomix3D can you share you git repo?

from eattheblocks.

Tomix3D avatar Tomix3D commented on March 28, 2024

Hey, sorry I can't.. but my swap code is above.

from eattheblocks.

MatthiasT91 avatar MatthiasT91 commented on March 28, 2024

Anyone else knows why I'm getting this in the console?
"this should not happen"
It's getting stuck after getting approved and I get to see the hash and the transaction comes through but never buys the token. and at the end states that message. "this should not happen". It's not written anywhere in my code. Thanks.

// Approves the transaction and then gives out a receipt check bscscan.com
console.log('After Approve');
const receipt = await tx.wait(); -- Get's stuck here?
console.log('Transaction receipt');
console.log(receipt);
}

from eattheblocks.

HugoMag avatar HugoMag commented on March 28, 2024

Hi,
Can anyone help me on the following?
When I run this code I always get the error "insufficient funds for gas * price + value".
My wallet has 0.2 WBNB and if I tried to do the swap in my Metamask wallet it works so I'm not sure what I'm doing wrong.

Thanks!

from eattheblocks.

SerMojo avatar SerMojo commented on March 28, 2024

Same problem as Matthias.
I've got this message "this should not happen" when calling Approve or swapExactTokensForTokens.
I'm pretty sure all my parameters are ok and in the right unit
(using 6e9 for gasPrice and 30000 for GasLimit).
I just don't get it and it's driving me nuts.
If someone has an idea or can help me on that, thanks in advance!

from eattheblocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.