Synopsis

In many type scripts, args act as unique identifiers to distinguish cells with the same type script. For example, Type ID generates a unique identifier by hashing the input UTXO's out point. Because UTXO can be spent once, the generated identifier is unique. However, this method does not support user-defined identifiers. This document introduces UniqueTS, a TypeScript design that enforces unique args for other type scripts. Once deployed, UniqueTS will serve as an infrastructure script that other type scripts can leverage it to ensure args uniqueness.

Overview

UniqueTS is based on the the work of Bartoletti2025[^1]. UniqueTS assumes that for a given type script T, all of its args can be sorted and are in the range from min (inclusively) to max (inclusively). UniqueTS will create vacant range cells to cover the unused args in the range [min, max]. Creating the unique args i, T must find the vacant range [a, b] where a <= i <= b and split it into [a, i-1] (if a <= i-1) and [i+1, b] (if i+1 <= b), so the vacant ranges will continue cover the unused args.

[^1]: Bartoletti, M., Marchesin, R., & Zunino, R. (2025). Scalable UTXO Smart Contracts via Fine-Grained Distributed State (No. arXiv:2406.07700). arXiv. https://doi.org/10.48550/arXiv.2406.07700.

For example, for a script T which args is in the range [1, 10], there will be a vacant range cell [1, 10] and there are no args created yet:

[1, 10]

Creation of the args 6 will split the range into [1, 5] and [7, 10]:

[1, 5] 6 [7, 10]

More examples:

After Creating 1:
  1 [2, 5] 6 [7, 10]
After Creating 4:
  1 [2, 3] 4 [5, 5] 6 [7, 10]
After Creating 5:
  1 [2, 3] 4 5 6 [7, 10]
After Reclaiming 1:
  [1, 3] 4 5 6 [7, 10]

Specification

This document will use following conventions:

UniqueTS makes following assumptions:

  1. T must use TypeID as the type: T.type = (TYPE, H(TypeID.type), TID) where TID is the args generated by TypeID.