Tranfer fail with TokenToETH

0xcd82862a819a9f9C09bd6701d1d84B87831db971
this is the swap contract that i use.

while i call the safeSwapTokenForETH function,even i do it with the same parameter with other success transaction.it also give me a shit failed in python , also bscscan.
here is my python code

#amount is token num i want to swap
#slip should be like this 0.05
async def sell_v2_token(self,Private_key,contract,amount,gas,slip,decimal):
        swap_c = self.client.eth.contract(address=longswap_contract,abi=longswap)
        account = Account().from_key(Private_key)
        path = [AsyncWeb3.to_checksum_address(contract),WBNB]
        deadline = datetime.now() + timedelta(minutes = 20)
        p , d = await self.get_v2_buy_price(contract,WBNB,decimal)
        #p is amount of token of 1 bnb
        print(amount/float(p))
        try:
            txn = await swap_c.functions.safeSwapTokenForETH(
                Pancake_v2,
                path,
                int(amount)*(10**decimal),
                
                int(float(amount)/float(p) *(1-float(slip))*(10**16)),
                int(50),  # Tax, if applicable
                account.address,
                int(deadline.timestamp())
            ).build_transaction({
                'from': account.address,
                'gas': 500000,
                'gasPrice': AsyncWeb3.to_wei(gas, 'gwei'),
                'nonce': await self.client.eth.get_transaction_count(account.address)
            }

        )
            signed_txn = self.client.eth.account.sign_transaction(txn, Private_key)
            
            tx_hash = await self.client.eth.send_raw_transaction(signed_txn.rawTransaction)
            
            tx_receipt = await self.client.eth.wait_for_transaction_receipt(tx_hash)
            if tx_receipt.status == 1:
                print(tx_receipt)
                return True
            else:
                return False
        except Exception as e:
            print(e)
            return e

how they work and i dont work for same function.
i sure that i approve the contract

1 Like