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:
- Elements specific to a blockchhain are defiend in each blockchain's own namespace. For example: <ethereum:call> element. See Namespace of blockchain-specific elements.
- 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 Elements | Use | |
---|---|---|
<token> element | Starts and ends the token specific tokenscript. Can be used as the root element of TokenScript. | |
tokens | A 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> element | A container of multiple Cards. | |
TokenScript Elements | Use | Use in |
card | Declares a Card, can be token, action or activity cards. | Can only be in <cards> element |
attribute | Defines properties of a token which can be used by other elements. | Can be in <token> element or <card> element |
origins | Can 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 |
contract | Defines information about the smart contracts to interact with. | In <token> element. |
asnx:module | Creates / Defines data objects for TokenScript. | |
address | Declares 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 |
Define data when interacting with the Ethereum blockchain | Ethereum |
data |
Declares data, usually used for Ethereum calls, e. G. to declare a receiving address. | Card, Attribute, Ethereum |
element |
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-specific Elements | Use | |
ethereum:call |
Calls a smart contract, for example fetching the balance. | Attributes, Origin |
ethereum:contract |
Defines the Token's contract | Contract |
ethereum:event |
Enables the wallet to render an attribute with a blockchain event | Attribute, Origin |
ethereum:transaction |
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.