Time-Windows Exercise

You may start this exercise by working from: https://github.com/corda/corda-training-code/tree/master/050-ref-state

In the previous chapter, you learned about enforcing a time-window to ensure that a transaction is notarized within a range of acceptable times.

Now, how do you use this enforcement of a time-window to make the car sales flow more robust and enforce the expiration date on the sales proposal? What you want to achieve is:

  • The proposal has an expiration date.
  • The buyer can only accept before this date.
  • And the seller can only reject the acceptance after this date.

Try to implement that on your own before looking below.


The way to go is:

  • The SalesProposal defines an expiration date as a point in time in the future.
  • The offer flow adds to the transaction a time-window with an “until” end.
  • On Offer, the contract checks that the expiration date is after this “until” end. If it is not, the buyer is not able to buy.
  • The accept flow adds to the transaction a time-window with an “until” end too.
  • On Accept, the contract checks that the expiration date is after this “until” end.
  • The reject flow adds to the transaction a time-window with a “from” end too.
  • On Reject, the contract checks that the expiration date is before this “from” end.

As you can see:

  • The contract verifies that the time-window is on the right side of the expiration date.
  • The notary verifies that it is signed within the time-window.

The interaction of these 2 attestations in effect enforces the expiration date.

Go ahead and add an expiration date to your project before moving on to the next chapter for an example solution.

Was this page helpful?

Thanks for your feedback!

Submit a ticket

Didn’t find what you are looking for? Sign in or register to submit a support ticket.

Chat with us

Come say hello! Live chat with the R3 developer community on Slack now.

Join the forum

Connect with R3 developers and enthusiasts through our online forum.

We're sorry this page wasn't helpful. Let us know how we can make it better!

Submit a ticket

Didn’t find what you are looking for? Sign in or register to submit a support ticket.

Chat with us

Come say hello! Live chat with the R3 developer community on Slack now.

Join the forum

Connect with R3 developers and enthusiasts through our online forum.