Distinct Attribute

If an attribute is distinct, it is used to identify a token.

A distinct attribute is a Token Attribute that has distinct set to true:
<attribute name="balance" distinct="true">

The number of unique values of this attribute is the number of token instances. The TokenScript engine records each value and uses that to identify each token.

If there is no distinct attribute defined, TokenScript takes ownerAddress=${ownerAddress} as its RDN.

Getting Multiple instances of the token defined

The following code defines a distinct attribute called tokenId. 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
<ts:attribute name="tokenId" distinct="true">
    <ethereum:call function="balanceOf" contract="EntryToken">
        <ts:uint256 ref="ownerAddress"></ts:uint256>

You have 1 contract that defines 2 tokens

For example, you can have 2 TokenScript files.

The first has:
<token name="tokenA">
  <attribute name="tokenID" distinct="true">
      <ethereum:call function="getTokenABalance" contract="MyContract" as="uint"/>
The second has:
<token name="tokenB">
  <attribute name="tokenID" distinct="true">
      <ethereum:call function="getTokenBalance" contract="MyContract" as="uint"/>

Although two tokens refer to the same contract "MyContract", and even if they point to the same contract address, a TokenScript engine is able to interpret that there are two tokens.

However, if both TokenScripts has the same distinct attribute from the same origin, it's an error.

A Smart Token identified by a customised attribute

For example, you have one token defined like this:
<token name="car">
  <attribute name="VIN" distinct="true">
      <ethereum:call function="getCars" contract="CarContract"/>

Then, depends on how many values are returned, the TokenScript engine should interpret that there are that many number of Car Tokens, each with a different distinct VIN (Vehicle Identification Number), all of these Car Tokens are instances defined by this single TokenScript file.