It is not an exact answer of the question. But it helps to prepare the ethereum transaction data EIP-1559.
We can check the hex using the broadcast transaction link provided by etherescan. It returns TxID if the raw data is valid. Otherwise shows error.
for goerlie testnet : https://goerli.etherscan.io/pushTx
Steps to prepare a EIP-1559 transaction using web3j
1.RawTransaction.createTransaction(chainId, nonce, gasLimit, to, value, data, maxPriorityFeePerGas, maxFeePerGas)
2. TransactionEncoder.encode(rawTransaction) // from sept1
3. Hash.sha3(encodedTx) // from step2
4. Sign the hash using private key
5. Convert the sign to Sign.SignatureData
Then Prepare the raw transaction
public String prepareRawTransactionWithSignature(RawTransaction transaction, Sign.SignatureData signatureData) {
// encode signature data
List<RlpType> values = transaction.getTransaction().asRlpValues(signatureData);
RlpList rlpList = new RlpList(values);
byte[] encoded = RlpEncoder.encode(rlpList);
if (!transaction.getType().equals(TransactionType.LEGACY)) {
encoded = ByteBuffer.allocate(encoded.length + 1)
.put(transaction.getType().getRlpType())
.put(encoded)
.array();
}
String serializedTxHex = Numeric.toHexString(encoded);
log.info("Serialized tx {}", serializedTxHex);
return serializedTxHex;
}