Enforce an expiration date
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:
SalesProposaldefines 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.
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.
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.
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.
Get 3 months access to the authors and experts who created this training.
- Expert instructors will review your code and help you to refine it.
- One-on-one support and mentoring from expert instructors.
- Collaboration with fellow students in a dedicated Training Slack channel.