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?

up vote 4 down vote accepted

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.

  • 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? – Brice Faller Aug 14 at 12:16

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

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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