5

I struggle using the timebounds option for an operation.

Use case : I want a transaction to be executed at a precise time, not before, not after.

I'm doing my tests on the test network. The transaction occured when I don't set a timeBounds, but when I do I get the same result without (except that my tokens aren't sent).

Here's the code I use :

String timeBounds = "1534239756";
TimeBounds timeBoundsT = new TimeBounds(Long.parseLong(timeBounds), 0);

transaction = new Transaction.Builder(sourceAccount)
        .addOperation(new PaymentOperation.Builder(destination,
            new AssetTypeCreditAlphaNum12(assetName, issuer), amount).build())
        .addTimeBounds(timeBoundsT).addMemo(Memo.text("Memo")).build();


// Sign the transaction to prove you are actually the person sending it.
transaction.sign(distributor);

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

Here's my response :

Success!

org.stellar.sdk.responses.SubmitTransactionResponse@3deb2326

Any idea?

3 Answers 3

4

If you'd like a transaction executed at a precise time, you need to submit it at that time.

The unix timestamp 1534239756 is in the past at the time you wrote this question (by about 10 minutes?). I suspect the transaction was successful.

To be certain, you should check the ResultXDR from the result.

response = server.submitTransaction(transaction);
System.out.println(response.getResultXdr());

Inspect that value in the lab.

1
  • So you can't prepar transactions to execute at a certain time? I get "result: [txTooEarly]" when the transaction is done before the timeBounds, which is correct. Is there any possibilities to lock the distributor account until a precise time? Commented Aug 14, 2018 at 12:16
2

Timebounds only tell the system when a transaction should be valid, it does nothing to submit things at a certain time.

0

I'm implementing a service to execute timed transactions at the right time. Have a look here for the testnet version: https://test.artspirit.com/

Let me know if this would solve your usecase.

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.