Distinct Attribute

Distinct Attributes are used to identify a token.

A distinct attribute is defined by setting distinct to true.
<attribute name="vin" distinct="true">
…
</attribute>

If there is only one distinct attribute in a token, then the number of unique values of this attribute determines how many token instances are there.

If there is no distinct attribute defined in a Token, TokenScript Engine takes a default value ownerAddress=${ownerAddress} as its Token Identifier.

A Car Ownership Token

In this example, which is part of a TokenScript that defines a Car Ownership Toke. Vehicle Identification Number ("vin") is an attribute that identifies a car:
  <ts:attribute name="vin" distinct="true">
    <ts:label>
      <ts:string xml:lang="en">Vehicle Identification Number</ts:string>
    </ts:label>
    <ts:origins>
      <ethereum:call function="getCars" contract="CarOwnership"/>
    </ts:origins>
  </ts:attribute>
Since VIN is a distinct token, each distinct values of this attribute is used to create a distinct token. So, let's say that the function getCars() in this example returns an array of two values:
"KL3TA48E9EB541191", "KL3TA48E9EB541192"
Then, the TokenScript engine should interpret that there are 2Car Tokens, identified the following two Token Identifiers:
vin=KL3TA48E9EB541191
vin=KL3TA48E9EB541192

Both are instances of the Car Token. If the TokenScript engine is running in a user's wallet, it would render two distinct cars.

CryptoKitty

The following code defines a distinct attribute called tokenId.
<ts:attribute name="tokenId" distinct="true">
  <ts:type>
    <ts:syntax>1.3.6.1.4.1.1466.115.121.1.40</ts:syntax>
  </ts:type>
  <ts:origins>
    <ethereum:call function="balanceOf" contract="EntryToken">
      <ts:data>
        <ts:uint256 ref="ownerAddress"></ts:uint256>
      </ts:data>
    </ethereum:call>
  </ts:origins>
</ts:attribute>
If the smart contract returns 2 values for it:
  • 0x59a7a9fd49fabd07c0f8566ae4be96fcf20be5e1
  • 0xd915c8AD3241F459a45AdcBBF8af42caA561A154
then the TokenScript engine identifies 2 tokens, each identified with:
  • tokenId=0x59a7a9fd49fabd07c0f8566ae4be96fcf20be5e1
  • tokenId=0xd915c8AD3241F459a45AdcBBF8af42caA561A154

In fact, this attribute can be found in all ERC721 tokens, as ERC721 requires an attribute tokenID to identify a token. However, such a design may not suit other tokens who doesn't benefit from being shoe-horned into ERC721.