'Error finding function on smart contract half of the time?
I have a script that buys a token with multiple wallets, shows you a profit stream on the token, and then allows you to sell a set % of the token you have left before going back into the profit stream and repeating the process.
Everything works great 90% of the time, but randomly if I sell 50% of the token and go back into sell again, 1 of the wallets gets an error finding the sell function.
try:
amountToSell = round(walletTokens[address['wallet']] * percent / 100 )
if chainNumber == 43114:
swap = router2.functions.swapExactTokensForAVAXSupportingFeeOnTransferTokens(amountToSell, 1, [contract, BNB], addresses[0]['wallet'], 1000000000000)
else:
swap = router2.functions.swapExactTokensForETHSupportingFeeOnTransferTokens(amountToSell, 1, [contract, BNB], addresses[0]['wallet'], 1000000000000)
tx = swap.buildTransaction({
'gas': config['sell_gaslimit'],
'gasPrice': sellGwei,
'nonce': walletNonce[address['wallet']],
'chainId' : chainNumber
})
signed = web3.eth.account.sign_transaction(tx, address['secret'])
web3.eth.send_raw_transaction(signed.rawTransaction)
sellTransactions.append(signed.hash)
walletNonce[address['wallet']] += 1
except Exception as e: print(e)
This is the error I get. As you can see the first run both wallets sell. Then the 2nd run only 1 of them sells and the position arguments are all correct type.
Total Profit: -0.50%
Total Profit: -0.50%
Total Profit: -0.50%
Selling 50% of tokens
Tokens Sold: 0x1f35b66ee52189274f6680426395a45ec0497941feee382ca2a9cbba69494763
Tokens Sold: 0x1b1c0642496068e1b3421a8829cb76c1fee5616a83c2de21b832a055a0536363
50.0 % Of Tokens Left
Total Profit: -0.50%
Total Profit: -0.50%
Selling 98% of tokens
Could not identify the intended function with name `swapExactTokensForETHSupportingFeeOnTransferTokens`, positional argument(s) of type `(<class 'int'>, <class 'int'>, <class 'list'>, <class 'str'>, <class 'int'>)` and keyword argument(s) of type `{}`.
Found 1 function(s) with the name `swapExactTokensForETHSupportingFeeOnTransferTokens`: ['swapExactTokensForETHSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)']
Function invocation failed due to no matching argument types.
Tokens Sold: 0xf35829cf30a7b86fcb7bee846a3d2d69cd9b5dbef14239938d3f60ec39312298
1.0 % Of Tokens Left
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
