How to create time-bound transactions
This recipe demonstrates how to create transactions that are only valid within a specific time window using the timeb
operation. Time-bound transactions enhance security and control by restricting when transactions can be included
on-chain.
- JS/TS client
Prerequisites
- Node.js
- FT4 client:
npm install @chromia/ft4
- Postchain client:
npm install postchain-client
Demo script
Key Features
This recipe includes examples for:
- Time window validation - Restricting transaction execution to specific time periods
- Offline transaction building - Creating and signing GTX transactions with temporal constraints
- Enhanced security - Preventing replay attacks and ensuring timely execution
- Transaction composition - Combining transfers with time-bound operations
What timeb
does
The timeb
(time bound) operation enforces a temporal condition on transaction validity by requiring that transactions
be included in a block only within a specified time window (in epoch milliseconds). This enhances control, security, and
synchronization of blockchain actions.
This operation requires that the client system's clock is reasonably synchronized with the signer node's clocks. While minor discrepancies of a few seconds are generally acceptable, significant time differences, such as several hours, may cause the operation to fail. This issue often arises from misconfigured system time settings, including incorrect time zones or daylight saving time (DST) adjustments.
All timestamps are expected to be in Coordinated Universal Time (UTC). However, if the system's timezone
configuration is incorrect, it may result in inaccurate UTC values, leading to unexpected validation failures during the
timeb
operation.
Learn more
- FT4 client documentation — covers account management and FT4 operations.
- JavaScript/TypeScript client — covers setup, connection, and usage patterns.
- Generic Transaction Protocol (GTX) — understanding GTX transaction structure.