🖋️
Tokenscript
  • Tokenization and dApps
  • TokenScript
    • Introduction to TokenScript
      • The Framework
      • Benefits for Users
      • What can TokenScript Do?
      • DeFi with, and without Tokenscript
      • Tokenscript examples in AlphaWallet
    • Quickstart Tutorial
  • Basic Concepts
    • TokenScript File
    • Attributes
    • Cards
      • Token Card
      • Action Card
      • Activity Card
    • Data Objects
    • Attestation
    • TokenScript Syntax
    • Magic Link
  • Deploy TokenScript
    • Deploy TokenScript
      • Signing a TokenScript
    • Features Implemented
    • TokenScript Specs
      • Encoding Attestation in URI
    • TokenScript Guides
      • Mini-guide: Add a Ropsten token to AlphaWallet
      • Mini-guide: Deploy a token on Ropsten testnet
      • Introduction to Token Negotiation
  • External Links
  • Github
Powered by GitBook
On this page
  • Distinct Attribute
  • A Car Ownership Token
  • CryptoKitty

Was this helpful?

  1. Deploy TokenScript

Features Implemented

This is a matrix that reports the current progress in implementing various TokenScript directives

PreviousSigning a TokenScriptNextTokenScript Specs

Last updated 4 years ago

Was this helpful?

Feature

iOS (AlphaWallet 3.05)

Android (AlphaWallet 3.1.1)

Tokenscript Debugger* (in development)

Distinct Attribute

n/a

n/a

n/a

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.

Note: Each Token is identified by a attribute-value pair where the attribute has to be a distinct attribute. See more in .

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

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"
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.

Then, the TokenScript engine should interpret that there are 2Car Tokens, identified the following two :

Token Identifier
Token Identifier
Token Identifiers