TokenScript XML Markup elements

Reference of all elements that can be used in a TokenScript.

Using namespace

TokenScript elements are under TokenScript namespace. That means TokenScript XML file's root element must use xmlns to declare the namespace. You can observe how this is done in any one of the examples.

TokenScript file must use a prefix to represent the namesapce.1 In most examples we use "ts:", like ts:token\ or ts:card\.

However, ther are two exceptions:

  1. Elements specific to a blockchhain are defiend in each blockchain's own namespace. For example: ethereum:call\ element. See Namespace of blockchain-specific elements.
  2. We use ASNX for data modeling, and such model is defined in asxn:module\ . Any element inside asnx:module\ is without perfix, such as sequence.
TokenScript Root ElementsUse 
TokenScript ElementsUseUse in
Ethereum-specific ElementsUse 
<token> elementStarts and ends the token specific tokenscript. Can be used as the root element of TokenScript.
tokensA tokens element contains definitions for a list of Tokens. They must all come from the same token issuer as they are signed by the same trust key.
<cards> elementA container of multiple Cards.
cardDeclares a Card, can be token, action or activity cards.Can only be in <cards> element
attributeDefines properties of a token which can be used by other elements.Can be in <token> element or <card> element
originsCan be a root element to define the contract a token uses, but can also be inside attributes to get the source of an attribute, like through an ethereum call.In <token> element, <card> element, or <attribute> element
contractDefines information about the smart contracts to interact with.In <token> element.
asnx:moduleCreates / Defines data objects for TokenScript. 
addressDeclares the address of the token's smart contract. Is usually based inside the contract-tags, but can also be inside the etherem element.Contract, Card
[bytes32](bytes32.md)Define data when interacting with the Ethereum blockchainEthereum
[data](data.md)Declares data, usually used for Ethereum calls, e. G. to declare a receiving address.Card, Attribute, Ethereum
[element](element.md)creates an element for a data module. Usually inside <sequence> tags.Data Module, Sequence
<grouping>How various instances of the same type of token are grouped. 
<item-view>Defines how the wallet must view the token.Card (Token Card)
<label>Labels allow to localize the TokenScript by adding language specific files or names.Attributes / Cards
<mapping>  
<option>  
<plural>Adds the correct designation when there is more than one token.Attributes / Cards
<selection>Selection is a way to categorise token instances. It allows you to select multiple token at once or define an action for them.Attributes / Cards
<sequence>Orders the sequence of elements in a data module. No "ts:" in the tag required.Data Module
<string>Is a simple string.Attributes / Cards
<syntax>  
<token-id>  
<type>  
<uint256>  
<user-entry>  
<value>  
<view>Marks the part which will be visible in the user interface. Is usually inside an Action Card and refers to a CSS and JavaScript file to create the view in HTML.Cards
[ethereum:call](ethereum-call.md)Calls a smart contract, for example fetching the balance.Attributes, Origin
[ethereum:contract](ethereum-transaction.md)Defines the Token's contractContract
[ethereum:event](ethereum-event.md)Enables the wallet to render an attribute with a blockchain eventAttribute, Origin
[ethereum:transaction](ethereum-transaction.md)Usually inside the <transaction> tag. Creates an Ethereum transaction.Card
<ethereum:value>  

1 Actually, only if it contains an ASNX module, thanks to one of the quirkness defined in ASNX RFC4912. Since it's not sure when you will be using such a module, the rule of thumb is always use a prefix.

We make tokens smart

Smart Token Labs is the creator of TokenScript and AlphaWallet two open source solutions for a tokenized future.