I am getting the following Exception while performing send transaction using the Java Stellar SDK.

This is my send transaction code:

import org.stellar.sdk.AssetTypeNative;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Memo;
import org.stellar.sdk.Network;
import org.stellar.sdk.PaymentOperation;
import org.stellar.sdk.Server;

import org.stellar.sdk.Transaction;
import org.stellar.sdk.responses.AccountResponse;
import org.stellar.sdk.responses.SubmitTransactionResponse;

public class sendTransaction {
    public static void main(String args[]) {
            Server server = new Server("https://horizon-testnet.stellar.org");

            KeyPair source = KeyPair.fromSecretSeed("SXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            KeyPair destination = KeyPair.fromAccountId("GXXXXXXXXXXXXXXXXXXXXXXXXX");

            try {
            catch(Exception e) {

            AccountResponse sourceAccount;
            try {
                sourceAccount = server.accounts().account(source);
            } catch (Exception e) {

            Transaction transaction = new Transaction.Builder(sourceAccount)
                    .addOperation(new PaymentOperation.Builder(destination, new AssetTypeNative(), "10").build())
            // Sign the transaction to prove you are actually the person sending it.


            // And finally, send it off to Stellar!
            try {
              SubmitTransactionResponse response = server.submitTransaction(transaction);
            } catch (Exception e) {
              System.out.println("Something went wrong!");


I am getting exception:

Exception in thread "main" java.lang.RuntimeException: TimeBounds has to be set or you must call setTimeout(TIMEOUT_INFINITE).
    at org.stellar.sdk.Transaction$Builder.build(Transaction.java:385)
    at com.apiservice.controller.sendTransaction.main(sendTransaction.java:45)

Here's my pom.xml






  • I'm no java-sdk expert but assume you have to new Transaction.Builder().setTimeout(60).[...].build()
    – sui
    Apr 15, 2019 at 7:29
  • The version of the SDK you're using is 1 year old. Please upgrade to 0.6.0, or whatever is the latest at time of reading at github.com/stellar/java-stellar-sdk/releases
    – Synesso
    Apr 18, 2019 at 10:24

2 Answers 2


The exception is clear. You need to call


In the builder chain.

  • I would encourage the OP to set a short specific timeout, rather than TIMEOUT_INFINITE (see my answer for rationale). Apr 18, 2019 at 18:31

Timebounds were introduced to the Java SDK in July 2017. The SDKs require you to specify timebounds, because once a transaction is sent to the network, there's no guarantee that (if the network is busy) it will be included in the next ledger. If it doesn't make it for several consecutive ledgers, the transaction is dropped.

From the perspective of the client, this uncertainty is difficult to manage. By providing timebounds, you explicitly indicate the window of validity for the transaction. If enough time has passed and you've exceeded the upper timebound that you provided, then you know that your submitted transaction will never be successful, and you can take appropriate action (e.g. by submitting another one, with the same sequence number).

Most developers will want to set sensible upper timebounds. TIMEOUT_INFINITE is intended to be used rarely. It is helpful for smart contracts or transactions that will execute in the far future.

For completeness: the lower timebound provides a way to indicate that a transaction cannot be valid until a certain time in the future. This is also more rarely used, as it is typically related to smart contracts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.