Replies: 41 comments 4 replies
-
Hey @Tomix3D, it looks like in your logic you are not approving before a swap. You have to approve your |
Beta Was this translation helpful? Give feedback.
-
@zemse I'm sending approve request before swap but I also noticed that in approve tx from pancakeswap v2 is amount set to I'm trying to sell ECOIN tokens (0x4cbdfad03b968bf43449d0908f319ae4a5a33371) so I changed I am just a beginner and I will be grateful for any help.. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Right now after I changed my gasLimit I successfully sold my tokens! Thank you @zemse !!! Is there any way how to specify gasLimit for all tokens? Would it be okay to set it to 1M instead of 210,000? Thanks. |
Beta Was this translation helpful? Give feedback.
-
I see you are trying to sell tokens, the token contract is not verified and it is likely that they have a require statement there which prevents you from selling. (That's what scam tokens do). I want to know who told you to do this bot? Is there any course? Because seems someone is clearly scamming a lot of people who are following that course/tutorial. |
Beta Was this translation helpful? Give feedback.
-
How can I set this infinite approve? It was just random coin for testing buy/sell requests... and it was my idea to create this bot. |
Beta Was this translation helpful? Give feedback.
-
Hello, Can you copy your source code after resolving the issue? |
Beta Was this translation helpful? Give feedback.
-
What kind of gaslimit did you change to? |
Beta Was this translation helpful? Give feedback.
-
I changed gasLimit: parseInt(reqUrl.searchParams.get('gasLimit')).. I was sending 210,000 gas limit and I changed it to 310,000. And also I changed 'ether' in ethers.utils.parseUnits to 18 for WBNB token and 9 to other tokens. |
Beta Was this translation helpful? Give feedback.
-
Clear for the first point. but I don't really understand the second point. What are 18 and 9? |
Beta Was this translation helpful? Give feedback.
-
18 and 9 are decimals of tokens. WBNB has 19 decimals and other tokens are using 9 decimals. |
Beta Was this translation helpful? Give feedback.
-
so that mean you change your gasLimit to ethers.utils.parseUnits('0.01', 18); instead of ethers.utils.parseUnits('0.01', 'ether'); ? |
Beta Was this translation helpful? Give feedback.
-
Please give the code you changes, and where you apply it to the code as well |
Beta Was this translation helpful? Give feedback.
-
Wbnb has 19 decimals? Do you mean 18? |
Beta Was this translation helpful? Give feedback.
-
Yes, I mean 18. Sorry. |
Beta Was this translation helpful? Give feedback.
-
But notice that some of tokens are having also 18 decimals ... so send correct number. |
Beta Was this translation helpful? Give feedback.
-
I could send you a working script that buys and sells for you, only for 1 BNB. I can give some guidance 😀 |
Beta Was this translation helpful? Give feedback.
-
If I can't figure this out haha I just might take you up on that. I have tried some others like this "swapExactTokensForETHSupportingFeeOnTransferTokens" with no luck haha. Still trying to figure this out haha |
Beta Was this translation helpful? Give feedback.
-
Lol, what are the params for "swapExactTokensForETHSupportingFeeOnTransferTokens" that you pass? |
Beta Was this translation helpful? Give feedback.
-
By the wat, the token in has only 15 zero's... BNB and WBNB uses 18 decimals, so... |
Beta Was this translation helpful? Give feedback.
-
Haha for real though haha I know a bit of node.js this is something different haha. I am passing these through my function "function swapExactTokensForETHSupportingFeeOnTransferTokens( |
Beta Was this translation helpful? Give feedback.
-
I'm trying to figure that one out haha I have this for the decimals in place. Not really sure how to change that " |
Beta Was this translation helpful? Give feedback.
-
I have changed it to 18 : 9 also with no luck |
Beta Was this translation helpful? Give feedback.
-
const testTx = async () => { That is what i am running |
Beta Was this translation helpful? Give feedback.
-
Appreciate your help also Geoff! |
Beta Was this translation helpful? Give feedback.
-
Well, the steps are as follows:
Have you added "swapExactTokensForETHSupportingFeeOnTransferTokens" to the ABI interface before calling this one? Maybe send the entire script to me by email or pm. I Will debug for you. But don't forget me if you make profit, alright? |
Beta Was this translation helpful? Give feedback.
-
What's your email? An for sure if you can help me out I totally would send you some no doubt brotha! |
Beta Was this translation helpful? Give feedback.
-
I just want to be able to grasp it a little more so I know fully what's going on haha so definitely help me and I'll help you. |
Beta Was this translation helpful? Give feedback.
-
Allright bro 😀, You can send to geoffsmiths1981@gmail.com. Let's help eachother. 🤘 |
Beta Was this translation helpful? Give feedback.
-
This seems like an API issue, not an ethers issue, but it may be useful for future developers, so I'm moving it to the discussions. Thanks! :) |
Beta Was this translation helpful? Give feedback.
-
Not sure if this will help. But I've made a functional buy/sell bot and here is what my process: (it could be extremely slapstick, I dont know but it works) So to sell, first you have to get token balance and decimal. Once you have the balance, you have to make sure that there are at least decimal + 1 digits. Because if you own a token and your balance of that token is for ex: 0.00356691... what you will get back from getbalance is 356691... to circumvent this I made this function:
your true balance after calling this function can be obtained by doing this: Once you get the number back which in this example will be 000356691.... you can use that as your input to getamountsout. if you want to adjust that number , this is the process I use. Get the balance and then before you pass the value into the make_true function, you treat your balance as an int and do your operations on that number. After you are done with your operation do:
Then you can pass final_value into getamountsout. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! I'm trying to buy and sell tokens on pancakeswap v2. I'm buying tokens with WBNB and it's working correctly.. but when I try to sell my tokens (so my tokenOut is WBNB) transaction fails.
My code and output..
Sending parameters are:
slippageTolerance => 10
gasPrice => 5
gasLimit => 210000
`
const http = require('http');
const ethers = require('ethers');
http.createServer(function (req, res) {
const baseURL = req.protocol + '://' + req.headers.host + '/';
const reqUrl = new URL(req.url,baseURL);
');
}).listen(3030);`
`
tokenIn: 250296617395320000000000000 0x4cbdfad03b968bf43449d0908f319ae4a5a33371
tokenOut: 761663233022492496404 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c
line 115
(node:1) UnhandledPromiseRejectionWarning: Error: transaction failed (transactionHash="0x78225d5214194dd0683b2cff32e2b57c37a3c4ae39b39f42f49db802be60b190", transaction={"nonce":85,"gasPrice":{"type":"BigNumber","hex":"0x012a05f200"},"gasLimit":{"type":"BigNumber","hex":"0x03d090"},"to":"0x10ED43C718714eb63d5aA57B78B54704E256024E","value":{"type":"BigNumber","hex":"0x00"},"data":"0x38ed1739000000000000000000000000000000000000000000cf0a5ed139d9491f9f80000000000000000000000000000000000000000000000000294a3362f81d3d521400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000082084929560e3c274373e5cdcd9a5dbbf8c3b1cd0000000000000000000000000000000000000000000000000000000060b5017d00000000000000000000000000000000000000000000000000000000000000020000000000000000000000004cbdfad03b968bf43449d0908f319ae4a5a33371000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c","chainId":56,"v":147,"r":"0x2427f352d2299477db485ad812d7d47957643489d127e93eeee9ba35e79367ac","s":"0x47b27ad4973c5c339d4ecac9f19e343f2491d8bb22e2dd3cfaf3b9bd03417bb4","from":"0x82084929560E3C274373e5CdCD9A5DBbf8C3b1cD","hash":"0x78225d5214194dd0683b2cff32e2b57c37a3c4ae39b39f42f49db802be60b190","type":null}, receipt={"to":"0x10ED43C718714eb63d5aA57B78B54704E256024E","from":"0x82084929560E3C274373e5CdCD9A5DBbf8C3b1cD","contractAddress":null,"transactionIndex":144,"gasUsed":{"type":"BigNumber","hex":"0xde07"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x0a138a74834c6802e0dd3b3ecfcef62d5b206a6d6a5bd5d78c26b2e0ad878d55","transactionHash":"0x78225d5214194dd0683b2cff32e2b57c37a3c4ae39b39f42f49db802be60b190","logs":[],"blockNumber":7891530,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x015737ed"},"status":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.2.0)
at Logger.makeError (/app/node_modules/@ethersproject/logger/lib/index.js:187:21)
at Logger.throwError (/app/node_modules/@ethersproject/logger/lib/index.js:196:20)
at JsonRpcProvider. (/app/node_modules/@ethersproject/providers/lib/base-provider.js:1301:36)
at step (/app/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
at Object.next (/app/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
at fulfilled (/app/node_modules/@ethersproject/providers/lib/base-provider.js:20:58)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag '--unhandled-rejections=strict' (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`
Beta Was this translation helpful? Give feedback.
All reactions