Create an account using the Java SDK

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

What version should be used for this type of linux?

Use Debian 12.6 bookworm
Debian “bookworm”

We want to divide the transfer operation into two steps. The first step is to calculate the hash offline, and the second step is to upload the signed information to the chain. Is this possible? I currently see that the implementation of the SDK is as follows, but it is directly uploaded to the chain after execution. We can only obtain the transaction hash after it is uploaded to the chain.

TransferWithMemoTransaction tx = TransactionFactory.newTransferWithMemo()
        .memo(Memo.from(new byte[]{1, 2, 3, 4, 5}))
        .receiver(AccountAddress.from(""))
        .amount(amount)
        .sender(AccountAddress.from(""))
        .nonce(nonce)
        .expiry(expiry)
        .signer(TransactionSigner.from(
                SignerEntry.from(Index.from(0), Index.from(0),
                        ED25519SecretKey.from("")),
                SignerEntry.from(Index.from(0), Index.from(1),
                        ED25519SecretKey.from(""))
        ))
        .build();

A hash of a built transaction, or any other BlockItem, can be obtained in the following way:

Hash.from(SHA256.hash(tx.getBytes())).asHex()

What I mean is that after the above code is executed, the transaction has been put on the chain. I want to get the transaction hash before signing with the private key, not after, because we have a separate signature machine service, which is fully offline.

Calculate the transaction hash value before the transaction is on the chain. This is what I want

Or the steps of signing and broadcasting can be divided into two steps, which means that after signing, the data is not uploaded to the chain, and the transaction can only be submitted to the chain through another broadcast interface.

It can’t be. TransactionFactory only construct transactions. What broadcasts a built transaction is ClientV2.sendTransaction(), please check if you make this call somewhere below.

By just building a transaction with TransactionFactory and calculating its hash as I suggested, you’ll know the hash before submitting the transaction.

As @oleg-android says, building the transaction does not submit it to chain. Once you have built the transaction, you can call tx.getHash() to get the Hash. It is not possible to compute the hash before the transaction is signed, because the transaction hash is derived from the entire transaction, including the signature.

Okay, I just tested it, and it does work.