<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Tokenization - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Tokenization - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Thu, 25 Jun 2026 04:44:43 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/tokenization/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Implement Tokenization using JWT and Django Rest Framework ]]>
                </title>
                <description>
                    <![CDATA[ When I was a young girl, we used to have sports competitions like running a hundred meters, relays, swimming, and basketball games.  My strengths were swimming and basketball. I went home with many gifts or, as my school's game master said, a token o... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-jwt-and-django-rest-framework-to-get-tokens/</link>
                <guid isPermaLink="false">66ba555237218559f94f2076</guid>
                
                    <category>
                        <![CDATA[ Django ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JSON Web Tokens ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JWT ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tokenization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Velda Kiara ]]>
                </dc:creator>
                <pubDate>Thu, 23 Feb 2023 15:53:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/Purple-Colorful-Tech-22-YouTube-Channel-Art.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When I was a young girl, we used to have sports competitions like running a hundred meters, relays, swimming, and basketball games. </p>
<p>My strengths were swimming and basketball. I went home with many gifts or, as my school's game master said, a <strong>token of appreciation</strong>.</p>
<p>A token is a secure form used to transmit data between two parties. The medals I got from the competitions hold a lot of value for me, and if I gave them to someone else, they would merely be trinkets.</p>
<p>JavaScript Object Notation (JSON) is a format used to present structured data based on JavaScript syntax. We use it to transmit data in web applications by sending the data from the server to the client's display.</p>
<p>JWT (JSON Web Token) is a form of transmitting a JSON object as information between parties. Let's learn more about what JWTs are and how they work.</p>
<h2 id="heading-the-importance-of-jwts">The Importance of JWTs</h2>
<p>JWTs are important for two main reasons:</p>
<p><strong>Authorization</strong>: in our competitions, we had to present our school identification cards for verification before getting our medals. </p>
<p>Our school IDs acted like log in requests in applications. These requests, in apps, contain a JWT that allows users to get permission to access any resources that are accessible with that token.</p>
<p><strong>Information exchange</strong>: my medals were a badge of honor and a way to get a certificate signed and stamped by our games master for legitimacy. </p>
<p>We use JWTs to exchange information in cases where they are signed – for example using public-private key pairs to make sure that the integrity of the information is not compromised since the payload and header are used to compute signatures.</p>
<h2 id="heading-how-do-jwts-work">How Do JWTs Work?</h2>
<p>A JWT is an authorization token that is included in requests. Here's an example of what one looks like:</p>
<pre><code class="lang-python">eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjczNTI3ODMzLCJpYXQiOjE2NzM1Mjc0MzAsImp0aSI6IjNkMGRkMGZiZjA5ZjRmZWU4MTZmMGQyOTQ5OWU3ZmFmIiwidXNlcl9pZCI6IjFmYTBiMGJkLWY4MmMtNDQzNy1iMmViLTMwOTYzMGZkNzQ2NiJ9.-swqFh4MCecycmodQfO8ZmfsDJ3DqoZBsdNzEWhfzhA
</code></pre>
<p>You can get a JWT through logging in with a username and password. In exchange the server returns an access and refresh token in the form of a JWT. The tokens access resources on the server.</p>
<p>The lifetimes of the access and refresh tokens vary since access tokens last for five minutes or less while the refresh tokens can last for 24 hours. But you can customize the timelines of both types of tokens.</p>
<p>If the access token expires, the client uses the refresh token to summon a new access token from the server. Once the refresh token expires, the user must log in again with their username and password to get a new pair of tokens. </p>
<p>It works this way to prevent damage that can occur when a token is compromised and to prevent unauthorized access.</p>
<h3 id="heading-different-parts-of-a-jwt">Different parts of a JWT</h3>
<p>JWTs hold information in three parts, as you can see in the following code blocks:</p>
<pre><code class="lang-python">header.payload.signature
</code></pre>
<pre><code class="lang-python">header = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9F5
payload = eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQzODI4NDMxLCJqdGkiOiI3ZjU5OTdiNzE1MGQ0NjU3OWRjMmI0OTE2NzA5N2U3YiIsInVsztZXJfaWQiOjF9
signature = Ju70kdcaHKn1Qaz8H42zrOYk0Jx9kIciuhkTn9Xx7vhikY
</code></pre>
<p>The above JWT is encoded using <a target="_blank" href="https://en.wikipedia.org/wiki/Base64">Base64</a>. Once decoded, the information will include something similar to the following parts:</p>
<h4 id="heading-header">Header</h4>
<p>The header contains:</p>
<ul>
<li>type: the specification that the token is a JWT</li>
<li>algorithm: the signing algorithm used to sign said token</li>
</ul>
<p>Algorithms that are used to sign include <a target="_blank" href="https://www.geeksforgeeks.org/rsa-algorithm-cryptography/">RSA</a>, <a target="_blank" href="https://www.geeksforgeeks.org/hmac-algorithm-in-computer-network/">HMAC</a>, or <a target="_blank" href="https://www.n-able.com/blog/sha-256-encryption#:~:text=The%20SHA%2D256%20algorithm%20is,that%20is%20256%20bits%20long.">SHA256</a>. The signatures for the tokens serve two purposes – integrity and authenticity.</p>
<p>An example of a header with the algorithm and type is as shown below:</p>
<pre><code class="lang-python">{
  <span class="hljs-string">"alg"</span>: <span class="hljs-string">"HS256"</span>,
  <span class="hljs-string">"typ"</span>: <span class="hljs-string">"JWT"</span>
}
</code></pre>
<h4 id="heading-payload">Payload</h4>
<p>The payload contains the intended messages which are commonly known as claims and metadata, as well as any other information.</p>
<p>There are three types of claims:</p>
<ol>
<li>Registered claims: they include exp (expiration time), iss (issuer), sub (subject) and aud (audience). They are highly recommended since they provide information on the use and condition of use of the token.</li>
<li>Public claims: these are claims that are unique to avoid collisions with other services that use JWT. </li>
<li>Private claims: these are claims that are used specifically between two parties that understand the meaning and use. Like the example of my medals, my games master and I understood the value.</li>
</ol>
<p>Below is an example of what a payload looks like.</p>
<pre><code class="lang-python">{
  <span class="hljs-string">"token_type"</span>: <span class="hljs-string">"access"</span>,
  <span class="hljs-string">"exp"</span>: <span class="hljs-number">1543828431</span>,
  <span class="hljs-string">"jti"</span>: <span class="hljs-string">"7f5997b7150d46579dc2b49167097e7b"</span>,
  <span class="hljs-string">"user_id"</span>: <span class="hljs-number">4</span>
}
</code></pre>
<ul>
<li><code>token_type</code> is a label that shows what kind of token this is. Case in point, it's an <code>access token</code>.</li>
<li><code>exp</code> stands for expiration. It's the time the token will stop working – in this case the number represents date and time in Unix time.</li>
<li><code>jti</code> stands for <code>JWT ID</code>. It's a unique identifier for this specific token. The ID is used to keep track of which tokens have been used, to prevent use of the same token more than once.</li>
<li><code>user_id</code>:  is an identifier of the user this token belongs to. In this case, the number 4 is the user identification.</li>
</ul>
<h4 id="heading-signature">Signature</h4>
<p>The signature verifies that information is only accessed by authorized people. It is issued by the JWT backend using base64 + payload +SECRET_KEY. </p>
<p>The signature is verified for each request. To validate the signature, you use the SECRET_KEY. Remember the purpose of having it called SECRET_KEY is so that it is secret. </p>
<p>Now let's see how JWTs work in practice with an example.</p>
<h2 id="heading-project-setup">Project Setup</h2>
<p>To illustrate how JWTs work, I will use the <a target="_blank" href="https://django-rest-framework-simplejwt.readthedocs.io/en/latest/">simple JWT</a>, which is a JSON Web Token authentication plugin for Django Rest Framework (DRF). </p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<p>To follow along, you should have some prior knowledge of HTML files and how to set up a Django project. You should also be familiar with what an API (Application Programming Interface) is. </p>
<p>You will also need to have a Django project already setup. You could name it <code>tokenization</code> also add an app called <code>access</code>. </p>
<p>Once your app and project are set up, you are good to go. </p>
<h3 id="heading-simple-jwt-installation">Simple JWT Installation</h3>
<p>As mentioned, I will be using the <code>simple JWT</code> which provides JWT authentication for the Django Rest Framework (DRF).  </p>
<p>DRF is a third-party package for Django used as a toolkit for building Web API's. It provides a seamless experience while you build, test, debug and maintain RESTful APIs using in Django. </p>
<p>RESTful APIs (Representational State Transfer APIs) are a type of web API that allow communication between different applications over the internet in a fast, reliable, and scalable way.</p>
<p>RESTful APIs are stateless. This means that requests contain information to finalize the request, and the server does not need to remember the history of previous requests.</p>
<p>To install <code>simple JWT</code>, use the command below in your terminal:</p>
<pre><code class="lang-python">pip install djangorestframework_simplejwt
</code></pre>
<h3 id="heading-how-to-set-authentication-to-simple-jwt">How to Set Authentication to Simple JWT</h3>
<p>Go to your project (tokenization), and in the <code>settings.py</code> file, add the following code to configure the REST framework to use simple JWT for authentication:</p>
<pre><code class="lang-python">REST_FRAMEWORK = {
    <span class="hljs-string">'DEFAULT_AUTHENTICATION_CLASSES'</span>: [
        <span class="hljs-string">'rest_framework_simplejwt.authentication.JWTAuthentication'</span>,
    ],
}
</code></pre>
<p>The code above specifies the default authentication class to be used for all API views in the application.</p>
<p><code>DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ]</code> sets the default authentication class to be  <code>JWTAuthentication</code> from the <code>rest_framework_simplejwt</code> package. This means that all API views in the project will use JWT authentication by default.</p>
<h3 id="heading-how-to-define-uniform-resource-locator-patterns">How to Define Uniform Resource Locator Patterns</h3>
<p>In your project (tokenization), create a file (if you have not created one yet) named<br><code>urls.py</code> . Then add the following code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.urls <span class="hljs-keyword">import</span> path
<span class="hljs-keyword">from</span> rest_framework_simplejwt <span class="hljs-keyword">import</span> views <span class="hljs-keyword">as</span> jwt_views

urlpatterns = [
    path(<span class="hljs-string">'api/token/'</span>, jwt_views.TokenObtainPairView.as_view(), name=<span class="hljs-string">'token_obtain_pair'</span>),
    path(<span class="hljs-string">'api/token/refresh/'</span>, jwt_views.TokenRefreshView.as_view(), name=<span class="hljs-string">'token_refresh'</span>),
]
</code></pre>
<p>The <code>path</code> function creates a new URL pattern and maps it to the specified view.</p>
<p>The URL (Uniform Resource Locator) path <code>/api/token/</code> is mapped to the view <code>jwt_views.TokenObtainPairView.as_view()</code>. The <code>as_view()</code>method converts the class-based view to a function-based view used in routing. The <code>name</code> parameter makes it easy to refer to the URL pattern in other parts of your code. </p>
<p>We have now created an endpoint for obtaining JWT tokens. If a request is made to the endpoint, <code>TokenObtainPairView</code>, <code>view</code> handles the request and returns a JWT token in the response for authentication.</p>
<h3 id="heading-how-to-customize-the-token-timelines">How to Customize the Token Timelines</h3>
<p>To customize the timeline of the tokens, first add the <code>rest_framework_simplejwt</code> in your installed apps section in the project (tokenization) under the <code>settings.py</code> file. The purpose for adding the <code>rest_framework_simplejwt</code> is for configuration. </p>
<p>To add the timeline we want, we will first create a dictionary called <code>SIMPLE_JWT</code>. Then we'll create variables to hold timelines for the access and refresh token. </p>
<p>The code snippet below shows how to set up the timelines for the tokens:</p>
<pre><code class="lang-python">INSTALLED_APPS = [
    <span class="hljs-comment">#other files</span>
    <span class="hljs-string">'rest_framework_simplejwt'</span>,
]

SIMPLE_JWT = {
    <span class="hljs-string">'ACCESS_TOKEN_LIFETIME'</span>: timedelta(minutes=<span class="hljs-number">5</span>),
    <span class="hljs-string">'REFRESH_TOKEN_LIFETIME'</span>: timedelta(days=<span class="hljs-number">1</span>),
}
</code></pre>
<p>Before you use the <code>timedelta</code> you will need to import it like this: <code>python from datetime import timedelta</code>.</p>
<h3 id="heading-visual-interaction-of-the-api">Visual Interaction of the API</h3>
<p>In this section, we will use the Django Rest Framework web interface to access the endpoints.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-13-at-10.55.14.png" alt="Image" width="600" height="400" loading="lazy">
<em>Testing tokenization</em></p>
<p>The access and refresh tokens are highlighted in red, as shown above. To get the tokens for a user, you need to input the correct password and username for an existing user.</p>
<p> Use a refresh token through this endpoint for an access token: <code>/api/token/refresh/</code> </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-13-at-10.55.53.png" alt="Image" width="600" height="400" loading="lazy">
<em>Refresh token</em></p>
<p>A refresh token gets an access token without the user using their login credentials to extend the user's session. This provides a seamless user experience and improves security by reducing the number of times a user has to key in their credentials.</p>
<h3 id="heading-how-to-add-a-homepage">How to Add a Homepage</h3>
<p>If you want to create a visually appealing interface, you can build a custom homepage to replace the current display of the API endpoints and error messages.</p>
<p>To add a homepage to your Django project, follow these steps:</p>
<ol>
<li>Create a <code>templates</code> folder in your application (access). Then, add a <code>index.html</code> file inside.</li>
<li>Create a <code>static</code> folder in your application (access) and add a <code>img</code> folder inside.</li>
<li>In this case, I wanted to display an image, so I added the <code>me.png</code> in the img folder.</li>
<li>Add the code below to your <code>html</code> file:</li>
</ol>
<pre><code class="lang-html">{% load static %}
<span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
        <span class="hljs-selector-tag">body</span> {
            <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">"{% static 'img/me.png' %}"</span>);
            <span class="hljs-attribute">background-size</span>: cover;
        }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>You will notice that we needed to add <code>{% load static %}</code> at the top of the file for proper styling and functioning of the site. <code>{% load static %}</code> serves files like stylesheets(CSS), scripts(JS), and images to your HTML templates to provide the user with a seamless experience while viewing your site.</p>
<h3 id="heading-how-to-define-the-url-patterns-for-your-home-page">How to Define the URL Patterns For Your Home Page</h3>
<p>In your app's (access) <code>urls.py</code> file (create one if you do not have it) add this:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.urls <span class="hljs-keyword">import</span> path
<span class="hljs-keyword">from</span> django.views.generic <span class="hljs-keyword">import</span> TemplateView

app_name=<span class="hljs-string">'access'</span>

urlpatterns=[
path(<span class="hljs-string">''</span>, TemplateView.as_view(template_name=<span class="hljs-string">'home.html'</span>), name=<span class="hljs-string">'home'</span>),

]
</code></pre>
<p>In your project's (tokenization) <code>settings.py</code> file, add the following code so that the static files are served:</p>
<pre><code class="lang-python"><span class="hljs-comment"># Static files settings</span>
STATIC_ROOT = os.path.join(BASE_DIR, <span class="hljs-string">'static'</span>)
STATIC_URL = <span class="hljs-string">'/static/'</span>
STATICFILES_DIRS = [os.path.join(BASE_DIR, <span class="hljs-string">'access/static'</span>)]
</code></pre>
<p>Once you run the server, your home page should be like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-13-at-10.54.54.png" alt="Image" width="600" height="400" loading="lazy">
<em>home page</em></p>
<h2 id="heading-bugs-and-solutions">Bugs and Solutions</h2>
<p>At some point, I may have deleted the <code>migrations</code> file which deleted some of the data I had. This caused the following error <code>django.db.utils.OperationalError: no such table: customUser</code>. </p>
<p>I was able to solve this through running the command <code>python manage.py migrate --run-syncdb</code> . The command syncs tables by looking into tables not created and then creating them.</p>
<p>I also had an issue of using a port that was already being used by a program I had left running and forgotten about. </p>
<p>To close a port you should identify the process using it by running the command <code>lsof -i :&lt;port_number&gt;</code>. This will show you the user using it and PID. To stop the process use <code>kill &lt;PID&gt;</code>. Additionally, you can use <code>sudo kill -9 -u &lt;username&gt; &lt;pid&gt;</code> .</p>
<p>It's good to know that to kill the port you will need administrator permissions. Also, stopping a process can cause data loss or unusual behavior so ensure your data is backed up before doing this.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>In this tutorial, you have learned how JWTs work, the structure of different tokens, how to use JWT and DRF to get tokens, how to create and serve static files in Django, and how to handle deleting migration files and kill a port.</p>
<p>There is so much you can learn about <a target="_blank" href="https://www.djangoproject.com/">Django</a> and the <a target="_blank" href="https://www.django-rest-framework.org/">Django Rest Framework.</a></p>
<p>The code for this article can be found <a target="_blank" href="https://github.com/VeldaKiara/tokenization">here</a>.</p>
<p>May your keyboard be swift, your bugs be few, and your fun meter be off the charts as you code away!</p>
<p>Thanks for reading my article on how to implement tokenization using JWT and Django Rest Framework. I'm always up for a good chat about coding and tech, so give me a follow on <a target="_blank" href="https://twitter.com/VeldaKiara">Twitter</a> and let's continue the conversation there.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Evolution of Tokenization – Byte Pair Encoding in NLP ]]>
                </title>
                <description>
                    <![CDATA[ Natural Language Processing may have come a little late to the AI game, but companies like Google and OpenAI are working wonders with NLP techniques these days. These companies have released state-of-the-art language models like BERT and GPT-2 and GP... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/evolution-of-tokenization/</link>
                <guid isPermaLink="false">66d45f3d3a8352b6c5a2aa7f</guid>
                
                    <category>
                        <![CDATA[ algorithms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Artificial Intelligence ]]>
                    </category>
                
                    <category>
                        <![CDATA[ natural language processing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ nlp ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tokenization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Harshit Tyagi ]]>
                </dc:creator>
                <pubDate>Tue, 05 Oct 2021 15:26:44 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/10/IMG_0079.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Natural Language Processing may have come a little late to the AI game, but companies like Google and OpenAI are working wonders with NLP techniques these days.</p>
<p>These companies have released state-of-the-art language models like BERT and GPT-2 and GPT-3. And GitHub Copilot and OpenAI codex are among some of the popular applications that are in the news lately.</p>
<p>As someone who has had very limited exposure to NLP, I decided to take it up as an area of research so I can learn more about it. My next few articles and videos will focus on sharing what I learn after dissecting some important components of NLP.</p>
<h3 id="heading-main-components-of-nlp">Main Components of NLP</h3>
<p>NLP systems have three main components that help machines understand natural language:</p>
<ol>
<li><p>Tokenization</p>
</li>
<li><p>Embedding</p>
</li>
<li><p>Model architectures</p>
</li>
</ol>
<p>Top Deep Learning models like BERT, GPT-2, and GPT-3 all share the same components but with different architectures that distinguish one model from another.</p>
<p>In this article (and the <a target="_blank" href="https://colab.research.google.com/drive/1QLlQx_EjlZzBPsuj_ClrEDC0l8G-JuTn?usp=sharing">notebook</a> that accompanies it), we are going to focus on the basics of the first component of an NLP pipeline which is <strong>tokenization</strong>. It's an often overlooked concept, but it is a field of research in itself.</p>
<p>We have come so far from the traditional NLTK tokenization process. And though we have state-of-the-art algorithms for tokenization, it's always a good practice to understand its evolution and how we got to where we are now.</p>
<p>So, here's what we'll cover:</p>
<ul>
<li><p>What is tokenization?</p>
</li>
<li><p>Why do we need a tokenizer?</p>
</li>
<li><p>Types of tokenization – Word, Character, and Subword.</p>
</li>
<li><p>Byte Pair Encoding Algorithm - a version of which is used by most NLP models these days.</p>
</li>
</ul>
<p>The next part of this tutorial will dive into more advanced (or enhanced versions of Byte Pair Encoding) algorithms:</p>
<ul>
<li><p><strong>Unigram Algorithm</strong></p>
</li>
<li><p><strong>WordPiece – BERT transformer</strong></p>
</li>
<li><p><strong>SentencePiece – End-to-End tokenizer system</strong></p>
</li>
</ul>
<h2 id="heading-what-is-tokenization">What is Tokenization?</h2>
<p>Tokenization is the process of representing raw text in smaller units called tokens. These tokens can then be mapped with numbers to further feed to an NLP model.</p>
<p>Here's an overly simplified example of what a tokenizer does:</p>
<pre><code class="lang-javascript">## read the text and enumerate the tokens <span class="hljs-keyword">in</span> the text
text = open(<span class="hljs-string">'example.txt'</span>, <span class="hljs-string">'r'</span>).read(). # read a text file

words = text.split(<span class="hljs-string">" "</span>) # split the text on spaces

tokens = {<span class="hljs-attr">v</span>: k <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> enumerate(words)} # generate a word to index mapping
</code></pre>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaa2e479-181a-4703-afb6-9796d0f74d09_229x327.png" alt="Image" width="229" height="327" loading="lazy"></p>
<p>Here, we have simply mapped every word in the text to a numerical index. This is, of course, a very simple example and we have not considered grammar, punctuation, or compound words (like test, test-ify, test-ing, and so on).</p>
<p>So we need a more technical and accurate definition of tokenization for our work here. To take into account all punctuation and every related word, we need to start working at the character level.</p>
<p>There are multiple applications of tokenization. One of the use cases comes from compiler design where you might need to parse computer programs to convert raw characters into keywords of a programming language.</p>
<p><strong>In deep learning,</strong> tokenization is the process of converting a sequence of characters into a sequence of tokens which further needs to be converted into a sequence of numerical vectors that can be processed by a neural network.</p>
<h2 id="heading-why-do-we-need-a-tokenizer">Why do we need a Tokenizer?</h2>
<p>The need for a tokenizer came from the question "How can we make machines read?"</p>
<p>A common way of processing textual data is to define a set of rules in a dictionary and then look up that fixed dictionary of rules. But this method can only go so far, and we want machines to learn these rules from the text that it reads.</p>
<p>Now, machines don't know any language, nor do they understand sound or phonetics. They need to be taught from scratch and in such a way that they can read any language that's out there.</p>
<p>Quite a task, right?</p>
<p>Humans learn a language by connecting sound to the meaning and then we learn to read and write in that language. Machines can't do that, so they need to be given the most basic units of text to start processing the text.</p>
<p>That's where tokenization comes into play. It breaks down the text into smaller units called "tokens".</p>
<p>And there are different ways of tokenizing text which is what we'll learn now.</p>
<h2 id="heading-different-ways-to-tokenize-text">Different ways to tokenize text</h2>
<p>To make the deep learning model learn from the text, we need a two-step process:</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fff7fafb7-a127-4e41-a050-cb02951f3112_1391x821.jpeg" alt="Image" width="1391" height="821" loading="lazy"></p>
<ol>
<li><p>Tokenize – decide the algorithm we'll use to generate the tokens.</p>
</li>
<li><p>Encode the tokens to vectors</p>
</li>
</ol>
<h2 id="heading-word-based-tokenization">Word-based tokenization</h2>
<p>As the first step suggests, we need to decide how to convert text into small tokens. A simple and straightforward method that most of us would propose is to use word-based tokens, splitting the text by spaces.</p>
<h3 id="heading-problems-with-word-tokenizer">Problems with Word tokenizer</h3>
<p><strong>There's a high risk of missing words in the training data.</strong> With word tokens, your model won't recognize the variants of words that were not part of the data on which the model was trained.</p>
<p>So, if your model has seen <code>foot</code> and <code>ball</code> in the training data but the final text has <code>football</code>, the model won't be able to recognize the word and it will be treated with an <code>&lt;UNK&gt;</code> token.</p>
<p>Similarly, punctuation poses another problem. For example, <code>let</code> or <code>let's</code> will need individual tokens which is an inefficient solution. This will <strong>require a huge vocabulary</strong> to make sure you've thought of every variant of the word.</p>
<p>Even if you add a <strong>lemmatizer</strong> to solve this problem, you're adding an extra step in your processing pipeline.</p>
<p><strong>It's also tough to handle slang and abbreviations.</strong> We use lots of slang and abbreviations in text these days, such as "FOMO", "LOL", "tl;dr" and so on. What do we do for these words?</p>
<p><strong>Finally, what if the language doesn't use spaces for segmentation?</strong> For a language like Chinese, which doesn't use spaces for word separation, this tokenizer will fail completely.</p>
<p>After encountering these problems, researchers looked into another approach which involved tokenizing all the characters.</p>
<h2 id="heading-character-based-tokenization">Character-based tokenization</h2>
<p>To resolve the problems associated with word-based tokenization, data scientists tried an alternative approach of character-by-character tokenization.</p>
<p>This did solve the problem of missing words, as now we are dealing with characters that can be encoded using ASCII or Unicode. Now it could generate embedding for any word.</p>
<p>Every character, whether it was a space, apostrophe, colon, or whatever can now be assigned a symbol to generate a sequence of vectors.</p>
<p>But this approach had its own cons.</p>
<h3 id="heading-problems-with-character-based-models">Problems with character-based models</h3>
<p><strong>First, this approach requires more computing resources.</strong> Character-based models will treat each character as a token. And more tokens means more input computations to process each token which in turn requires more compute resources.</p>
<p>For example, for a 5-word long sentence, you may need to process 30 tokens instead of 5 word-based tokens.</p>
<p><strong>Also, it narrows down the number of NLP tasks and applications.</strong> With long sequences of characters, you can only use a certain type of neural network architecture.</p>
<p>This limits the type of NLP tasks we can perform. For applications like entity recognition or text classification, character-based encoding might turn out to be an inefficient approach.</p>
<p><strong>Finally, there's a risk of learning incorrect semantics.</strong> Working with characters could generate incorrect spellings of words. Also, with no inherent meaning, learning with characters is like learning with no meaningful semantics.</p>
<blockquote>
<p>What's fascinating is that for such a seemingly simple task, multiple algorithms have been written to find the optimal tokenization policy.</p>
</blockquote>
<p>After understanding the pros and cons of these tokenization methods, it makes sense to look for an approach that offers a middle route. We'll want one that preserves the semantics with limited vocabulary that can generate all the words in the text on merging.</p>
<h2 id="heading-subword-tokenization">Subword Tokenization</h2>
<p>With character-based models, we risk losing the semantic features of the word. And with word-based tokenization, we need a very large vocabulary to encompass all the possible variations of every word.</p>
<p>So, the goal was to develop an algorithm that could:</p>
<ol>
<li><p>Retain the semantic features of the token, that is information per token.</p>
</li>
<li><p>Tokenize without demanding a very large vocabulary with a finite set of words.</p>
</li>
</ol>
<p>To solve this problem, you can think of breaking down the words based on a set of prefixes and suffixes. For example, we can write a rule-based system to identify subwords like <code>"##s"</code>, <code>"##ing"</code>, <code>"##ify"</code>, <code>"un##"</code> and so on, where the position of the double hash denotes prefix and suffixes.</p>
<p>So, a word like <code>"unhappily"</code> is tokenized using subwords like <code>"un##"</code>, <code>"happ"</code>, and <code>"##ily"</code>.</p>
<p>The model only learns relatively few subwords and then puts them together to create other words. This solves the problems of memory requirement and effort required to create a large vocabulary.</p>
<h3 id="heading-problems-with-the-subword-tokenization-algorithm">Problems with the subword tokenization algorithm:</h3>
<p>First of all, some of the subwords that are created as per the defined rules may never appear in your text to tokenize and may end up occupying extra memory.</p>
<p>Also, for every language, we'll need to define a different set of rules to create subwords.</p>
<p>To alleviate this problem, in practice, most modern tokenizers have a training phase that identifies the recurring text in the input corpus and creates new subword tokens. For rare patterns, we stick to word-based tokens.</p>
<p>Another important factor that plays a vital role in this process is the size of the vocabulary that the user sets. A large vocabulary size allows for more common words to be tokenized, whereas smaller vocabulary requires more subwords to be created to create every word in the text without using the <code>&lt;UNK&gt;</code> token.</p>
<p>Striking the right balance for your application is key here.</p>
<h2 id="heading-byte-pair-encoding-bpe-algorithm">Byte Pair Encoding (BPE) Algorithm</h2>
<p>BPE was originally a data compression algorithm that you use to find the best way to represent data by identifying the common byte pairs. We now use it in NLP to find the best representation of text using the smallest number of tokens.</p>
<p>Here's how it works:</p>
<ol>
<li><p>Add an identifier (<code>&lt;/w&gt;</code>) at the end of each word to identify the end of a word and then calculate the word frequency in the text.</p>
</li>
<li><p>Split the word into characters and then calculate the character frequency.</p>
</li>
<li><p>From the character tokens, for a predefined number of iterations, count the frequency of the consecutive byte pairs and merge the most frequently occurring byte pairing.</p>
</li>
<li><p>Keep iterating until you have reached the iteration limit (set by you) or until you have reached the token limit.</p>
</li>
</ol>
<p>Let's go through each step (in the code) for some sample text. For coding this, I have taken help from <a target="_blank" href="https://leimao.github.io/blog/Byte-Pair-Encoding/">Lei Mao's very minimalistic blog on BPE</a>. I encourage you to check it out!</p>
<h2 id="heading-step-1-add-word-identifiers-and-calculate-word-frequency">Step 1: Add word identifiers and calculate word frequency</h2>
<p>Here's our sample text:</p>
<pre><code class="lang-javascript"><span class="hljs-string">"There is an 80% chance of rainfall today. We are pretty sure it is going to rain."</span>
</code></pre>
<pre><code class="lang-javascript">## define the text first
</code></pre>
<pre><code class="lang-javascript">text = <span class="hljs-string">"There is an 80% chance of rainfall today. We are pretty sure it is going to rain."</span>
</code></pre>
<pre><code class="lang-javascript">## get the word frequency and add the end <span class="hljs-keyword">of</span> word (&lt;/w&gt;) token ## at the end <span class="hljs-keyword">of</span> each word

words = text.strip().split(<span class="hljs-string">" "</span>)

print(f<span class="hljs-string">"Vocabulary size: {len(words)}"</span>)
</code></pre>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb90e5882-9f1f-4b05-be48-3e9336cf1854_283x392.png" alt="Image" width="283" height="392" loading="lazy"></p>
<h2 id="heading-step-2-split-the-word-into-characters-and-then-calculate-the-character-frequency">Step 2: Split the word into characters and then calculate the character frequency</h2>
<pre><code class="lang-javascript">char_freq_dict = collections.defaultdict(int)
<span class="hljs-keyword">for</span> word, freq <span class="hljs-keyword">in</span> word_freq_dict.items():
    chars = word.split()
    <span class="hljs-keyword">for</span> char <span class="hljs-keyword">in</span> chars:
        char_freq_dict[char] += freq

char_freq_dict
</code></pre>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fecbf93c5-7fd6-4a40-a63d-e504be1bf157_396x536.png" alt="Image" width="396" height="536" loading="lazy"></p>
<h2 id="heading-step-3-merge-the-most-frequently-occurring-consecutive-byte-pairings">Step 3: Merge the most frequently occurring consecutive byte pairings</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> re

## create all possible consecutive pairs
pairs = collections.defaultdict(int)
<span class="hljs-keyword">for</span> word, freq <span class="hljs-keyword">in</span> word_freq_dict.items():
    chars = word.split()
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(chars)<span class="hljs-number">-1</span>):
        pairs[chars[i], chars[i+<span class="hljs-number">1</span>]] += freq
</code></pre>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdaf21979-946b-4dfb-b090-64e591c13907_400x590.png" alt="Image" width="400" height="590" loading="lazy"></p>
<h2 id="heading-step-4-iterate-n-times-to-find-the-best-in-terms-of-frequency-pairs-to-encode-and-then-concatenate-them-to-find-the-subwords">Step 4 - Iterate n times to find the best (in terms of frequency) pairs to encode and then concatenate them to find the subwords</h2>
<p>It is better at this point to structure our code into functions. This means that we need to perform the following steps:</p>
<ol>
<li><p>Find the most frequently occurring byte pairs in each iteration.</p>
</li>
<li><p>Merge these tokens.</p>
</li>
<li><p>Recalculate the character tokens' frequency with the new pair encoding added.</p>
</li>
<li><p>Keep doing this until there are no more pairs or you reach the end of the for a loop.</p>
</li>
</ol>
<p>For detailed code, you should <strong>check out my</strong> <a target="_blank" href="https://colab.research.google.com/drive/1QLlQx_EjlZzBPsuj_ClrEDC0l8G-JuTn?usp=sharing"><strong>Colab notebook</strong></a><strong>.</strong></p>
<p>Here’s a trimmed output of those 4 steps:</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb7b992-1986-4dbc-a444-da817255f80f_1295x637.png" alt="Image" width="1295" height="637" loading="lazy"></p>
<p>So as we iterate with each best pair, we merge (concatenate) the pair. You can see that as we recalculate the frequency, the original character token frequency is reduced and the new paired token frequency pops up in the token dictionary.</p>
<p>If you look at the number of tokens created, it first increases because we create new pairings – but the number starts to decrease after a number of iterations.</p>
<p>Here, we started with 25 tokens, went up to 31 tokens in the 14th iteration, and then came down to 16 tokens in the 50th iteration. Interesting, right?</p>
<h2 id="heading-how-to-improve-the-bpe-algorithm">How to improve the BPE algorithm</h2>
<p>BPE algorithm is a greedy algorithm, which means that it tries to find the best pair in each iteration. And there are some limitations to this greedy approach.</p>
<p>So of course there are pros and cons of the BPE algorithm, too.</p>
<p>The final tokens will vary depending upon the number of iterations you have run. This also causes another problem: we now can have different tokens for a single text, and thus different embeddings.</p>
<p>To address this issue, multiple solutions have been proposed. But the one that stood out was a unigram language model that added <a target="_blank" href="https://arxiv.org/pdf/1804.10959.pdf">subword regularization (a new method of subword segmentation)</a> training that calculates the probability for each subword token to choose the best option using a loss function. We'll talk more about this in upcoming articles.</p>
<h2 id="heading-do-we-use-bpe-in-berts-or-gpts">Do we use BPE in BERTs or GPTs?</h2>
<p>Models like BERT or GPT-2 use some version of the BPE or the unigram model to tokenize the input text.</p>
<p>BERT included a new algorithm called WordPiece. It is similar to BPE, but has an added layer of likelihood calculation to decide whether the merged token will make the final cut.</p>
<h2 id="heading-summary">Summary</h2>
<p>In this blog, you've learned how a machine starts to make sense of language by breaking down the text into very small units.</p>
<p>Now, there are many ways to break text down and so it becomes important to compare one approach with another.</p>
<p>We started off by understanding tokenization by splitting the English text by spaces – but not every language is written the same way (that is using spaces to denote segmentation). So then we looked at splitting by character to generate character tokens.</p>
<p>The problem with characters was the loss of semantic features from the tokens at the risk of creating incorrect word representations or embeddings.</p>
<p>To get the best of both worlds, we looked at subword tokenization which was more promising. And finally we looked at the BPE algorithm to implement subword tokenization.</p>
<p>We'll look more into the next steps and advanced tokenizers like WordPiece, SentencePiece, and how to work with the HuggingFace tokenizer next week.</p>
<h2 id="heading-references-and-notes">References and Notes</h2>
<p>My post is actually an accumulation of the following papers and blogs that I encourage you to read:</p>
<ol>
<li><p><a target="_blank" href="https://arxiv.org/pdf/1508.07909.pdf">Neural Machine Translation of Rare Words with Subword Units</a> - Research paper that discusses different segmentation techniques based BPE compression algorithm.</p>
</li>
<li><p><a target="_blank" href="https://github.com/rsennrich/subword-nmt">GitHub repo on Subword NMT(Neural Machine Translation)</a> - supporting code for the above paper.</p>
</li>
<li><p><a target="_blank" href="https://leimao.github.io/blog/Byte-Pair-Encoding/">Lei Mao’s blog on Byte Pair Encoding</a> - I used the code in his blog to implement and understand BPE myself.</p>
</li>
<li><p><a target="_blank" href="https://blog.floydhub.com/tokenization-nlp/">How Machines read</a> - a blog by Cathal Horan.</p>
</li>
</ol>
<p>If you’re looking to start in the field of data science or ML, check out my course on <a target="_blank" href="https://www.wiplane.com/p/foundations-for-data-science-ml"><strong>Foundations of Data Science &amp; ML</strong></a>.</p>
<p>If you would like to get all my tutorials/blogs delivered directly to your inbox, consider subscribing to <a target="_blank" href="https://dswharshit.substack.com/">my newsletter here.</a></p>
<p>Have something to add or suggest, you can reach out to me via:</p>
<ul>
<li><p><a target="_blank" href="https://www.youtube.com/channel/UCH-xwLTKQaABNs2QmGxK2bQ">YouTube</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/dswharshit">Twitter</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/tyagiharshit/">LinkedIn</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Universal Ethereum Delegated Transactions: No More Transaction Fees ]]>
                </title>
                <description>
                    <![CDATA[ TL;DR Check this back end and front end solutions for delegated transactions. It is universal for any token which supports the delegation of its functions. Read more below. This mostly technical article provides a universal framework and a working s... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/universal-ethereum-delegated-transactions-no-more-ethereum-fees/</link>
                <guid isPermaLink="false">66b99b7c3cd81de09c96b2bc</guid>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ crypto ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ethereum ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ethereum blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ token economy ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tokenization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Nikita Savchenko ]]>
                </dc:creator>
                <pubDate>Mon, 30 Sep 2019 15:53:22 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/09/you-need-some-ether-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <blockquote>
