⏳Timelines
BitBadges uses timeline-based fields to allow dynamic, time-dependent values for various attributes. This feature enables automatic updates to field values based on the current time, without requiring additional blockchain transactions.
Key Concepts
Time Representation:
Times are represented as UNIX time (milliseconds since the epoch).
Epoch: Midnight at the beginning of January 1, 1970, UTC.
Value Assignment:
Values are assigned to specific time ranges.
No overlapping time ranges are allowed for a single field.
Default Behavior:
If no value is set for the current time, the field assumes an empty/null/default value.
Structure
Timeline-based fields extend the TimelineItem
interface:
Example Timeline Fields
The collection interface includes the following timeline-based fields:
managerTimeline: ManagerTimeline<T>[]
collectionMetadataTimeline: CollectionMetadataTimeline<T>[]
badgeMetadataTimeline: BadgeMetadataTimeline<T>[]
offChainBalancesMetadataTimeline: OffChainBalancesMetadataTimeline<T>[]
customDataTimeline: CustomDataTimeline<T>[]
standardsTimeline: StandardsTimeline<T>[]
isArchivedTimeline: IsArchivedTimeline<T>[]
Example: CollectionMetadataTimeline
Protocol Buffers Definition
Usage Example
In this example:
From time 1 to 10, the collection metadata URI is 'ipfs://abc123'.
From time 11 to 10000000, the collection metadata URI is 'ipfs://xyz456'.
At time 5, the first entry would be used.
At time 20, the second entry would be used.
Practical Application
This feature allows for automatic, time-based updates to collection attributes. For example, you can set a collection's metadata URL to change at specific times:
This setup would automatically switch the metadata URL from example1.com to example2.com on April 1, 2023, without requiring any additional blockchain transactions.
Last updated