forked from SmartTokenLabs/TokenScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataObjects.html
68 lines (67 loc) · 7.85 KB
/
DataObjects.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html
SYSTEM "about:legacy-compat">
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="copyright" content="(C) Copyright 2020"><meta name="DC.rights.owner" content="(C) Copyright 2020"><meta name="DC.type" content="concept"><meta name="description" content="With Data Objects you can add data to a TokenScript. Data objects are in a format that allows efficient signing and onchain storage."><meta name="DC.relation" scheme="URI" content="BasicConcepts.html"><meta name="DC.relation" scheme="URI" content="elements/element.html"><meta name="DC.format" content="HTML5"><meta name="DC.identifier" content="concept_rvn_2lg_nmb"><link rel="stylesheet" type="text/css" href="css/commonltr.css"><link rel="stylesheet" type="text/css" href="css/custom.css"><title>Data Objects</title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab|Lato">
<script type="text/javascript" src="https://alphawallet.com/wp-content/themes/alphawallet/discourse/widget.js"></script>
</head><body id="concept_rvn_2lg_nmb"><header role="banner"><nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
<div class="container">
<a class="navbar-brand" href="/">🆃okenScript</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="/TokenScript.html">Documents</a></li>
<li class="nav-item"><a class="nav-link" href="/guides/Intro.html">Guides</a></li>
<li class="nav-item"><a class="nav-link" href="/specs/Intro.html">Specs</a></li>
<li class="nav-item external"><a class="nav-link" href="">TokenScript community forum</a></li>
<li class="nav-item external"><a class="nav-link" href="/TokenScript.html">AlphaWallet (uses TokenScript)</a></li>
<li class="nav-item external"><a class="nav-link" href="/guides/Intro.html">Github TokenScript</a></li>
<li class="nav-item external"><a class="nav-link" href="/specs/Intro.html">Github TokenScript Examples</a></li>
</ul>
</div>
</div>
</nav></header><div class="container" id="content"><div class="row"><nav role="toc" class="col-lg-3"><ul><li><a href="Tokenization.html">Tokenization and dApps</a></li><li><a href="index.html">Introduction to TokenScript</a></li><li><a href="QuickStart.html">Quick Start (usuable now)</a></li><li><a href="BasicConcepts.html">Basic Concepts</a><ul><li><a href="TokenScript-Component.html">TokenScript File</a></li><li><a href="Attributes.html">Attributes</a></li><li><a href="Card.html">Card</a></li><li class="active"><a href="DataObjects.html">Data Objects</a></li><li><a href="Attestation.html">Attestation</a></li><li><a href="TokenScript-Syntax.html">TokenScript Syntax</a></li><li><a href="MagicLink.html">Magic Link</a></li></ul></li><li><a href="Deploy.html">Deploy TokenScript</a></li><li><a href="features/FeatureImplementation.html">Features implemented</a></li><li><a href="specs/Intro.html">TokenScript Specs</a></li><li><a href="guides/Intro.html">TokenScript Guides</a></li></ul></nav><main role="main" class="col-lg-9"><article role="article" aria-labelledby="ariaid-title1">
<h1 class="title topictitle1" id="ariaid-title1">Data Objects</h1>
<div class="body conbody"><p class="shortdesc">With Data Objects you can add data to a TokenScript. Data objects are in a format
that allows efficient signing and onchain storage.</p>
<p dir="ltr" class="p" id="concept_rvn_2lg_nmb__docs-internal-guid-5821591c-7fff-aba2-b132-ed5627f0c95d">There will be a
lot of cases where you want to integrate data in the TokenScript. This can be some other
file describing a function, an image file for a logo, a signed file to attest identity,
a set of information and much more.</p>
<p dir="ltr" class="p">Data objects are defined by <asnx:module> in TokenScript XML markup.
TokenScript uses DER-encoded data in a modified ASN.1 format, which is also used for SSL
certificates or as X.509 like for the Estonian e-residency.</p>
<p dir="ltr" class="p">Data objects can be stored offchain as a file on the wallet device, or onchain
as part of a smart contract.</p>
<section class="section"><h2 class="title sectiontitle">Data Structure</h2>
<p dir="ltr" class="p" id="concept_rvn_2lg_nmb__docs-internal-guid-9cfcb9e7-7fff-ed55-0a83-60c4178928ef">TokenScript
created its own format for DataObjects, relying on well established technology. The data
is structured in a way that it can be put on the blockchain with low gas costs, but also
used off-chain. It is designed to be interoperable, extensible and longevitable. </p>
<p dir="ltr" class="p">Other than JSON data objects, the data is separated from the scheme. It
consists of pure data. The scheme for the data is transferred offchain. The data is
encoded in a string of bytes, separated by structural bytes according to standard DER
encoding rules. To be used in TokenScript the data is usually written in ASN.X, an XML
scheme language. </p>
<p dir="ltr" class="p">This data structure has several advantages. Compared with a JSON object it
reduces gas cost by more than 50%. As a string of DER-encoded bytes it is useful for
signing, like for an attestation. This data structure has also a better interoperability
than JSON, and it can be easily extended.</p>
</section><section class="section"><h2 class="title sectiontitle">Using Data Objects</h2>
<p dir="ltr" class="p" id="concept_rvn_2lg_nmb__docs-internal-guid-02889378-7fff-5fcb-10e8-53f68e6218f4">Data objects can
be used in multiple ways: They can transport information about the token, like a ticket
number or the date of a soccer match or even a icon or a picture. They can also be the
data to be signed for an attestation to proof identity or ownership. Finally, they can
carry more complex operational information, like a blueprint for smart contract
transactions or a key to interact with a third party API.</p>
<p dir="ltr" class="p">Data objects can be used onchain. They can be part of a smart contract and be
downloaded from a blockchain, for example, to get the data needed to start an
attestation process. However, in most cases the data doesn’t need to be onchain. </p>
<p dir="ltr" class="p">For example, when an event organiser issues thousands of ticket, the tickets
don’t need to be onchain. It is enough when the tickets are data objects ascribed to an
Ethereum address and signed by the issuer. They can be just a data object. However, when
the tickets are sold and transfered, the data objects can be used to create an Ethereum
transaction which proof that the ticket is valid.</p></section>
</div>
<nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="BasicConcepts.html" title="Learn about the basic concepts of TokenScript, which are used for creating a TokenScript.">Basic Concepts</a></div></div><div class="linklist relref"><strong>Related reference</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="elements/element.html" title="In a data module elements are put in a ordered sequence.">Element</a></li></ul></div></nav></article></main></div></div></body></html>