<p>TL;DR Check this <a target="_blank" href="https://github.com/ZitRos/ethereum-delegated-tx-service">back end</a> and <a target="_blank" href="https://zitros.github.io/ethereum-delegated-tx-widget/">front end</a> solutions for delegated transactions. It is universal for any token which supports the delegation of its functions. Read more below.</p>
</blockquote>
<p>This mostly technical article provides a <strong>universal framework</strong> and a <strong>working solution</strong> for Ethereum tokens and applications that eliminates the need to pay fees in Ether, a problem that is practically killing the user experience of many blockchain applications.</p>
<blockquote>
<p><em>Imagine spending dollars and then being asked to also hand over some</em> <a target="_blank" href="https://en.wikipedia.org/wiki/Ukrainian_hryvnia"><em>Hryvnias</em></a> <em>as a transaction fee. That's how Ethereum tokens work so far.</em></p>
</blockquote>
<p>In other words, for example, to transfer any Ethereum token (like <a target="_blank" href="https://coinmarketcap.com/currencies/tether/">Tether</a>, <a target="_blank" href="https://coinmarketcap.com/currencies/dai/">DAI</a>, <a target="_blank" href="https://coinmarketcap.com/currencies/basic-attention-token/">BAT</a>, <a target="_blank" href="https://token.dreamteam.gg/">DREAM</a>, etc.), the user has to also spend some <a target="_blank" href="http://ethereum.org/use/#_2-what-is-eth-and-how-do-i-get-it">Ether</a> (internal Ethereum platform currency). This introduces a big inconvenience that prevents the mass adoption of DApps: users have to purchase multiple currencies instead of just one to interact with the blockchain network.</p>
<h1 id="heading-the-problem">The Problem</h1>
<p>Tokens, as we imagine them today are just fuel for applications and services on top of blockchain networks. Organizations create their own tokens (using ICOs, IEOs, etc) and run services/applications that utilize them, introducing their own micro-economy (widely known as a <a target="_blank" href="https://medium.com/@pentremont/token-economy-101-or-why-blockchain-powered-decentralized-networks-are-important-310de1cc8bac">token economy</a>). But almost every token turns out to be quite a complex currency itself. By design of how blockchain networks work, in order to do something with your tokens, you also need another currency — often Ether (for Ethereum) to be able to transfer tokens.</p>
<p>To illustrate the problem, let's look into how users come to use different blockchain-powered services and applications like:</p>
<ul>
<li><a target="_blank" href="https://trickle.gg/">Trickle</a> - where you create secure, hourly-based contracts with an untrusted party in any token</li>
<li><a target="_blank" href="https://loomx.io/">Loom</a> - where you use Loom tokens to create sidechains in Loom Network</li>
<li><a target="_blank" href="https://www.cryptokitties.co/">Cryptokitties.co</a> - where you breed, trade and transfer kitties (ERC721 tokens)</li>
<li><a target="_blank" href="https://www.stateofthedapps.com/">Others</a> (there are a lot!)</li>
</ul>
<p>All these applications use tokens, as well as they require you to purchase Ether. The complexity of using crypto tokens as we know them today is one of the biggest reasons why 99% of crypto startups fail (or avoid adopting real crypto, for example, by replacing it with virtual coins).</p>
<p>As you may already know, the harder it is to use the application, the fewer users it will get right from the beginning. This is something known as <a target="_blank" href="https://www.appcues.com/blog/user-onboarding-funnel-amplitude">The User Onboarding Funnel</a>, which is still a big pain for blockchain-powered applications and services:</p>
<p><img src="https://lh3.googleusercontent.com/XJyaZoGARI3TF4DOjODJerEUNwn3qFm2D8WSZBrxwYE81oSHaw5h3MOweymV5VV9Jby-2OBUE7o1FGkVqZxWvONW0GLuoezAKqt8HmB-N-vPwHL_ouohPO2whDyS1jiXHLIQv9am" alt="Image" width="600" height="400" loading="lazy">
<em>The typical user onboarding funnel of a decentralized, blockchain-based application</em></p>
<p>To understand why I put 0.001% of users prior to the service use, let's see what exactly purchasing some Ether means:</p>
<ul>
<li>Creating a crypto wallet</li>
<li>Registering on Exchange (and learning all the exchange rules, including country policies!)</li>
<li>Passing KYC (though it's getting easier, still, many countries have limited access to exchanges)</li>
<li>Purchasing a minimum allowed amount of Ether (usually, it's <a target="_blank" href="https://changelly.com/widget-settings">whopping $50</a> while you need just nearly $0.05 to perform one or two transactions)</li>
<li>Withdrawing Ether to your wallet</li>
<li>Not to mention reading lengthy guides on how to perform all these steps properly</li>
</ul>
<p>Instead of just:</p>
<ul>
<li>Creating a crypto wallet</li>
</ul>
<p>Of course, it highly depends on how the application or service is made. But, so far, there was no better simplification of the onboarding flow as just cutting crypto tokens from there, or making them fake, "virtual" currency with deposit and withdrawal function. Unfortunately, the latter approach is now the common one across all startups and companies adopting crypto, for many good reasons. Another reason could be a monetization strategy, but this is another big story worth a dedicated article (Interested? Comment out!).</p>
<p>Getting back to the transaction fees problem, we can state the following, which is hard to argue with.</p>
<blockquote>
<p><em>It is natural for the user to purchase <strong>only</strong> the cryptocurrency they really need (for instance, tokens:</em> <a target="_blank" href="https://coinmarketcap.com/currencies/tether/"><em>Tether</em></a><em>,</em> <a target="_blank" href="https://coinmarketcap.com/currencies/dai/"><em>DAI</em></a><em>,</em> <a target="_blank" href="https://coinmarketcap.com/currencies/basic-attention-token/"><em>BAT</em></a><em>,</em> <a target="_blank" href="https://token.dreamteam.gg/"><em>DREAM</em></a><em>, etc.), and they would normally expect to pay any transaction fees <strong>in this cryptocurrency</strong>.</em></p>
</blockquote>
<p>So why not just allow them to do so? Because it's quite complex indeed. Let's see why, and how this has just got easier with our open-sourced solution (at least for Ethereum).</p>
<h1 id="heading-existing-approaches">Existing Approaches</h1>
<p>From the very beginning of blockchain existence, there were a couple of solutions that could simplify the user onboarding flow to the flow depicted below, avoiding the step of purchasing an intermediate currency like Ether. Still, creating a blockchain wallet is not an easy step, but some users who do understand the value of the application/service go through this step quite well.</p>
<p><img src="https://lh3.googleusercontent.com/B_D585TaVcYR9qXA-0q3MfvAv1DjGzAulIup0XT1X8Va3eeekX32jAtayKbFCmKoISotoBk_WOyq9jGAdqJzfAnz5q61foOPjgxeVbcfq8bXlA9X25iqzKczy6qmjPvZJgBYsRrL" alt="Image" width="600" height="400" loading="lazy">
<em>The user onboarding funnel with delegated transactions</em></p>
<p>The solution which allows to avoid using intermediate currencies (Ether for Ethereum) is called "delegated transactions", or "meta transactions". </p>
<blockquote>
<p><em>In short, delegated transaction, or "meta transaction" in blockchain is the type of transaction which performs an intended action on one account's behalf, while it is conducted (published) by another account (delegate), who actually pays fees for the transaction.</em></p>
</blockquote>
<p>There are <a target="_blank" href="https://medium.com/@austin_48503/ethereum-meta-transactions-90ccf0859e84">multiple</a> <a target="_blank" href="https://fravoll.github.io/solidity-patterns/proxy_delegate.html">approaches</a> <a target="_blank" href="https://medium.com/@e2toe4/ethereum-meta-transactions-36f10448619">around</a> <a target="_blank" href="https://github.com/ethereum/EIPs/issues/1035">the</a> <a target="_blank" href="https://github.com/ethereum/EIPs/issues/1228">internet</a> of the generalized concept of delegated transactions I am presenting in this article. But it seems that none of them are still widely adopted, as these approaches are quite complex by its nature, very specific as for the implementation, as well as some of them are <strong>quite complex to standardize</strong>. To be more constructive, existing approaches can be divided into 3-4 groups: those which use proxy smart contracts, those which embed delegation into a smart contract itself and, theoretically, there is an opportunity for the blockchain-native implementation (say, Ethereum 2.0).</p>
<h2 id="heading-1-delegated-transactions-approaches-which-use-proxy-contracts">1. Delegated transactions approaches which use proxy-contracts</h2>
<p>Proxy contracts, or, in this context, identity contracts are tiny contracts deployed to replace the user account which wants to avoid paying fees. This smart contract is programmed to act as a wallet, as well as a "caller" (sender) of other smart contract's functions. The key is that it is a delegate account that triggers all the actions, while the true "owner" of this smart contract is another user. The user just generates correct signatures in order to control their funds stored on a smart contract address (= in their wallet).</p>
<p><img src="https://lh3.googleusercontent.com/BqoXbK-n6UmpKY-nu8_GuibFbfA3a2Lrghc_fHSoJOzMqv_MYL2BNzIUzyZPgT1aSM00WC0fJoyErLQKc0Dtu3D92NRdYB3Cm4bJ8vZAnbfHVaSe4pCxrEsI8rvEiNCbQriStqfx" alt="Image" width="600" height="400" loading="lazy">
<em>A visualization of how identity contracts look like</em></p>
<p><strong>Pros of this approach:</strong></p>
<ul>
<li>It works with any tokens and contracts which are already deployed to the network</li>
</ul>
<p><strong>Cons of this approach:</strong></p>
<ul>
<li>Users don't see tokens in their wallet, because they are physically on an identity smart contract</li>
<li>As a result, a need to develop custom UIs and custom tools/wallets</li>
<li>Identity smart contract deployment and assignment initial fees, as opposed to no fees at all</li>
<li>Requires a comprehensive standard to be widely adopted</li>
</ul>
<h2 id="heading-2-semi-delegated-transactions-via-operator-pattern-erc777httpseipsethereumorgeipseip-777">2. Semi-delegated transactions via "Operator" pattern (<a target="_blank" href="https://eips.ethereum.org/EIPS/eip-777">ERC777</a>)</h2>
<p>There is a token standard that describes this approach — <a target="_blank" href="https://eips.ethereum.org/EIPS/eip-777">ERC777</a>. In short, any token holder can authorize any other account to freely manage their tokens. I won't call it delegated transactions but nevertheless, I need to mention that, as here we somewhat delegate control over your tokens to other accounts.</p>
<p><img src="https://lh6.googleusercontent.com/Sf3WEbL4fRfefAZLZIBzxD8nAhLnFt75uIZUSO0SjifRwqbiIwSOUnWf4QkN6v6kmWXBazs05bGnG6w1AOTNZIEXwuVUf6GIPdBNtD60mAwiU5r7Oe4MMlNEGLy5htCrk51zsfwi" alt="Image" width="600" height="400" loading="lazy">
<em>A visualization of ERC777 standard's "operator" pattern</em></p>
<p><strong>Pros of this approach:</strong></p>
<ul>
<li>Standardized</li>
</ul>
<p><strong>Cons of this approach:</strong></p>
<ul>
<li>Highly centralized around the "operator" accounts</li>
<li>Weak security due to operators have 100% control over your tokens</li>
<li>Initial fees for approval transaction</li>
<li>Requires additional UIs/tools development</li>
</ul>
<h2 id="heading-3-delegated-transactions-embedded-directly-into-a-token-smart-contract">3. Delegated transactions embedded directly into a (token) smart contract</h2>
<p>Just the same as it is possible to implement custom fees in a proxy smart contract, paying fees in tokens can be implemented directly in a token smart contract. For example, using the approach I described in <a target="_blank" href="https://hackernoon.com/you-dont-need-ether-to-transfer-tokens-f3ae373606e1">my previous article</a>, it is possible to implement a function in a smart contract, which will transfer tokens accepting the user's signature, instead of requiring the user to call this function directly. We have implemented this approach in our <a target="_blank" href="https://token.dreamteam.gg/">DREAM Token</a>, which is used on our <a target="_blank" href="https://dreamteam.gg/">dreamteam.gg</a> platform.</p>
<p><img src="https://lh3.googleusercontent.com/NTd44yatekkdfGEOfSDdsXi1S8cmtRdkQLXmUKSIm-nFzMMQdOM1Rox1nML6Y2Z8gYh9t_sMIsPvr7L7AHxTPlYXp0ENnVWQBLf5g85Cue-CiR2zb1Xw4Ym4G407MQOhCUUnSrrQ" alt="Image" width="600" height="400" loading="lazy">
<em>A visualization of how embedding delegation into the token contract looks like</em></p>
<p>As you may notice, in contrast to the previous approach there is no identity contract anymore, and there is an optional way to call other smart contracts directly from the token contract.</p>
<p><strong>Pros of this approach:</strong></p>
<ul>
<li>Users see their tokens as usual on their wallet's balance</li>
<li>No initial fees for account initialization</li>
<li>May not even require a standard (continue reading)</li>
</ul>
<p><strong>Cons of this approach:</strong></p>
<ul>
<li>If you have a (token) smart contract that is already deployed to the network, you cannot apply this approach to it directly. While you can always deploy a new token and, for example, a "migration" utility, which will allow other users to swap tokens (burn the old token and mint a new one)</li>
<li>Because a standard for this approach is yet not well-defined, implementation can drastically vary</li>
<li>A need to develop custom UI/tools for delegated transactions (continue reading — solved!)</li>
</ul>
<h2 id="heading-4-delegated-transactions-on-the-blockchain-platform-level">4. Delegated transactions on the (blockchain) platform level</h2>
<p>This is far the best one of all the described approaches above but also the one <strong>which is not implemented anywhere yet</strong> (by anywhere I mean the most popular blockchain platforms). There is a hope that its support comes with Ethereum 2.0 release, or at least I've heard from Vitalik that they are in progress with something cool there.</p>
<p>Theoretically, we can imagine this approach as being able to make an "offline" signature of two transactions at a time: one which does something useful for the signing account which wants to avoid paying fees (for example, transferring tokens) and another one which does something useful for the delegate (for example, paying fee in tokens to the account which executes these two transactions).</p>
<p><img src="https://lh5.googleusercontent.com/R1S5_YVazRlh2mfzuMLaKAnix8GmXJy4swBQyxzWFzhIZhE5nDTZ4gfOLp9G51dx-ydW7sLQCsWkic6k_nVj_1CD8JkHjGjRYSMwt17wGSLAG58Vs2ve02KS3L5m5L2oTCMWfxlG" alt="Image" width="600" height="400" loading="lazy">
<em>A visualization of how platform-native delegated transactions could look like</em></p>
<p>But the problem is, regarding Ethereum 2.0, this feature has a chance to land only in 2022 or even later. I also suppose that this feature will still require a dedicated back end (similar to the one which is introduced within this article), as it is hard to imagine how miners will accept fees in tokens. Simply put, if some of them refuse to accept fees in tokens than it makes little sense to do it on a "mining" level at all, not to mention how much would it take to track all token prices and volumes across exchanges, in a decentralized manner.</p>
<p><strong>Pros of this approach:</strong></p>
<ul>
<li>No need to change smart contracts that were already deployed</li>
<li>No initial fees for account initialization</li>
<li>May not even require a custom UI/tools if standardized</li>
</ul>
<p><strong>Cons of this approach:</strong></p>
<ul>
<li>Most likely, will still require a centralized back end (the "delegate")</li>
<li>Not yet implemented on a platform level (as of 2019)</li>
</ul>
<h1 id="heading-the-solution">The Solution</h1>
<p>From the four approaches above, except for the platform-level approach which is yet to be implemented and standardized in 2022+, the most appealing one is <strong>the third approach</strong>, where we embed delegated functions directly to the token smart contract. Thus, we save the standard token paradigm allowing wallets to normally work with the smart contract and have no need to wait until delegated transactions will land natively in one of the top blockchain platforms. We will stick to this approach and make it <strong>universal</strong> just below.</p>
<p>Delegated transactions support programmed right in the token smart contract is awesome. But how to deal with its cons? In fact, the only problem which is tough to deal with (as you cannot modify existing smart contracts), <strong>you will need to deploy a new token smart contract if you have already deployed it without delegated functions</strong> (for instance, standard ERC20 or ERC721 tokens). The next step, in this case, would be adding a way to migrate tokens from one smart contract to another. For example, you can decide to implement one more function in the new smart contract that will allow token holders to migrate their assets from the old smart contract.</p>
<p>Token migration function implementation can vary, starting from implementing <em>receiveApproval</em> in the new token, if the previous token supports <em>approveAndCall</em>, or ending with utilizing <em>approve</em> + <em>transferFrom</em> framework if you have just a bare minimal ERC20 (the user _approve_s tokens to the new token contract address and then calls a function in the new contract which burns old tokens and mints new ones — but this requires a standard fee for the user for the approval transaction). Actually, there is more: you can decide not to burn old tokens but to "lock" them on a new token smart contract, minting new tokens — this opens an opportunity to implement <strong>two-sided token migration</strong>, which is awesome — <strong>you won't need to list the "new" token on the exchange</strong>, while the users will still be able to send the old token to exchanges without fees in Ether! If you are interested, please fill the issue <a target="_blank" href="https://github.com/ZitRos/ethereum-delegated-tx-service/issues">here</a> if you want to know more details on how to do it, because this approach is worth a whole new article.</p>
<p>In my <a target="_blank" href="https://hackernoon.com/you-dont-need-ether-to-transfer-tokens-f3ae373606e1">previous article</a>, I provided an example of the token smart contract which supports delegation of such functions like <em>transfer</em>, <em>transferFrom</em>, <em>approve</em> and <em>approveAndCall</em>. Exactly these "delegated" functions allow users to pay fees in tokens, instead of Ether.</p>
<p><img src="https://lh6.googleusercontent.com/K95psDr4YlNLWPFIByI6HmE5DOz-uIGmD9xfNODmhfj6oRfkIlGJwkZLPYBEVof4MwitQe5Li6SbUNptplVKL2MfERLbVHLJru5jJkTpCVDnDaQbpMd24wtbWOTp81hX7CHtiRtR" alt="Image" width="600" height="400" loading="lazy">
<em>How delegation works in Ethereum, in short. Read more in <a target="_blank" href="https://hackernoon.com/you-dont-need-ether-to-transfer-tokens-f3ae373606e1">this article</a>.</em></p>
<p>But that wasn't enough to start the mass adoption. In this article, I am providing a complete <a target="_blank" href="https://github.com/ZitRos/ethereum-delegated-tx-service">universal back end solution</a> (Transaction Publisher in the picture above), as well as a <a target="_blank" href="https://github.com/ZitRos/ethereum-delegated-tx-widget">configurable widget</a> (<a target="_blank" href="https://zitros.github.io/ethereum-delegated-tx-widget/">check it here</a>), which allows you to replace Ether fees for token fees today.</p>
<p>Some key points before we dive in:</p>
<ul>
<li>This delegated transactions back end is made to be universal, or <strong>standard-free</strong>, meaning that you can have <strong>any implementation</strong> of delegated functions and <strong>use any signature standard(s)</strong> in your token. From the back end standpoint, you just need to write a manifest file for your token, describing its usage.</li>
<li>Currently, converting collected fees in tokens back to Ether is a manual action on exchanges. But it could be a potential improvement for automation in the future (if needed).</li>
</ul>
<h1 id="heading-the-concept-behind-the-universal-solution">The Concept Behind the Universal Solution</h1>
<p>What does it mean that the token supports delegated transactions? Let's look at it using the ERC20 standard token as an example.</p>
<h2 id="heading-smart-contract">Smart Contract</h2>
<p>As for the token smart contract, the approach is quite straightforward. In addition to every method like <strong>transfer(to, value)</strong> which we want to be "delegatable", we add a companion function which, instead of inspecting <strong>msg.sender</strong>, accepts the signature of a user and does the same what the original function meant to do by validating this signature inside the smart contract. Thus, for example, for <strong>transfer(to, value)</strong> function we can add <strong>transferViaSignature(to, value, ...aditionalParams)</strong> function. As you know from <a target="_blank" href="https://en.wikipedia.org/wiki/Public-key_cryptography">public-key cryptography</a>, no one can create a valid signature except private key owner, so that's why this approach is as secure as Ethereum itself.</p>
<p>And the coolest part is that the delegated function implementation, as well as its signature doesn't matter much, from the delegate back end standpoint. You can even decide to implement one "call by signature" function for all other functions that the smart contract supports. Delegate back end just need to know <strong>how</strong> to call this function, which is solved by providing an off-chain contract manifest for the delegate back end. For example, the argument <em>additionalParams</em> in <strong>transferViaSignature</strong> can vary and can include anything from this list, if not more: fee, fee recipient address, expiration timestamp, a signature standard used, a signature itself, nonce number or any other unique delegated transaction ID and so on. Regarding the smart contract design, in order to understand why exactly these arguments, read my <a target="_blank" href="https://hackernoon.com/you-dont-need-ether-to-transfer-tokens-f3ae373606e1">previous article</a>.</p>
<p>We also want to allow "delegates" to earn something in order to cover their Ether spending, as well as to be profitable. Thus, we have to add a fee, but a much more natural fee than Ether: a fee in the token itself. So that, for example, if you need to transfer 100 tokens, you pay 3 more tokens to the delegate depending on its price and network conditions to perform a transfer, and this should be preserved in a smart contract logic.</p>
<h2 id="heading-back-end">Back End</h2>
<p>All right, now we have a token that allows transferring someone else's tokens by using their signature. Now, the crucial part is to automate the process of requesting and publishing such transactions. And here where our open-sourced <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-service">back end</a> (and a <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-widget">front end</a>) kicks in.</p>
<p>Below is the sequence diagram describing how front end (client) communicates with the back end from the delegated transaction request to its publishing to the network:</p>
<ol>
<li>(hidden on the diagram) The client requests information from the delegated back end to understand which contracts does it support, as well as which functions can it delegate.</li>
<li>The client requests a particular smart contract's function to be delegated. Most importantly, the back end returns the fees it charges and a data to be signed by the client.</li>
<li>The client signs the data in their wallet. Signing is a free operation, unlike publishing transaction to the network.</li>
<li>The client sends their signature back, thus confirming their intent to perform this particular delegated transaction. The back end validates this transaction against the current network.</li>
<li>Finally, the back end publishes a transaction to the network.</li>
<li>(hidden on the diagram) The client constantly polls the back end for the delegated request status until it receives a mined status. Note: it is important to poll the back end instead of using a transaction hash to understand when the transaction is mined. It is a very common case when the gas price suddenly increases, and, in order for the transaction to be mined quickly, the back end may republish it with a higher gas price. Though it is currently not implemented, it is very likely to be implemented soon.</li>
</ol>
<p><img src="https://lh5.googleusercontent.com/X2SADmcB2aMcJoUgN291XXPdk73sVNi4ebruRwN6TCcDgVWi7ILZs02Mlz0WSR4ufOnzXqxrHIdTSJyijeSKsTw1Z89vB0zjwD8dvQ3Jop6Z4xPKET1TWBnNDBad5QDlD8y0jptG" alt="Image" width="600" height="400" loading="lazy">
<em>Sequence diagram representing the simplified flow of how delegated transaction is delivered to the network</em></p>
<p>This approach is universal, and only requires the manifest file for the back end to understand how to calculate fees and which signature standard to use on the client side. Here is another visualization of the components of the system and their interaction sequence:</p>
<p><img src="https://lh4.googleusercontent.com/EmfRndRu7BJyU9UTYVGt_rKlQIE83v21s7UywoeTeZQ3Y832Z85KgYRQgmB4o9bqUS7OExMGy2ace6kc3v7QEL-t0bcsvsg9xu9zqLdKDUrzHWXrhHnwoOQWUkd8GBAOWwLww5e8" alt="Image" width="600" height="400" loading="lazy">
<em>Component diagram</em></p>
<p>We've provided a comprehensive <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-service#delegated-transactions-concept">documentation</a> for this solution. You can check how the back end <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-service#api">API is structured</a>, as well as find the token <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-service/blob/master/config/contracts/mainnet/0x82f4ded9cec9b5750fbff5c2185aee35afc16587/manifest.js">manifest file</a> which describes how to work with a <a target="_blank" href="https://etherscan.io/address/0x82f4ded9cec9b5750fbff5c2185aee35afc16587#code">particular token contract</a>. We encourage you to contribute your own tokens there!</p>
<p>And you don't need much setup: it's already there with the universal front end!</p>
<h2 id="heading-front-end">Front End</h2>
<p><a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-widget">Open-sourced front end part</a> of the delegated transactions is the user interface which is <strong>set up for every token</strong>: just run your delegated transactions back end and you are ready to go!</p>
<p><img src="https://lh4.googleusercontent.com/8TagMGFbuyXbiIEe8_x7cmBycjrAxcpE8zyURXmDIF1cQET-K64NchEmK0lWfNpwR5mzcJIQ5YLp--hLSCksLlMflOAPBbDCf2frPrF4xm6cEZ92GNXH-QDA3MBKpokX4O2tZoUq" alt="Image" width="600" height="400" loading="lazy">
<em>What <a target="_blank" href="https://send-token.dreamteam.gg">it</a> looks like</em></p>
<p>It is made to be an embeddable widget, which will guide the user through the procedure of sending tokens. You can plug any back end, token or call any token function with it by utilizing <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-widget#embedding">additional URL parameters</a> you can specify.</p>
<p>Using this widget, and by implementing something similar to widely used, but not standardized <em><strong>approveAndCall</strong></em> function in your token smart contract, you will be able to call other smart contracts with arbitrary data by paying fees in tokens!</p>
<p>Here is a quick guide for you if you want to play with this UI yourself:</p>
<ol>
<li>Access the widget via <a target="_blank" href="https://zitros.github.io/ethereum-delegated-tx-widget/?contractAddress=0xcc7e25e30b065ea61814bec6ecdb17edb0f891aa">this link</a>.</li>
<li>It will ask you to switch to the Kovan test network.</li>
<li>Get some test Ether using <a target="_blank" href="https://www.google.com/search?q=ethereum+kovan+faucet">any available Kovan faucet</a>.</li>
<li>Use test Ether to mint some <a target="_blank" href="https://kovan.etherscan.io/address/0xcc7e25e30b065ea61814bec6ecdb17edb0f891aa#writeContract">test tokens</a>: call <a target="_blank" href="https://kovan.etherscan.io/dapp/0xcc7e25e30b065ea61814bec6ecdb17edb0f891aa#writeContract">mintTokens</a> function in a token smart contract which will give you 10 test tokens.</li>
<li>Now, get back to <a target="_blank" href="https://zitros.github.io/ethereum-delegated-tx-widget/?contractAddress=0xcc7e25e30b065ea61814bec6ecdb17edb0f891aa">the widget</a> and try to transfer these tokens!</li>
</ol>
<p>If you open up the browser's developer tools, you may notice that there are a couple of back ends connected by default — they provide the front end with all required information to make a delegated request according to given widget URL parameters. All backends are requested during the widget load and, if any of them can provide a delegation for a particular contract's function, then the widget requests additional information: fees, supported signatures, etc. If there are multiple back ends which can delegate the same contract function, all of them are requested and the back end which provides the best fee will be used for the transaction.</p>
<p>Transaction mining time is seemingly fixed, but it can vary because of the network conditions. The back end uses an actual network fee when calculating the token fee, however, it may change before the user decides to execute the transaction. Thus, the "underpriced" transaction is submitted to the network and can be pending for a while. While the back end is currently not programmed to deal with this case, it might be implemented in future — transactions will be republished with higher gas fees in case of the network fee increases. But, we will also need to count this into the token fee.</p>
<h2 id="heading-signature-standards">Signature Standards</h2>
<p>The last question which you may be wondering is — which signature standard to use for your token. There are several available: _eth<em>sign</em> (deprecated), _eth<em>personalSign</em> (note that old <a target="_blank" href="https://trezor.io/">Trezor</a> and <a target="_blank" href="https://www.ledger.com/">Ledger</a> produce a different signatures because of ambiguity in a standard, so you may want to include both), _eth<em>signTypedData</em> (deprecated), <a target="_blank" href="https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26">_eth_signTypedData<em>v3</em></a> and so on. I would recommend supporting at least two: ageless _eth<em>personalSign</em> and new <a target="_blank" href="https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26">_eth_signTypedData<em>v3</em></a> (as of 2019).</p>
<p><img src="https://lh3.googleusercontent.com/TZhSpdfJF_035M1uCARZVYixZC4W8hsiG1jbs2zTyYZQC5fpwJUR3W7x14WaLofyklmEaR9O4Cgt7EkKb7MCb1RHK6geJfxKb-oGVVxlOXBOu6dh5c6nRtNwblF5B0sZ07Gf6mV7" alt="Image" width="600" height="400" loading="lazy">
<em>Signature standards comparison — what the user sees</em></p>
<p>The front end is programmed to always prefer the user-readable standard like <a target="_blank" href="https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26">eth_signTypedData_v3</a> to any others eth_personalSign. So if your token supports many signature standards, and you added all of them to the <a target="_blank" href="https://github.com/dreamteam-gg/ethereum-delegated-tx-service/blob/master/config/contracts/mainnet/0x82f4ded9cec9b5750fbff5c2185aee35afc16587/manifest.js">manifest file</a> of your token, it will display <a target="_blank" href="https://medium.com/metamask/eip712-is-coming-what-to-expect-and-how-to-use-it-bb92fd1a7a26">eth_signTypedData_v3</a> prompt first.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Delegated transactions are great: they solve one of the biggest problems of blockchain application adoption, which eases the mass adoption of crypto overall. I will put a couple of thesis in a Q&amp;A format here for you to answer the last questions that you may still have after reading this article:</p>
<ul>
<li>Our open-source solution is free to use and production-ready, feel free to apply it to your applications or tokens!</li>
<li>The described approach does not compromise security nor centralization. Think this way: the centralized back end is only a helper for someone who wants to transfer tokens without fee in Ether. If the back end is hacked, or it is just unavailable, there's no problem to interact with the network just as it was before, by paying fees in Ether. As well as the back end cannot harm or trick the user to steal their tokens when a proper signature standard is used (it's up to your token implementation).</li>
<li>There is a way to support delegated transactions for existing, already-deployed tokens. However, it requires the additional Ether-consuming step to migrate existing tokens to a new token contract. And, by programming a new token contract properly, as well as designing your application to work with both tokens you can even avoid a need to list a new token on exchanges.</li>
<li>By using the <a target="_blank" href="https://github.com/zitros/ethereum-delegated-tx-service/blob/master/config/contracts/mainnet/0x82f4ded9cec9b5750fbff5c2185aee35afc16587/manifest.js">existing tokens as an example</a>, which is available in delegated transactions <a target="_blank" href="https://github.com/zitros/ethereum-delegated-tx-service">back end</a> and <a target="_blank" href="https://github.com/zitros/ethereum-delegated-tx-widget">front end</a> repositories, you can produce your own manifest for your own token.</li>
<li><a target="_blank" href="https://github.com/zitros/ethereum-delegated-tx-service#setup">Read the instructions</a> on how to set up your own back end for a token, and then add it to the URL of your widget (or commit to the open-source repository).</li>
<li>Have a token which already supports delegated transactions? Plug it into <a target="_blank" href="https://zitros.github.io/ethereum-delegated-tx-widget">our UI</a> with these three quite simple steps: (1) create a manifest for your token and put your token abi file while setting up the delegate back end, (2) run this back end, exposing a public API URL and (3) use URL parameters in a widget to reference your back end or commit it directly to our open-source repository. Read more about it in GitHub's readme file.</li>
</ul>
<p>I hope that was a really helpful piece of information for all the searchers of incredible. Feel free to contact <a target="_blank" href="https://nikita.tk/">me</a> or fill the issue <a target="_blank" href="https://github.com/ZitRos/ethereum-delegated-tx-service/issues">here</a> if I missed something. Have fun, let the token economy be simple!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How does tokenization work, anyway? ]]>
                </title>
                <description>
                    <![CDATA[ By Albert Ho Not everything will be tokenized, but that which can be will be. 2017 saw the hype of utility tokens and ICOs. 2018 marks the hyped start of asset tokenization and the launch of securities tokens/platforms. This trend is notably huge in... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-does-tokenization-work-anyway-afb5fed1ac47/</link>
                <guid isPermaLink="false">66c34d124f7405e6476b01d8</guid>
                
                    <category>
                        <![CDATA[ Bitcoin ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Blockchain ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cryptocurrency ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ethereum ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tokenization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 20 Oct 2018 13:06:04 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*7pMYW1axSFq7uO09x3UoqA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Albert Ho</p>
<h4 id="heading-not-everything-will-be-tokenized-but-that-which-can-be-will-be"><strong>Not everything will be tokenized, but that which can be will be.</strong></h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3S1xyeWzGYjjVeZp5EGSY1S6gFYFUEyYLl12" alt="Image" width="800" height="533" loading="lazy"></p>
<p>2017 saw the hype of utility tokens and ICOs. 2018 marks the hyped start of asset tokenization and the launch of securities tokens/platforms. This trend is notably huge in the U.S, given how A16z and GGV Capital invested in the likes of tokenization platforms like <a target="_blank" href="https://blog.trusttoken.com/trusttoken-raises-20-million-usd-in-strategic-round-88912d1dbc71">TrustToken</a>, <a target="_blank" href="https://techcrunch.com/2018/04/17/harbor-securities-tokenization/">Harbor</a>, and <a target="_blank" href="https://www.businessinsider.sg/a-startup-raised-59-million-in-a-token-sale-to-usher-in-the-next-generation-of-crypto-2018-2/?r=US&amp;IR=T">Polymath</a>.</p>
<p>In Asia, the trend is starting to pick up too. For instance, <a target="_blank" href="https://rate3.network">Rate3 Network</a> was funded by various notable Asian VCs that include Matrix Partners China and Fenbushi Capital.</p>
<p>Conceptually, tokenization <em>might seem</em> easy: Issue an ERC-20 token (or any other blockchain tokens), imbue legal rights and ownership rights in the tokens, and you can trade them easily. However, this warrants a much deeper look: how do you distinguish claim rights and ownership rights? What are the differences in tokenization between different asset classes? What is impeding tokenization from adoption?</p>
<p>Thinking comprehensively about tokenization requires an understanding of blockchains and smart contracts, legal, finance, and economics. There has already been in-depth research on each of these components.</p>
<p>In this piece, I want to give a comprehensive introduction to tokenization through using real estate as a primary example. Here’s what we’ll discuss:</p>
<ul>
<li><a class="post-section-overview" href="#8381">What <em>exactly</em> is Tokenization?</a> <em>(Is it not just securitization?)</em></li>
<li><a class="post-section-overview" href="#ccc3">What are the <em>real</em> benefits of tokenization?</a> <em>(Why do we even bother?)</em></li>
<li><a class="post-section-overview" href="#9264">What are some of the <em>tougher</em> issues to think about?</a> <em>(How do we ask the right questions?)</em></li>
<li><a class="post-section-overview" href="#57ff">What are the <em>challenges</em> for tokenization?</a> <em>(What’s stopping adoption?)</em></li>
<li><a class="post-section-overview" href="#789d">How will the tokenized <em>future</em> be?</a> <em>(What are some elements?)</em></li>
</ul>
<p><strong>Let’s get started!</strong></p>
<h3 id="heading-what-is-tokenization">What is Tokenization?</h3>
<h4 id="heading-isnt-tokenization-just-securitization">Isn’t Tokenization just securitization?</h4>
<p>For structured finance professionals, tokenization <em>might</em> seem like securitization. In summary, securitization consists of a few steps:</p>
<ol>
<li>Originator (owner of the assets) collects the assets in a pool and transfers the pool to a legal entity (usually a special purpose vehicle). Through this legal structure, assets are not exposed to counter-party risks or risk of bankruptcy of the originator bank</li>
<li>The SPV structures the assets within the pool into several tranches, according to different risk levels and characteristics usually. Securities are issued, and backed by the cash flows generated by the underlying assets.</li>
<li>After issuing the securities, the SPV sells the securities to investors, whilst transferring the proceeds to the originator afterwards.</li>
</ol>
<h4 id="heading-securitization-has-various-flaws"><strong>Securitization</strong> has various flaws.</h4>
<p>The classic <strong>securitization</strong> process is extremely costly and takes up a lot of time. The entire process might cost up to millions of dollars and takes up to a year. The securitization process requires agreements with various parties under conditions of asymmetric information, as well as a heterogeneous structure of asset data.</p>
<p>Furthermore, there might be a lack of full transparency in the various stages of securitization, all of which hinder auditing and rating of the underlying assets. In the sub-prime mortgage crisis, there is no transparency on the credit pool nor the audit process that lead to defaults on the bonds issued.</p>
<h4 id="heading-clearly-tokenization-securitization">Clearly, tokenization =/= securitization</h4>
<p>Tokenization — in its simplest definition — refers to converting an asset into a digital token on the blockchain system. The biggest difference between tokenization and securitization, is how programmability is introduced into the tokenized asset. This way, business logic can be introduced, reducing the need for manual settlements. Smart contracts can have functions for automatic transactions, formulas for calculating asset prices and other specific features.</p>
<h3 id="heading-what-are-the-real-benefits-of-tokenization-then">What are the real benefits of Tokenization then?</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/-W6AlP3OdocdH7XlQG3vxR6Ki2ifpbdwyCfS" alt="Image" width="800" height="532" loading="lazy">
<em>Photo by @sanfrancisco, Unsplash</em></p>
<p>Numerous research pieces have talked about various benefits of tokenization, but these various benefits can be categorized into three core principles: 1) <strong>liquidity</strong>, 2) <strong>programmability</strong> and 3) <strong>immutable proof of ownership</strong>.</p>
<h4 id="heading-key-principle-1-liquidity">Key Principle 1: Liquidity</h4>
<p><a target="_blank" href="http://www3.weforum.org/docs/WEF_GAC15_Technological_Tipping_Points_report_2015.pdf">World Economic Forum</a> predicts that over the next ten years, 10% of the world’s GDP will be stored in crypto assets, amounting to $10 trillion. This is primarily due to increased fractional ownership, and unlocking of liquidity premiums.</p>
<p>Assuming no legal and regulatory barriers, tokenization allows for increased fractional ownership. Most tokens can be broken into 18 decimals, as compared to fiat which can be broken down to $0.01 only. Fractional ownership lowers the barriers of entry for new investors. For instance, instead of paying $1 million for a new apartment, I can pay $50,000 for a tokenized fraction of the real estate. For investors, fractional ownership and lower barriers help them to increase portfolio diversification and construct a “truer” market portfolio.</p>
<p>The increase in liquidity helps unlock value for markets through liquidity premiums. When illiquid assets become more liquid, a <a target="_blank" href="http://people.stern.nyu.edu/adamodar/pdfiles/country/illiquidity.pdf">liquidity premium</a> of approximately ~20–30% is unlocked. One example is real estate: Even a fractional improvement in the sales price of such investments could result in trillions of dollars of new value for issuers and resellers.</p>
<h4 id="heading-key-principle-2-programmability-built-into-tokens">Key Principle 2: Programmability built into tokens</h4>
<p>Programmability refers to the ability to introduce <em>certain</em> business logic into smart contracts, allowing for automated events to occur. Tokenization can also lead to easier management of investors and their rights. Secondary transactions can be easily tracked by collaborating with third-party exchanges, allowing investors to receive distributions and exercise their other rights (e.g., voting) through the blockchain.</p>
<p>Programmability is especially useful in increasing the speed of settlements. In traditional finance, settlements refer to the process of documentation of the transfer of asset ownership before the ownership of assets actually changes hands. Compliance can be programmed into the tokens, if all participants have a digital identity that has gone through the relevant compliance/KYC/AML checks.</p>
<h4 id="heading-key-principle-3-immutable-proof-of-ownership">Key Principle 3: Immutable proof of ownership</h4>
<p>Blockchains are immutable and keep a public trace of every transfer, and owner. This digital trace of transactions not only proves the history of ownership but also helps to ensure less fraud. The immutable structure makes it impossible for a token-holder to “double-sell” a token — accepting a transfer for the same token to two different sources. This helps assure investors that no one can falsify transactions after the transaction has happened.</p>
<h3 id="heading-lets-dive-deeper-into-tokenization">Let’s dive deeper into tokenization.</h3>
<p><em>Tokenization is the process of digitally storing the property rights to a thing of value (asset) on a blockchain or distributed ledger, so that ownership can be transferred via the blockchain’s protocol. What are the other challenges?</em></p>
<h4 id="heading-issue-1-what-are-the-requirements-for-tokenization-to-take-place">Issue #1: What are the requirements for tokenization to take place?</h4>
<p>There are 3 fundamental requirements:</p>
<ol>
<li><strong>The rights to an asset can be stored digitally on a blockchain</strong></li>
</ol>
<p>Let’s go back to the real estate example. If I want to tokenize my house, I must be able to record my ownership of my house on a token itself. This means that to regulatory authorities, holding a token represents an ownership right or claim right on the house itself. <em>(We will go into these rights in a bit.)</em></p>
<p><strong>2. These rights can be legally transferred via blockchains</strong></p>
<p>Whilst I can document my rights to my house in a legally-recognized way, I should be able to transfer these rights to anyone I want and that person will have legal ownership of my house, assuming my tokens are imbued with ownership rights.</p>
<p><strong>3. Tokens can be easily exchanged for value, giving the assets “value”</strong></p>
<p>Lastly, like any security, I must be able to exchange my real estate token for value easily — so I can subscribe value to the asset.</p>
<h4 id="heading-issue-2-what-are-the-other-legal-issues-to-consider">Issue #2: What are the other legal issues to consider?</h4>
<p>Apart from the 3 requirements, what is more crucial to take note is the exact asset you are tokenizing: Does the token represent a claim on the asset or does the token represent actual ownership of the asset itself? Investors and token issuers must think carefully about what exactly a token represents.</p>
<p><strong>The truth is: it depends on what you want to tokenize. Tokenization is flexible.</strong> Using real estate as an example again, what can be tokenized could be direct ownership in the real estate (being a partial equity owner), right to rental income, or even the right to use an asset (renting the apartment).</p>
<p>Hence, a token could represent <em>ownership</em> of the underlying real asset, an <em>interest in a debt</em> secured by the asset, an <em>equity interest</em> in a legal entity that owns that asset, or a <em>right to the cash flow</em> from the asset.</p>
<h3 id="heading-there-are-3-basic-categories-of-rights-to-understand">There are 3 basic categories of rights to understand.</h3>
<p>The rights bestowed by tokenized securities (or security token) can be very complex to understand. However, tokenized securities can include claims to the assets (and usually the resulting cash flows), direct ownership rights, governance rights or a combination of all.</p>
<ol>
<li><strong>Claim rights:</strong> Claims to only certain specific uses (and claims) of the asset</li>
<li><strong>Ownership rights:</strong> Equity ownership and control of the asset</li>
<li><strong>Governance:</strong> System by which a group of people can come to unified decisions</li>
</ol>
<h4 id="heading-lets-illustrate-this-with-real-estate-again-with-a-few-examples-on-the-token-holders-rights">Let’s illustrate this with real estate again, with a few examples on the token holders’ rights:</h4>
<ol>
<li><strong>Claim rights, but no ownership rights</strong>: Token holders are entitled to cash flows from ongoing leases, but they have no ‘equity’ and ‘ownership’ of the underlying real estate</li>
<li><strong>Claim rights, AND ownership rights</strong>: Token holders are the ‘owners’ of the underlying real estate with claims to the cash flows. They can make decisions directly: how much to charge for rent, investments made to maintain the real estate, hiring staff and given the proceeds from the sale of the real estate.</li>
<li><strong>Only ownership rights:</strong> This example is rarely the case, but it means that token holders are now the ‘equity owners’ of the real estate.</li>
</ol>
<h4 id="heading-what-are-the-challenges-that-arise-from-these-different-rights">What are the challenges that arise from these different rights?</h4>
<p>It is possible that there is a separation of claim rights and ownership rights, and this creates misaligned incentives between both parties.</p>
<p><strong>What if… the tokens have ownership rights for token holders?</strong> How do 1,000 token holders make decisions collectively for the best of the assets? Is there a need for delegated voting or decision making?</p>
<p><strong>What if… the tokens only imbue claim rights for token holders?</strong> The token issuers (owners) can reduce profits and cash flows to the token holders, by re-investing the profits. This will be to the detriment of token holders who originally look towards the future cash flow.</p>
<p>The smart contract geek might ask: <em>can’t one automate all these logic in smart contracts?</em></p>
<h3 id="heading-no-smart-contracts-cannot-solve-all-these-issues">No, smart contracts cannot solve all these issues.</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/lP3pwrUqO9p3X0gH66HrJVmelSsIPHUmAh18" alt="Image" width="800" height="458" loading="lazy"></p>
<p>Contracts and smart contracts are <strong><em>incomplete:</em></strong></p>
<ol>
<li><em>Contracts are only enforceable when events and actions can be verified by a third party</em></li>
</ol>
<p>This is the long-standing problem of “<strong><em>oracles</em></strong>” in tokenization. There are some events that can be captured in code, but near impossible for any arbiter to determine if they really happened.</p>
<p>For instance, I issued out real estate tokens to holders so they can receive a portion of the rental income. However, it is possible that I do not document down all the rental agreements so token holders do not know what the real amount of rental income is. If this cannot be enforced effectively, there is no rational reason for parties to abide by the smart contract.</p>
<p><em>2. It is near impossible to write a contract that contains all possible conditions and events, hence achieving “completeness”</em></p>
<p>The problem with contracts is not what is in them, it is what is not in them. It is very costly and operationally challenging to write down every condition and event. Furthermore, events and conditions change in real life — and contracts have to adapt to these real-life changes.</p>
<p>Given the limitations of smart contracts as inherently incomplete, certain asset types should not be tokenized.</p>
<h3 id="heading-what-should-not-be-tokenized">What should not be tokenized?</h3>
<ol>
<li><strong>When the blockchain cannot fully capture the change of ownership of assets</strong></li>
</ol>
<p>There are some assets in markets where I can sell the physical asset outside of the protocol directly, despite it being tokenized. For instance, I can tokenize real estate and transfer the token (with ownership rights) to you, but it is possible I can also legally sell the same real estate to another.</p>
<p>There are also other cases when I can trade tokens, but have no guarantees that I can verify the authenticity of the underlying asset. In the case of real estate, it is easier to verify, but other examples include gold bars. If it takes a lot of costs and resources to verify the authenticity, tokenization might not be a viable solution.</p>
<p><strong>2. When the use of prices impede the protocol from achieving its objectives</strong></p>
<p>There are some situations in which we don’t <em>want</em> prices to determine who gets what. Sometimes, prices do not capture external societal benefits and costs, and might not be the most equitable way to allocate resources. Examples include social goods, for instance.</p>
<p><strong>3. Sometimes, we just <em>do not want</em> to tokenize some ‘assets’ and rights</strong></p>
<p>For instance, rights to birth certificates or educational records should not be tokenized since they represent a <em>unique</em> right. We do not, and should not tokenize these ‘assets’.</p>
<p>Clearly, there are some asset classes that _should no_t be tokenized, given real-life limitations.</p>
<h3 id="heading-how-do-you-really-tokenize">How do you really tokenize?</h3>
<p>We have walked through the <em>what</em> and <em>why of tokenization,</em> now let’s talk a little about the <em>how</em> of tokenization.</p>
<p>There are a few categories of assets that have been tokenized:</p>
<ul>
<li><strong>Fiat currencies</strong></li>
</ul>
<p>The tokenization of fiat currencies gave rise to stablecoins. <a target="_blank" href="https://tether.to">Tether</a> is the first example, creating USDT. However, there are inherent challenges with Tether. For a good, updated summary on stablecoins, I suggest this:</p>
<p><a target="_blank" href="https://blog.goodaudience.com/stablecoins-are-now-officially-in-vogue-again-131383ab8db9"><strong>Stablecoins are now officially in vogue again</strong></a><br><a target="_blank" href="https://blog.goodaudience.com/stablecoins-are-now-officially-in-vogue-again-131383ab8db9">_With seemingly one new project unveiling multi-million-dollar funding every other week, no one will blame you for…_blog.goodaudience.com</a></p>
<ul>
<li><strong>Gold</strong></li>
</ul>
<p>An example of a gold tokenization project is <a target="_blank" href="https://digix.global/dgx/">Digix</a>.</p>
<p>Each DGX token is 1:1 gold-backed, and 1 token represent 1 gram of 99.99% gold from London Bullion Market Association-certified refiners, with gold stored in The Safehouse vault. Purchasing 1 DGX token is equivalent to purchasing actual gold itself.</p>
<ul>
<li><strong>Real Estate</strong></li>
</ul>
<p>My primary interest lies in real estate, given the analogy between REITs and tokenized real estate. A few interesting examples are <a target="_blank" href="https://www.forbes.com/sites/rachelwolfson/2018/10/03/a-first-for-manhattan-30m-real-estate-property-tokenized-with-blockchain/#537f78784895">how a Manhattan real estate property was most recently tokenized</a>, or <a target="_blank" href="https://venturebeat.com/2018/10/09/elevated-returns-gets-18-million-for-st-regis-aspen-resort-tokenized-real-estate/">how a portion of the St. Regis Aspen is tokenized</a>. In the case of St. Regis Aspen, each Aspen token represents an indirect ownership interest in a common stock of the St. Regis Aspen REIT. According to Elevated Returns, the “REIT provides tax efficient structure while the blockchain provides peer-to-peer investing and cross-border transaction made simpler for investors.”</p>
<h3 id="heading-clearly-there-are-many-challenges-associated-with-tokenization">Clearly, there are many challenges associated with tokenization.</h3>
<h4 id="heading-1-lack-of-tokenization-standards-and-legal-infrastructure">1. Lack of tokenization standards and legal infrastructure</h4>
<p>Tokenization is not simply the creation of a token — any Solidity developer can do it. Instead, it’s about the design of the whole system, including understanding the various rights and issues we’ve talked about previously.</p>
<p>How do tokenization standards cater for these issues:</p>
<ul>
<li>Incentives (claim rights, ownership rights, governance)</li>
<li>Privileges of users and system admins (who operate the token contracts)</li>
<li>Life-cycle management of an asset (issuance, payouts, withdrawal)</li>
<li>Security management</li>
<li>Integration of KYC/AML requirements across different jurisdictions</li>
<li>Integration with exchanges</li>
<li>Interoperability between different public chains</li>
</ul>
<p>In the case of cross-chain interoperability, we do see different chains with different nascent characteristics. For instance, Ethereum has scalability issues but provides for more complex Turing-complete smart contracts. How about other public blockchain networks like Stellar or IOST or Zilliqa?</p>
<p><em>How can tokenized assets (in the form of tokens) be interoperable across these different chains?</em></p>
<h4 id="heading-2-digital-identity-thats-globally-and-legally-recognized">2. Digital identity that’s globally and legally-recognized</h4>
<p>From a regulatory point of view, it is a regulatory nightmare for assets to be issued and transferred across citizens of different legal jurisdictions.</p>
<p>Suppose I am an EU resident looking to tokenize my real estate and the token only imbues claim rights. How do I transfer this token to U.S persons, whilst taking into account their identity, KYC/AML issues, U.S regulations, taxes and all the other issues?</p>
<p><em>How can I reasonably and easily deal with a verified, attested U.S person in a legally-compliant way for both our national jurisdictions?</em></p>
<h4 id="heading-3-tokenization-does-not-mean-instant-liquidity">3. Tokenization does not mean instant liquidity</h4>
<p>Liquidity is the biggest challenge in the security token space and it does not happen organically. History has given us various examples of financial markets and instruments that have not yet achieved significant levels of liquidity. Helping to create liquidity through allowing institutional investors or accredited retail investors — through custodian solutions will be key. Of course, the underlying asset must be useful.</p>
<p><em>How do we introduce long-term, sustainable solutions for large institutional investors — the market makers — to create and maintain liquidity?</em></p>
<h3 id="heading-what-does-a-tokenized-future-look-like">What does a tokenized future look like?</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/VROVXufGdaPXFsGlBxX3mnk1zyqtHrnrX0Wi" alt="Image" width="800" height="519" loading="lazy"></p>
<p>I’m generally bullish on a tokenized future: a fairer, more equitable world with lower barrier to entry and capital requirements for individuals or businesses.</p>
<p>Through capturing value in tokenized assets, we can re-create all the sophistication of the existing financial and operational world we live in, with far less operational costs and complexities. When combining tokenization with reasonably complex business logic enabled by smart contracts, we can represent complex business interactions faithfully and more efficiently.</p>
<h4 id="heading-there-will-be-interoperability-through-standardization">There will be interoperability, through standardization</h4>
<p><strong>ERC 20 for token standards, as an example</strong></p>
<p>If the ecosystem for global assets becomes interoperable, it means we can hold ownership claims to a commercial building, early-stage equity, corporate bonds, a T-bill, a single-family residence, and a decentralized network on the same platform.</p>
<p>Different assets can reference each other contractually and interact in an automated way. It means an increased liquidity for all (tokenized) asset classes.</p>
<p><strong>ERC 725 for Identity, as another</strong></p>
<p><a target="_blank" href="https://twitter.com/feindura?lang=en">Fabian Vogelstellar</a> — creator of the ERC 20 standard — is leading the front for a unique decentralized identity for “humans, groups, objects and machines”. Quoting directly from the ERC 725 Github itself, “ This identity can hold keys to sign actions (transactions, documents, logins, access, etc), and claims, which are attested from third parties (issuers) and self-attested (<a target="_blank" href="https://github.com/ethereum/EIPs/issues/735">#ERC735</a>), as well as a proxy function to act directly on the blockchain”.</p>
<p>You can read more here about <em>ERC 725</em> here:</p>
<p><a target="_blank" href="https://github.com/ethereum/EIPs/issues/725"><strong>ERC: Identity · Issue #725 · ethereum/EIPs</strong></a><br><a target="_blank" href="https://github.com/ethereum/EIPs/issues/725">_eip: title: ERC-725 Identity author: Fabian Vogelsteller (@frozeman) discussions-to…_github.com</a></p>
<p>There are notable projects that have been working on implementing ERC 725 identity contracts. A few examples are: <a target="_blank" href="https://www.originprotocol.com/en">Origin Protocol</a> and <a target="_blank" href="https://rate3.network">Rate3 Network</a>.</p>
<p><a target="_blank" href="https://medium.com/originprotocol/managing-identity-with-a-ui-for-erc-725-5c7422b38c09"><strong>Managing Identity with a UI for ERC 725</strong></a><br><a target="_blank" href="https://medium.com/originprotocol/managing-identity-with-a-ui-for-erc-725-5c7422b38c09">_At Origin, we’re building a platform for decentralized, peer-to-peer marketplaces. You can imagine a future Airbnb-like…_medium.com</a><a target="_blank" href="https://medium.com/official-rate3/rate3-cross-chain-identity-protocol-identity-and-claims-erc-725-erc735-c6e51f422e7b"><strong>Rate3 Cross-Chain Identity Protocol — Identity and Claims (ERC 725, ERC735)</strong></a><br><a target="_blank" href="https://medium.com/official-rate3/rate3-cross-chain-identity-protocol-identity-and-claims-erc-725-erc735-c6e51f422e7b">_At Rate3, we initially wanted to build a blockchain-based settlement and clearance network for businesses. We…_medium.com</a></p>
<h3 id="heading-the-future-of-tokenization-is-not-here-yet-but-it-will-be-sooner-than-we-know">The future of tokenization is not here (yet), but it will be sooner than we know</h3>
<p>We are optimistic and bullish for the future of tokenization and tokenized securities. There are many elements of the envisioned tokenized future that we observe today:</p>
<ol>
<li><strong>Governments are increasingly partnering with private companies to create infrastructural solutions</strong></li>
</ol>
<p>One such example is the collaboration between <em>NASDAQ</em>, <em>Monetary Authority of Singapore</em> (Singapore’s Central Bank) and <em>Singapore Exchange</em> (Singapore’s main stock exchange) to develop Delivery versus Payment capabilities for settlement of tokenized assets across different blockchain platforms to improve operational efficiency and reduce settlement risks.</p>
<p><a target="_blank" href="http://www.mas.gov.sg/News-and-Publications/Media-Releases/2018/MAS-and-SGX-partner-Anquan-Deloitte-and-Nasdaq-to-harness-blockchain-technology.aspx"><strong>MAS and SGX partner Anquan Deloitte and Nasdaq to harness blockchain technology</strong></a><br><a target="_blank" href="http://www.mas.gov.sg/News-and-Publications/Media-Releases/2018/MAS-and-SGX-partner-Anquan-Deloitte-and-Nasdaq-to-harness-blockchain-technology.aspx">_Singapore, 24 August 2018… The Monetary Authority of Singapore (MAS) and Singapore Exchange (SGX) today announced a…_www.mas.gov.sg</a></p>
<ol start="2">
<li><strong>Projects have recognized the need for compliance, and are creating solutions that target automated compliance and AML/KYC</strong></li>
</ol>
<p>We have touched about the need to meld real-world legal requirements into the blockchain space. There are various projects that have been doing these globally:</p>
<ol>
<li><a target="_blank" href="https://harbor.com/"><strong>Harbor</strong></a>: <em>A compliance platform and protocol to ensure tokenized securities comply with existing securities laws at issuance and on every trade, everywhere across the globe.</em></li>
<li><a target="_blank" href="https://rate3.network"><strong>Rate3 Network</strong></a>: <em>A protocol that handles asset-tokenization and identity management across both Ethereum and Stellar blockchains.</em></li>
<li><a target="_blank" href="https://polymath.network/"><strong>Polymath:</strong></a> <em>A security token platform on which regulatory-compliant tokens can be built</em></li>
</ol>
<p>I do notice more blockchain projects building tokenization solutions targeted at different asset classes, different ways of modeling structured finance through issuing both debt and equity tokens, for instance. More importantly, these solutions know that working directly with regulatory authorities, collaborating with central banks and other projects will help to improve the overall ecosystem.</p>
<p>Ensuring the legally-compliant design of the whole system is key.</p>
<p><strong>3. “Paths of least resistance” will help everyone relate existing real examples to upcoming tokenization projects</strong></p>
<p>Real estate have always been quoted as an example for tokenization projects. This is due to the structure of real estate investment trusts (REITs), that one could relate more easily to tokenized structures.</p>
<p>Tokenized real estate is <em>not</em> REITs, but there are various principles we can use to help us understand, relate and think better: property rights, economics for REITs for instance.</p>
<p><em>Not everything will be tokenized, but those that can be will be.</em></p>
<p><em>Disclosure: I work at <a target="_blank" href="https://www.rate3.network/">Rate3 Network</a>, a dual-protocol that handles asset-tokenization and identity management across both Ethereum and Stellar blockchains.</em></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
