You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "sell2.py", line 78, in
pancakeswap2_txn = contract.functions.swapExactTokensForETH(
File "/usr/local/lib/python3.8/dist-packages/web3/contract.py", line 1081, in buildTransaction
return build_transaction_for_function(
File "/usr/local/lib/python3.8/dist-packages/web3/contract.py", line 1650, in build_transaction_for_function
prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.8/dist-packages/web3/_utils/transactions.py", line 102, in fill_transaction_defaults
default_val = default_getter(web3, transaction)
File "/usr/local/lib/python3.8/dist-packages/web3/_utils/transactions.py", line 66, in
'gas': lambda web3, tx: web3.eth.estimate_gas(tx),
File "/usr/local/lib/python3.8/dist-packages/web3/eth.py", line 735, in estimate_gas
return self._estimate_gas(transaction, block_identifier)
File "/usr/local/lib/python3.8/dist-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/usr/local/lib/python3.8/dist-packages/web3/manager.py", line 187, in request_blocking
return self.formatted_response(response,
File "/usr/local/lib/python3.8/dist-packages/web3/manager.py", line 167, in formatted_response
apply_error_formatters(error_formatters, response)
File "/usr/local/lib/python3.8/dist-packages/web3/manager.py", line 67, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz/functoolz.pyx", line 667, in cytoolz.functoolz.pipe
File "cytoolz/functoolz.pyx", line 642, in cytoolz.functoolz.c_pipe
File "/usr/local/lib/python3.8/dist-packages/web3/_utils/method_formatters.py", line 569, in raise_solidity_error_on_revert
raise ContractLogicError(response['error']['message'])
web3.exceptions.ContractLogicError: execution reverted: Pancake: K
Can you help me or fix the code?
Thanks
The text was updated successfully, but these errors were encountered:
I have created a loop that decreases the amount until the transaction is successful:
def estimateGas( txn):
try:
gas = web3.eth.estimateGas({
"from": txn['from'],
"to": txn['to'],
"value": txn['value'],
"data": txn['data']})
gas = gas + (gas / 10) # Adding 1/10 from gas to gas!
except:
gas = False
return gas
while True:
pancakeswap2_txn = contract.functions.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmountok,
0,
# Set to 0 or specify min number of tokens - setting to 0 just buys X amount of token at its current price for whatever BNB specified
[tokenToBuy, spend],
my_wallet,
(int(time.time()) + transactionRevertTime)
).buildTransaction({
'from': my_wallet,
'gas': 400000,
'gasPrice': web3.toWei('5','gwei'),
'nonce': nonce,
})
If i try to sell a crypto i see:
996341397394100562
0.996341397394100562
Enter the Contract Address of token you want to sell: 0x4d496efc21754481fe7a9f3f0f758785ade8e1d3
Balance: 9435079356.573655643061248581 SANINU
Enter amount of SANINU you want to sell: 700000
Approved: 0x59a9466c83ab9412cd96614de95937bf8572c3dc6b086c8043eda0e6ab597be9
Swapping 700000 SANINU for BNB
Traceback (most recent call last):
File "sell2.py", line 78, in
pancakeswap2_txn = contract.functions.swapExactTokensForETH(
File "/usr/local/lib/python3.8/dist-packages/web3/contract.py", line 1081, in buildTransaction
return build_transaction_for_function(
File "/usr/local/lib/python3.8/dist-packages/web3/contract.py", line 1650, in build_transaction_for_function
prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/usr/local/lib/python3.8/dist-packages/web3/_utils/transactions.py", line 102, in fill_transaction_defaults
default_val = default_getter(web3, transaction)
File "/usr/local/lib/python3.8/dist-packages/web3/_utils/transactions.py", line 66, in
'gas': lambda web3, tx: web3.eth.estimate_gas(tx),
File "/usr/local/lib/python3.8/dist-packages/web3/eth.py", line 735, in estimate_gas
return self._estimate_gas(transaction, block_identifier)
File "/usr/local/lib/python3.8/dist-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/usr/local/lib/python3.8/dist-packages/web3/manager.py", line 187, in request_blocking
return self.formatted_response(response,
File "/usr/local/lib/python3.8/dist-packages/web3/manager.py", line 167, in formatted_response
apply_error_formatters(error_formatters, response)
File "/usr/local/lib/python3.8/dist-packages/web3/manager.py", line 67, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz/functoolz.pyx", line 667, in cytoolz.functoolz.pipe
File "cytoolz/functoolz.pyx", line 642, in cytoolz.functoolz.c_pipe
File "/usr/local/lib/python3.8/dist-packages/web3/_utils/method_formatters.py", line 569, in raise_solidity_error_on_revert
raise ContractLogicError(response['error']['message'])
web3.exceptions.ContractLogicError: execution reverted: Pancake: K
Can you help me or fix the code?
Thanks
The text was updated successfully, but these errors were encountered: