I need to sign two different transactions:
token_contract = web3.eth.contract(address=web3.to_checksum_address(TOKEN_ADDRESS), abi=json.loads(erc20_abi))
approve_trx = token_contract.functions.approve(getenv("ROUTER_ADDRESS"), my_out).build_transaction({
'nonce': web3.eth.get_transaction_count(wallet.address),
'from': wallet.address,
'maxFeePerGas': int(victim_trx["maxFeePerGas"]trx["maxFeePerGas"], 16) + web3.to_wei(getenv("BRIBE_GWEI"), "gwei") if "maxFeePerGas" in victim_trxtrx else web3.to_wei(getenv("BRIBE_GWEI"), "gwei"),
'maxPriorityFeePerGas': int(victim_trx["maxPriorityFeePerGas"]trx["maxPriorityFeePerGas"], 16) + web3.to_wei(getenv("BRIBE_GWEI"), "gwei") if "maxPriorityFeePerGas" in victim_trxtrx else web3.to_wei(getenv("BRIBE_GWEI"), "gwei")
})
and
sell_trx = router_contract.functions.swapExactTokensForETH(my_out, 0, [TOKEN_ADDR, WETH_ADDR], wallet.address, int(time.time()) + 30).build_transaction({
'nonce': web3.eth.get_transaction_count(wallet.address),
'from': wallet.address,
'maxFeePerGas': int(victim_trx["maxFeePerGas"]trx["maxFeePerGas"], 16) + web3.to_wei(getenv("BRIBE_GWEI"), "gwei") if "maxFeePerGas" in victim_trxtrx else web3.to_wei(getenv("BRIBE_GWEI"), "gwei"),
'maxPriorityFeePerGas': int(victim_trx["maxPriorityFeePerGas"]trx["maxPriorityFeePerGas"], 16) + web3.to_wei(getenv("BRIBE_GWEI"), "gwei") if "maxPriorityFeePerGas" in victim_trxtrx else web3.to_wei(getenv("BRIBE_GWEI"), "gwei")
})
and then I want to sign them with:
signed_approve = web3.eth.account.sign_transaction(approve_trx, getenv("PRIV_KEY"))
signed_sell = web3.eth.account.sign_transaction(sell_trx, getenv("PRIV_KEY"))
However, build_transaction of the sell trx raises the error: execution reverted: TransferHelper: TRANSFER_FROM_FAILED
This is correct since I did not sent the first transaction yet, but is there a way to sing both instead of send the approve and wait for it?