Card
Cards are a fundamental part of TokenScript. They define how the token behaves in the wallet and in web pages. They are the only part of TokenScript which is visible for the user.
- Token Card
- Token Cards determine how the token behaves in the wallet and in web pages: How it appears, how the wallet processes it and what users can do with it. Cards are like little programs which extend the functionality and style of a wallet, tailored for a specific token.
- Action Card
- Action Cards are triggered by user or website to perform actions. It may result in a transaction to be sent to the underlying blockchain, a cryptographic message being signed, or a proof being made.
- Activity Card
- Activity Cards displays activities that have happened or will soon happen.
Token Card and Activity Card often have actions available to them that a user can click and result in the corresponding Action Card being shown.
While other parts of TokenScript are written mostly in XML, cards are built in JavaScript and HTML (WebAssembly support will be supported too). Theses JavaScript and HTML are either embedded or referred to from XML.
An important aspect of cards is that with a TokenScript enabled user-agent, they are not rendered in a website or app (although they may be physically placed there). They are defined in the TokenScript files and executed in a protected environment in the wallet or a TokenScript enabled dapp browser. Like a card in a game, a dApp can play it, but is not able to transform it. In the web 3.0 cards can become an important enabler of privacy and security: They offload operations and information from websites to wallets. They protect the user and reduce the risks of database heists.
Cards allow dApps to use token to interact with wallets in a much more specific and manifold way than a smart contract can do. They are used to display specific icons for a token, to query an API to get accompanying information, to create transactions, to structure the record of past transactions in a meaningful way and much more.
A planned feature of TokenScript is to allow the creation and use of decks, which means a set of cards that can be combined.
Code
In the TokenScript XML file cards are declared by
<ts:cards>
...</ts:cards>