Skip to content

darakhbharat/TokenScript

 
 

Repository files navigation

TokenScript: Add Rich Functionality To Your Tokens

Bring context, security and cross-platform functionality (iOS, Android and Web) to your favourite tokens with a single file.

TokenScript makes SmartTokens (Credit to Virgil Griffith for coming up with the term). These are like traditional ERC20 or ERC721 tokens, but with extendable structure & signed JavaScript to realise rich functions that DApps struggle to implement, and be traded with flexible, customisable trading rules.

A TokenScript file is made of

  • JavaScript to make Token work in the user's wallet or across multiple apps; and
  • XML data to extract status and value of the token.

In short, it's like a secure front-end for tokens.

Benefits

  • Run your tokens from users wallets as native, modular ‘Mini-DApps'
  • Extend token structure and realise rich functions with a single file
  • Portable across DApps
  • Sync updates at any time
  • Blockchain agnostic
  • Secure Enclave
  • DvP Security
  • Context based programming: User-experience
  • Attestation

tokenscript stack alphawallet dapps

Where can I find examples of already complete TokenScripts that I can use to create my own?

Visit our example Repo here, which is full of complete TokenScripts that run inside our wallet, AlphaWallet.

Working examples:

A really good starting point to generating your own TokenScript

How is TokenScript created and used?

A TokenScript is typically created by the Token's issuer — the team which builds the underlying smart contracts dictating the token's transaction rules.

When used by a User through a user agent (such as a DApp browser), TokenScript visually renders the token and provides trustworthy assembling of transactions related to the token.

When used by a DApp developer, TokenScript allows a DApp to interact with its interface instead of directly accessing smart contracts, so that the DApp can be upgraded independently of all the tokens it supports.

When used by a Market or any other token related service (e.g. an auction or collateralisation), it allows the token to be correctly rendered and signed for use with these services.

What's in a TokenScript file?

TokenScript is an XML dialect. It describes:

  • The functions provided by the token (through smart contract or not)
  • The method to render it on the user's interface
  • The ERCs token behaviour templates it uses
  • The JavaScript needed to construct transactions and render the token.

It also defines how attestations are used to decorate, or convert to, or validate a transaction.

Why TokenScript?

Today, the way tokens are accessed, rendered and transacted are scattered across DApps and Smart Contracts. This limited the use of Tokens.

Typically, all knowledge about rendering a token and constructing a transaction about the token is in a "host" web app. The "host" web app becomes a centre in the token's marketisation and integration, recreating data interoperability, security and availability barrier - precisely the same set of issues that prevented tokenisation before blockchain's invention.

By taking the knowledge of tokens including smart contract interfaces out and put them into a portable TokenScript we allow tokens to be accessible and useful.

The team at AlphaWallet is committed to bringing Web 3.0 via tokenization. Tokenised rights can be traded on the market and integrated across systems, forming a Frictionless Market and allowing Limitless Integration.

Why use XML rather than JSON or some other JS format?

It is helpful to think of the TokenScript file as a project file and the canonicalized version as the final distributable, build target.

XML has certain standards and tools that have been built over time that helps us here:

  1. XML canonicalization (c14n) which specifies and provides a portable way to represent an XML file under transmission in an always identical format.

  2. XML digital Signatures which is based on signing canonicalized XMLs.

  3. XML allows developers to list and describe attributes and actions/transactions declaratively. While it's possible to do it with JSON, it would likely involve listing them in dictionary and string literals that are harder to enforce schema, validation and track schema changes.

  4. standardized static types, with XML we can easily enforce ASN.1 variable encodings to ensure the variable is as defined.

Used together, we can ensure that a given signed, canonicalized TokenScript file has not been tampered with. Without using XML, these crucial properties of XML have to be reinvented and made available.

Ultimately, if we look at the TokenScript XML file as a project file, we can foresee that in the future, we might build tools to manage them instead of relying on editing the XML file directly, then how the file is itself being editable ceases to be that important and integrity of the file becomes more important.

TokenScript Project introduction

The TokenScript project is an initiative to design, progress TokenScript development and incentivise use.

Git repo

This project holds: doc : documents about the language and the design schema : XML schema files which define the syntax for TokenScripts

Join the conversation or contribute

Looking for support, have feedback or questions? We'd love to hear your thoughts and see what you come up with.

Please join the conversation at Telegram, Twitter or through our community forums.

Donation Address ETH: 0xdeadd42a3ab7d14626a98eadebd26ae8c81b07e4

Want to support the TokenScript team? A cup of coffee or beer is always appreciated! ☕

Contributors

Thank you to all the contributors! You are awesome.


Weiwu Zhang

💻

James Sangalli

💻

theBergmann

💻

Hwee-Boon Yar

💻

Victor Zhang

💻

maxliu

💻

James Brown

💻

Rosalie

💻

James Zaki

💻

Farrah Fazirah

💻

Laurence

💻

Lucas Toledo

💻

License

TokenScript is available under the MIT license. Free for commercial and non-commercial use.

About

TokenScript schema, specs and paper

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 47.2%
  • Solidity 19.9%
  • Java 11.9%
  • JavaScript 7.7%
  • CSS 7.3%
  • Makefile 6.0%