Define attributes so that token data becomes available to Cards and Websites.

In TokenScript you can declare “attributes”. These are properties of the token. They can be pulled from the blockchain or declared on your own will. Due to attributes TokenScript enables a data-driven and event-driven approach to token management in a wallet.

TokenScript does not define or assume any specific token attributes, however any token must have at least one attribute.

The most commonly used attribute is "balance" as defined in ERC20. Let's take another more complex example: For a token representing a ticket for a soccer match, its attributes should contain the information when and where the match happens, which teams play, which seat is reserved and so on.

Attributes are declared in TokenScript. The following is a minimalist declaration, where an attribute "balance" is defined. The value originates from an Ethereum function call balanceOf.

    <ts:attribute name="balance">
            <ethereum:call function="balanceOf" as="uint">
                <ts:data><ts:address ref="ownerAddress"/></ts:data>

Another example of an Attribute declaration declares the locality of a soccer match in the TokenScript for an entry token:

 <ts:attribute name="locality">
          <ethereum:call function="getLocality" contract="EntryToken" as="utf8">
                  <ts:uint256 ref="tokenId"/>
An token attribute is defined, so that the TokenScript engine knows how to get its value when needed. For example, an Action Card of an ENS TokenScript renews the ENS domain and uses the attribute ensName, which was declared in the XML file:
constructor(tokenInstance) {
        this.props = tokenInstance;
        this.props.baseNode = ".eth";
        this.props.fullName = this.props.ensName + this.props.baseNode;

Once defined, the attribute is available to all of the Card defined for this token in the same TokenScript file without special permissions. It also became available in the The Token Layer to allow functionalities like:

  • Token Negotiation
  • Search / index of a token (e.g. in a market place)
  • Selection
  • Describe criteria of actions
  • Set the role of a token

An token's attribute is a data object.

Attributes are just declarations. They are never directly shown to a wallet. They are just here to let the wallet know and to allow TokenScript to build further operations and representations on it. To make them visible you need cards.

Attribute is a categorical declaration. There are other declarations inside the <attribute> tags, for example <origins> or <token>.

If you want TokenScript to querry an API for information, like weather or exchange prices, this will not be part of the attribute tag, but part of an action card.