<h2id="example-of-code-block">Example Of Code Block</h2>
<p>In accumsan lacus ac neque maximus dictum. Phasellus eleifend leo id mattis bibendum. Curabitur et purus turpis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;</p>
<p>Cras at dolor eget urna varius faucibus tempus in elit. Cras a dui imperdiet, tempus metus quis, pharetra turpis. Phasellus at massa sit amet ante semper fermentum sed eget lectus. Quisque id dictum magna turpis.</p>
<p>If you don’t find <codeclass="highlighter-rouge">npm</code> in your system, <ahref="https://www.npmjs.com/get-npm">install
it</a>.</p>
@ -332,16 +331,14 @@ existing projects.</p>
<li>
<p>Install Yeoman.</p>
<divclass="language-bash highlighter-rouge"><preclass="highlight"><code> npm install -g yo
</code></pre>
</div>
<divclass="language-bash highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> npm <spanclass="nb">install</span><spanclass="nt">-g</span> yo
</code></pre></div></div>
</li>
<li>
<p>Install the Blockstack application generator.</p>
<spanclass="n">userDataTextView</span><spanclass="p">.</span><spanclass="n">text</span><spanclass="p">=</span><spanclass="s">"Signed in as ${userData.decentralizedID}"</span>
<spanclass="n">userDataTextView</span><spanclass="p">.</span><spanclass="n">text</span><spanclass="p">=</span><spanclass="s">"Signed in as ${userData.decentralizedID}"</span>
<p>If you don’t find <codeclass="highlighter-rouge">npm</code> in your system, <ahref="https://www.npmjs.com/get-npm">install
it</a>. Finally, if you get stuck at any point
@ -279,16 +278,14 @@ existing projects.</p>
<li>
<p>Install Yeoman.</p>
<divclass="language-bash highlighter-rouge"><preclass="highlight"><code> npm install -g yo
</code></pre>
</div>
<divclass="language-bash highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> npm <spanclass="nb">install</span><spanclass="nt">-g</span> yo
</code></pre></div></div>
</li>
<li>
<p>Install the Blockstack application generator.</p>
<spanclass="s2">"1 Head of Lettuce"</span><spanclass="p">,</span>
<spanclass="s2">"Haralson apples"</span>
<spanclass="p">]</span>
<spanclass="p">},</span>
<spanclass="c1">// ...more lists with items</span>
<spanclass="p">}</span>
</code></pre>
</div>
</code></pre></div></div>
<p>This is conceptually the simplest way to manage grocery lists. When you read a
<codeclass="highlighter-rouge">/grocerylists.json</code> file with <codeclass="highlighter-rouge">getFile()</code>, you get back one or more grocery
@ -504,28 +492,26 @@ or remove a grocery list; updating a list has no impact.</p>
<p>The <codeclass="highlighter-rouge">Person</code> object holds a Blockstack profile. Add <codeclass="highlighter-rouge">putFile</code>, <codeclass="highlighter-rouge">getFile</code>,
and <codeclass="highlighter-rouge">lookupProfile</code> after <codeclass="highlighter-rouge">Person</code>.</p>
<divclass="highlighter-rouge"><preclass="highlight"><code> When you are done, the import statement should look like the following:
</code></pre>
</div>
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> When you are done, the import statement should look like the following:
<p>Replace the <codeclass="highlighter-rouge">constructor()</code> initial state so that it holds the key properties required by the app.</p>
<p>This code constructs a Blockstack <codeclass="highlighter-rouge">Person</code> object to hold the profile. Your constructor should look like this:</p>
<p>This code allows the application to post statuses. It also displays the
user’s Blockstack ID. To display this, your app must extract the ID from the
@ -620,19 +604,18 @@ user profile data.</p>
<p>You’ll use the Blockstack <codeclass="highlighter-rouge">loadUserData()</code> method to access the <codeclass="highlighter-rouge">username</code>.</p>
<p>This loads existing state. Your code needs to fetch statuses on page load.</p>
</li>
<li>
<p>Add a new method called <codeclass="highlighter-rouge">fetchData()</code> after the <codeclass="highlighter-rouge">statuses.unshift(status)</code> section.</p>
<li>Save and close the <codeclass="highlighter-rouge">src/index.js</code> file.</li>
<li>Edit the <codeclass="highlighter-rouge">src/components/App.jsx</code> file.</li>
<li>
<p>Add the new route by importing the <codeclass="highlighter-rouge">Switch</code> and <codeclass="highlighter-rouge">Route</code> components from <codeclass="highlighter-rouge">react-router-dom</code>:</p>
<p>You use <codeclass="highlighter-rouge">isLocal()</code> to check if the user is viewing the local user profile or another user’s profile. If it’s the local user profile, the app runs the <codeclass="highlighter-rouge">getFile()</code> function you added in an earlier step. Otherwise, the app looks up the profile belonging to the <codeclass="highlighter-rouge">username</code> using the <codeclass="highlighter-rouge">lookupProfile()</code> method.</p>
</li>
<li>
<p>Modify the <codeclass="highlighter-rouge">fetchData()</code> method like so:</p>
@ -963,8 +931,7 @@ process URL paths that contain the <code class="highlighter-rouge">.</code> (dot
<spanclass="p">})</span>
<spanclass="p">}</span>
<spanclass="p">}</span>
</code></pre>
</div>
</code></pre></div></div>
<p><strong>NOTE</strong>: For <codeclass="highlighter-rouge">https</code> deployments, the default Blockstack Core API endpoint for name
lookups should be changed to point to a core API served over <codeclass="highlighter-rouge">https</code>.
@ -976,7 +943,7 @@ process URL paths that contain the <code class="highlighter-rouge">.</code> (dot
<li>
<p>Add the following block to <codeclass="highlighter-rouge">fetchData()</code> right after the call to <codeclass="highlighter-rouge">lookupProfile(username)... catch((error)=>{..}</code> block:</p>
<p>### This checks to ensure that users are viewing their own profile, by wrapping the <strong>Logout</strong> button and inputs with the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">isLocal()</span><spanclass="w"></span><spanclass="err">&&</span><spanclass="w"></span><spanclass="err">...</span><spanclass="p">}</span></code> condition.</p>
<p>### This checks to ensure that users are viewing their own profile, by wrapping the <strong>Logout</strong> button and inputs with the <codeclass="highlighter-rouge">{isLocal()&&...}</code> condition.</p>
</li>
</ol>
@ -1080,9 +1045,8 @@ process URL paths that contain the <code class="highlighter-rouge">.</code> (dot
<li>
<p>Restart the application so that the disabling of the <codeclass="highlighter-rouge">.</code> (dot) rule takes effect.</p>
{"description":"Use the Blockstack Browser","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/browser/browser-introduction.html","headline":"Use the Blockstack Browser","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/browser-introduction.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/browser/browser-introduction.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Get the Blockstack Browser","dateModified":"2018-10-17T09:26:44-07:00","description":"Get the Blockstack Browser","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/browser-introduction.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<td>Takes you to the initial page. This page contains a list of the available applications. You can also find available applications at the <ahref="https://app.co/blockstack"target="\_blank">App.co</a> site.</td>
</tr>
<tr>
<td>IDs</td>
<td>Allows you to establish the identity of your primary ID. You also go here to create additional, sub identities.</td>
</tr>
<tr>
<td>Wallet</td>
<td>Allows you to send and receive Bitcoin.</td>
</tr>
<tr>
<td>Settings</td>
<td>Configure settings for storage, change session password, reset the Browser, and more.</td>
</tr>
</tbody>
</table>
<h2id="uninstall-the-browser">Uninstall the browser</h2>
<p>If you installed the browser using an installer, follow the instructions for
<li><ahref="#what-is-the-decentralized-internet"id="markdown-toc-what-is-the-decentralized-internet">What is the decentralized internet?</a></li>
<li><ahref="#what-is-blockstack"id="markdown-toc-what-is-blockstack">What is Blockstack?</a></li>
<li><ahref="#how-do-dapps-differ-from-applications-i-typically-use"id="markdown-toc-how-do-dapps-differ-from-applications-i-typically-use">How do Dapps differ from applications I typically use?</a></li>
<li><ahref="#how-do-dapps-differ-applications-i-typically-use"id="markdown-toc-how-do-dapps-differ-applications-i-typically-use">How do Dapps differ applications I typically use?</a></li>
<li><ahref="#where-is-my-identity-kept"id="markdown-toc-where-is-my-identity-kept">Where is my identity kept?</a></li>
<li><ahref="#can-blockstack-control-my-data-or-id-when-i-use-it"id="markdown-toc-can-blockstack-control-my-data-or-id-when-i-use-it">Can Blockstack control my data or ID when I use it?</a></li>
<li><ahref="#do-dapps-work-with-a-regular-browser"id="markdown-toc-do-dapps-work-with-a-regular-browser">Do Dapps work with a regular browser?</a></li>
<li><ahref="#do-dapps-uwork-with-a-regular-browser"id="markdown-toc-do-dapps-uwork-with-a-regular-browser">Do Dapps uwork with a regular browser?</a></li>
<li><ahref="#what-is-the-blockstack-browser"id="markdown-toc-what-is-the-blockstack-browser">What is the Blockstack Browser?</a></li>
<p>If you don’t find <codeclass="highlighter-rouge">npm</code> in your system, <ahref="https://www.npmjs.com/get-npm">install
it</a>.</p>
@ -278,16 +277,14 @@ existing projects.</p>
<li>
<p>Install Yeoman.</p>
<divclass="language-bash highlighter-rouge"><preclass="highlight"><code> npm install -g yo
</code></pre>
</div>
<divclass="language-bash highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> npm <spanclass="nb">install</span><spanclass="nt">-g</span> yo
</code></pre></div></div>
</li>
<li>
<p>Install the Blockstack application generator.</p>
<p>Use Yeoman and the Blockstack application generator to create your initial <codeclass="highlighter-rouge">hello-world-tutorial</code> application.</p>
<divclass="language-bash highlighter-rouge"><preclass="highlight"><code> yo blockstack
</code></pre>
</div>
<divclass="language-bash highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> yo blockstack
</code></pre></div></div>
<p>You should see several interactive prompts.</p>
<p>You can find the <codeclass="highlighter-rouge">redirectUserToSignIn()</code> function is part of the <ahref="https://blockstack.github.io/blockstack.js/">Blockstack Javascript documentation</a>. There is also a sign out button handler. This handler deletes the local user data and signs the user out:</p>
<p>Each <codeclass="highlighter-rouge">getElementById()</code> function refers to elemments in the <codeclass="highlighter-rouge">index.html</code> file.</p>
@ -563,7 +550,7 @@ several states the user can be in:</p>
<p>The application handles these situtations as followed:</p>
{"description":"Get and use a Blockstack ID","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/browser/ids-introduction.html","headline":"Get and use a Blockstack ID","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/ids-introduction.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/browser/ids-introduction.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Get and use a Blockstack ID","dateModified":"2018-10-17T09:26:44-07:00","description":"Get and use a Blockstack ID","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/ids-introduction.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
{"description":"Manage Data with Gaia","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/browser/multi-player-storage.html","headline":"Manage Data with Gaia","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/multi-player-storage.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/browser/multi-player-storage.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Manage Data with Gaia","dateModified":"2018-10-17T09:26:44-07:00","description":"Manage Data with Gaia","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/multi-player-storage.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<p>If you don’t find <codeclass="highlighter-rouge">npm</code> in your system, <ahref="https://www.npmjs.com/get-npm">install
it</a>. Finally, if you get stuck at any point
@ -279,16 +278,14 @@ existing projects.</p>
<li>
<p>Install Yeoman.</p>
<divclass="language-bash highlighter-rouge"><preclass="highlight"><code> npm install -g yo
</code></pre>
</div>
<divclass="language-bash highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> npm <spanclass="nb">install</span><spanclass="nt">-g</span> yo
</code></pre></div></div>
</li>
<li>
<p>Install the Blockstack application generator.</p>
<spanclass="s2">"1 Head of Lettuce"</span><spanclass="p">,</span>
<spanclass="s2">"Haralson apples"</span>
<spanclass="p">]</span>
<spanclass="p">},</span>
<spanclass="c1">// ...more lists with items</span>
<spanclass="p">}</span>
</code></pre>
</div>
</code></pre></div></div>
<p>This is conceptually the simplest way to manage grocery lists. When you read a
<codeclass="highlighter-rouge">/grocerylists.json</code> file with <codeclass="highlighter-rouge">getFile()</code>, you get back one or more grocery
@ -504,28 +492,26 @@ or remove a grocery list; updating a list has no impact.</p>
<p>The <codeclass="highlighter-rouge">Person</code> object holds a Blockstack profile. Add <codeclass="highlighter-rouge">putFile</code>, <codeclass="highlighter-rouge">getFile</code>,
and <codeclass="highlighter-rouge">lookupProfile</code> after <codeclass="highlighter-rouge">Person</code>.</p>
<divclass="highlighter-rouge"><preclass="highlight"><code> When you are done, the import statement should look like the following:
</code></pre>
</div>
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> When you are done, the import statement should look like the following:
<p>Replace the <codeclass="highlighter-rouge">constructor()</code> initial state so that it holds the key properties required by the app.</p>
<p>This code constructs a Blockstack <codeclass="highlighter-rouge">Person</code> object to hold the profile. Your constructor should look like this:</p>
<p>This code allows the application to post statuses. It also displays the
user’s Blockstack ID. To display this, your app must extract the ID from the
@ -620,19 +604,18 @@ user profile data.</p>
<p>You’ll use the Blockstack <codeclass="highlighter-rouge">loadUserData()</code> method to access the <codeclass="highlighter-rouge">username</code>.</p>
<p>This loads existing state. Your code needs to fetch statuses on page load.</p>
</li>
<li>
<p>Add a new method called <codeclass="highlighter-rouge">fetchData()</code> after the <codeclass="highlighter-rouge">statuses.unshift(status)</code> section.</p>
<li>Save and close the <codeclass="highlighter-rouge">src/index.js</code> file.</li>
<li>Edit the <codeclass="highlighter-rouge">src/components/App.jsx</code> file.</li>
<li>
<p>Add the new route by importing the <codeclass="highlighter-rouge">Switch</code> and <codeclass="highlighter-rouge">Route</code> components from <codeclass="highlighter-rouge">react-router-dom</code>:</p>
<p>You use <codeclass="highlighter-rouge">isLocal()</code> to check if the user is viewing the local user profile or another user’s profile. If it’s the local user profile, the app runs the <codeclass="highlighter-rouge">getFile()</code> function you added in an earlier step. Otherwise, the app looks up the profile belonging to the <codeclass="highlighter-rouge">username</code> using the <codeclass="highlighter-rouge">lookupProfile()</code> method.</p>
</li>
<li>
<p>Modify the <codeclass="highlighter-rouge">fetchData()</code> method like so:</p>
@ -963,8 +931,7 @@ process URL paths that contain the <code class="highlighter-rouge">.</code> (dot
<spanclass="p">})</span>
<spanclass="p">}</span>
<spanclass="p">}</span>
</code></pre>
</div>
</code></pre></div></div>
<p><strong>NOTE</strong>: For <codeclass="highlighter-rouge">https</code> deployments, the default Blockstack Core API endpoint for name
lookups should be changed to point to a core API served over <codeclass="highlighter-rouge">https</code>.
@ -976,7 +943,7 @@ process URL paths that contain the <code class="highlighter-rouge">.</code> (dot
<li>
<p>Add the following block to <codeclass="highlighter-rouge">fetchData()</code> right after the call to <codeclass="highlighter-rouge">lookupProfile(username)... catch((error)=>{..}</code> block:</p>
<p>### This checks to ensure that users are viewing their own profile, by wrapping the <strong>Logout</strong> button and inputs with the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">isLocal()</span><spanclass="w"></span><spanclass="err">&&</span><spanclass="w"></span><spanclass="err">...</span><spanclass="p">}</span></code> condition.</p>
<p>### This checks to ensure that users are viewing their own profile, by wrapping the <strong>Logout</strong> button and inputs with the <codeclass="highlighter-rouge">{isLocal()&&...}</code> condition.</p>
</li>
</ol>
@ -1080,9 +1045,8 @@ process URL paths that contain the <code class="highlighter-rouge">.</code> (dot
<li>
<p>Restart the application so that the disabling of the <codeclass="highlighter-rouge">.</code> (dot) rule takes effect.</p>
{"description":"Todo List Application Tutorial","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/browser/todo-list.html","headline":"Todo List Application Tutorial","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/todo-list.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/browser/todo-list.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Todo List Application Tutorial","dateModified":"2018-10-17T09:26:44-07:00","description":"Todo List Application Tutorial","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/browser/todo-list.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<li><ahref="#install-the-applicaton-code-and-retrieve-the-dependencies"id="markdown-toc-install-the-applicaton-code-and-retrieve-the-dependencies">Install the applicaton code and retrieve the dependencies</a></li>
<li><ahref="#about-this-tutorial-and-the-prerequisites-you-need"id="markdown-toc-about-this-tutorial-and-the-prerequisites-you-need">About this tutorial and the prerequisites you need</a></li>
<li><ahref="#install-the-application-code-and-retrieve-the-dependencies"id="markdown-toc-install-the-application-code-and-retrieve-the-dependencies">Install the application code and retrieve the dependencies</a></li>
<li><ahref="#sign-into-the-application"id="markdown-toc-sign-into-the-application">Sign into the application</a></li>
<li><ahref="#understand-the-sign-in-process"id="markdown-toc-understand-the-sign-in-process">Understand the sign in process</a></li>
<li><ahref="#under-the-covers-in-the-sign-in-code"id="markdown-toc-under-the-covers-in-the-sign-in-code">Under the covers in the sign in code</a></li>
<li><ahref="#undder-the-covers-in-the-sign-in-code"id="markdown-toc-undder-the-covers-in-the-sign-in-code">Undder the covers in the sign in code</a></li>
<li><ahref="#working-with-the-application"id="markdown-toc-working-with-the-application">Working with the application</a></li>
<p>If you prefer a video, you can view a <ahref="https://www.youtube.com/embed/oyvg-h0obFw">video of the tutorial</a>.</p>
<p>If you prefer a video, you can view <ahref="https://www.youtube.com/embed/oyvg-h0obFw">a video of the tutorial</a>.</p>
<h2id="prerequisites">Prerequisites</h2>
<h2id="about-this-tutorial-and-the-prerequisites-you-need">About this tutorial and the prerequisites you need</h2>
<p>For this tutorial, we will use the following tools:</p>
<p>Make sure you have <ahref="ids-introduction#create-an-initial-blockstack-id">created at least one Blockstack ID</a>. You’ll use this ID to
interact with the Todo application.</p>
<ul>
<li><codeclass="highlighter-rouge">npm</code> to manage dependencies and scripts</li>
<li><codeclass="highlighter-rouge">browserify</code> to compile node code into browser-ready code</li>
<li><codeclass="highlighter-rouge">blockstack.js</code> to authenticate the user and work with the user’s identity/profile information</li>
</ul>
<p>The applicaton code relies on both the <codeclass="highlighter-rouge">npm</code> and the <codeclass="highlighter-rouge">yarn</code> package managers.
Before you begin, verify you have these tools <codeclass="highlighter-rouge">npm</code> using the <codeclass="highlighter-rouge">which</code> command to
verify.</p>
<p>At minimum, Blockstack requires macOS High Sierra. This tutorial was written for a user running macOS High Sierra 10.13.4. The application you build is a React.js application that is completely decentralized and server-less. While not strictly required to follow along, basic familiarity with React.js is helpful.</p>
<li>looking up the profiles and statuses of other users</li>
</ul>
<p>The basic identity and storage services are provided by blockstack.js. To test the application, you need to have already registered a Blockstack ID.</p>
<p>The tutorial relies on the <codeclass="highlighter-rouge">npm</code> dependency manager. Before you begin, verify you have installed <codeclass="highlighter-rouge">npm</code> using the <codeclass="highlighter-rouge">which</code> command to verify.</p>
<p>If you don’t find <codeclass="highlighter-rouge">npm</code> in your system, <ahref="https://www.npmjs.com/get-npm">install it</a>.</p>
<p>While it stands alone, this tour relies on the information from the <ahref="hello-blockstack">Hello
Blockstack tutorial</a>. If you haven’t worked through the hello-world
tutorial, you may want to do that before continuing.</p>
<p>Finally, make sure you have <ahref="{site.baseurl}}/browser/ids-introduction.html#create-an-initial-blockstack-id">created at least one Blockstack ID</a>.
You’ll use this ID to interact with the application.</p>
<h2id="install-the-applicaton-code-and-retrieve-the-dependencies">Install the applicaton code and retrieve the dependencies</h2>
<h2id="install-the-application-code-and-retrieve-the-dependencies">Install the application code and retrieve the dependencies</h2>
<p>Clone the source code with <codeclass="highlighter-rouge">git</code> or
<ahref="https://github.com/blockstack/blockstack-todos/archive/master.zip">download and unzip the code from the repository</a>.
<p>You can clone the source code with <codeclass="highlighter-rouge">git</code> or <ahref="https://github.com/blockstack/blockstack-todos/archive/master.zip">download and unzip the code from
@ -282,14 +290,11 @@ These instructions assume you are cloning.</p>
[5/5] 📃 Building fresh packages...
success Saved lockfile.
✨ Done in 19.90s.
</code></pre>
</div>
</code></pre></div></div>
</li>
</ol>
<p>The Todo application has a basic Vue.js structure. There are several
configuration files but the crucial implementation files are in the <codeclass="highlighter-rouge">src</code>
directory:</p>
<p>The Todo application has a basic Vue.js structure. There are several configuration files but the central programming files are in the <codeclass="highlighter-rouge">src</code> directory:</p>
<table>
<thead>
@ -320,23 +325,21 @@ directory:</p>
<h2id="sign-into-the-application">Sign into the application</h2>
<p>The example application runs in a core node on your local host. In the next
section, you start the application and interact with it.</p>
<p>The example application runs in a node server on your local host. In the this section, you start the application and interact with it.</p>
<ol>
<li>
<p>Make sure you are in the root of the code base.</p>
<li>The <codeclass="highlighter-rouge">iss</code> property is a decentralized identifier or <codeclass="highlighter-rouge">did</code>. This identifies you and your name to the application. The specific <codeclass="highlighter-rouge">did</code> is a <codeclass="highlighter-rouge">btc-addr</code>.</li>
<li>The Blockstack JWT implementation is different from other implementations because of the underlying cryptography we employ. There are libraries in <ahref="https://github.com/blockstack/jsontokens-js">Javascript</a> and <ahref="https://github.com/blockstack/ruby-jwt-blockstack">Ruby</a> available on the Blockstack Github to allow you to work with these tokens.</li>
</ul>
</blockquote>
</li>
</ol>
<blockquote>
<p><strong>Notes</strong>:</p>
<ul>
<li>The <codeclass="highlighter-rouge">iss</code> property is a decentralized identifier or <codeclass="highlighter-rouge">did</code>. This identifies you and your name to the application. The specific <codeclass="highlighter-rouge">did</code> is a <codeclass="highlighter-rouge">btc-addr</code>.</li>
<li>The Blockstack JWT implementation is different from other implementations because of the underlying cryptography. There are libraries in <ahref="https://github.com/blockstack/jsontokens-js">Javascript</a> and <ahref="https://github.com/blockstack/ruby-jwt-blockstack">Ruby</a> available on the Blockstack Github to allow you to work with these tokens.</li>
</ul>
</blockquote>
<p>When the Blockstack node receives the <codeclass="highlighter-rouge">authRequest</code>, it generates a
session token and returns an authentication response to the application. This
response is similar to the <codeclass="highlighter-rouge">authRequest</code> above in that the <codeclass="highlighter-rouge">authResponse</code>
includes a private key intended only for the application. This allows the
application to encrypt data on your personal Blockstack storage.</p>
<p>When the Blockstack node receives the <codeclass="highlighter-rouge">authRequest</code>, it generates a session token
and returns an authentication response to the application. This response is
similar to the <codeclass="highlighter-rouge">authRequest</code> above in that the <codeclass="highlighter-rouge">authResponse</code> includes a private key
intended only for the application. This allows the application to encrypt data
on your personal Blockstack storage.</p>
<p>After the completion of this process, the user is loggged in.</p>
<p>After the completion of this process, the user is logged in.</p>
<h2id="under-the-covers-in-the-sign-in-code">Under the covers in the sign in code</h2>
<h2id="undder-the-covers-in-the-sign-in-code">Undder the covers in the sign in code</h2>
<p>Go to the underlying <codeclass="highlighter-rouge">blockstack-todo</code> code you cloned or downloaded. Sign
<p>Now, go to the underlying <codeclass="highlighter-rouge">blockstack-todo</code> code you cloned or downloaded. Sign
in and sign out is handled in each of these files:</p>
<table>
@ -449,18 +451,17 @@ in and sign out is handled in each of these files:</p>
</tbody>
</table>
<p>The <codeclass="highlighter-rouge">src/components/Landing.vue</code> code calls a <ahref="https://blockstack.github.io/blockstack.js#redirectToSignIn"><codeclass="highlighter-rouge">redirectToSignIn()</code></a> function which generates the <codeclass="highlighter-rouge">authRequest</code> and redirects the user to the Blockstack browser:</p>
<p>The <codeclass="highlighter-rouge">src/components/Landing.vue</code> code calls a <ahref="https://blockstack.github.io/blockstack.js#redirectToSignIn"><codeclass="highlighter-rouge">redirectToSignIn()</code></a> function which generates the <codeclass="highlighter-rouge">authRequest</code> and redirects the user to the Blockstack authenticator:</p>
<p>Once the user authenticates, the application handles the <codeclass="highlighter-rouge">authResponse</code> in the <codeclass="highlighter-rouge">src/App.vue</code> file. :</p>
<p>If <ahref="https://blockstack.github.io/blockstack.js/#isusersignedin"><codeclass="highlighter-rouge">blockstack.isUserSignedIn()</code></a> is true, the user was previously signed in so Blockstack pulls the data from the browser and uses it in the application. If the check on <ahref="https://blockstack.github.io/blockstack.js/#issigninpending"><codeclass="highlighter-rouge">blockstack.isSignInPending()</code></a> is true, a previous <codeclass="highlighter-rouge">authResponse</code> was sent to the application but hasn’t been processed yet. The <codeclass="highlighter-rouge">handlePendingSignIn()</code> function processes any pending sign in.</p>
<p>If <ahref="https://blockstack.github.io/blockstack.js/#isusersignedin"><codeclass="highlighter-rouge">blockstack.isUserSignedIn()</code></a> is true, the user was previously signed in so Blockstack pulls the data from the browser and uses it in our application. If the check on <ahref="https://blockstack.github.io/blockstack.js/#issigninpending"><codeclass="highlighter-rouge">blockstack.isSignInPending()</code></a> is true, a previous <codeclass="highlighter-rouge">authResponse</code> was sent to the application but hasn’t been processed yet. The <codeclass="highlighter-rouge">handlePendingSignIn()</code> function processes any pending sign in.</p>
<p>Signout is handled in the<codeclass="highlighter-rouge">src/components/Dashboard.vue</code> code.</p>
<p>Signout is handled in <codeclass="highlighter-rouge">src/components/Dashboard.vue</code>.</p>
</span><spanclass="nt">"text"</span><spanclass="p">:</span><spanclass="s2">"Software package manager secured by the blockchain"</span><spanclass="p">,</span><spanclass="w">
</span><spanclass="s2">"text"</span><spanclass="p">:</span><spanclass="s2">"Software package manager secured by the blockchain"</span><spanclass="p">,</span><spanclass="w">
</span><spanclass="nt">"text"</span><spanclass="p">:</span><spanclass="s2">"Mutable torrents with human readable names"</span><spanclass="p">,</span><spanclass="w">
</span><spanclass="s2">"text"</span><spanclass="p">:</span><spanclass="s2">"Mutable torrents with human readable names"</span><spanclass="p">,</span><spanclass="w">
</span><spanclass="nt">"text"</span><spanclass="p">:</span><spanclass="s2">"Software package manager secured by the blockchain"</span><spanclass="p">,</span><spanclass="w">
</span><spanclass="s2">"text"</span><spanclass="p">:</span><spanclass="s2">"Software package manager secured by the blockchain"</span><spanclass="p">,</span><spanclass="w">
<p>The code needs to read the Todo items from the storage with the <ahref="https://blockstack.github.io/blockstack.js/#getfile"><codeclass="highlighter-rouge">blockstack.getFile()</code></a> method which returns a promise:</p>
<spanclass="nx">blockstack</span><spanclass="p">.</span><spanclass="nx">getFile</span><spanclass="p">(</span><spanclass="nx">STORAGE_FILE</span><spanclass="p">)</span><spanclass="c1">// decryption is enabled by default</span>
<p>The <codeclass="highlighter-rouge">todos</code> data is retrieved from the promise.</p>
<h2id="summary">Summary</h2>
<p>You now have everything you need to construct complex applications complete with authentication and storage on the Decentralized Internet. Why not try coding <ahref="/browser/multi-player-storage.html">a sample application that accesses multiple profiles</a>.</p>
<p>You now have everything you need to construct complex applications complete with authentication and storage on the Decentralized Internet. Why not try coding <ahref="multi-player-storage.md">a sample application that accesses multiple profiles</a>.</p>
<p>If you would like to explore the Blockstack APIs, you can visit the <ahref="https://core.blockstack.org/">Blockstack Core API</a> documentation or the <ahref="https://blockstack.github.io/blockstack.js">Blockstack JS API</a>.</p>
{"description":"Docs","author":{"@type":"Person","name":"Blockstack"},"@type":"WebPage","url":"https://docs.blockstack.org/contact/","headline":"Got Any Questions?","@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/contact/","author":{"@type":"Person","name":"Blockstack"},"headline":"Got Any Questions?","description":"Docs","@type":"WebPage","@context":"http://schema.org"}</script>
{"description":"How to Use the Atlas Network","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/atlas/howtouse.html","headline":"How to Use the Atlas Network","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/atlas/howtouse.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/atlas/howtouse.html","author":{"@type":"Person","name":"Blockstack"},"headline":"How to Use the Atlas Network","dateModified":"2018-10-17T09:26:44-07:00","description":"How to Use the Atlas Network","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/atlas/howtouse.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
@ -316,7 +321,7 @@ chunk data. A client can query up to 100 chunks in one RPC call.</p>
the returned payload will be a <codeclass="highlighter-rouge">dict</code> with a <codeclass="highlighter-rouge">zonefiles</code> key that maps the chunk
<spanclass="o">>>></span><spanclass="n">data</span><spanclass="o">=</span><spanclass="s">"..."</span><spanclass="c"># this is the chunk data you will announce</span>
<spanclass="o">>>></span><spanclass="n">data</span><spanclass="o">=</span><spanclass="s">"..."</span><spanclass="c1"># this is the chunk data you will announce
<spanclass="o">>>></span><spanclass="n">data</span><spanclass="o">=</span><spanclass="s">"..."</span><spanclass="c"># this is the chunk you will replicate widely</span>
<spanclass="o">>>></span><spanclass="n">data</span><spanclass="o">=</span><spanclass="s">"..."</span><spanclass="c1"># this is the chunk you will replicate widely
{"description":"Overview of the Atlas network","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/atlas/overview.html","headline":"Overview of the Atlas network","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/atlas/overview.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/atlas/overview.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Overview of the Atlas network","dateModified":"2018-10-17T09:26:44-07:00","description":"Overview of the Atlas network","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/atlas/overview.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
{"description":"Understand the Architecture","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/architecture.html","headline":"Understand the Architecture","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/architecture.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/architecture.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Understand the Architecture","dateModified":"2018-10-17T09:26:44-07:00","description":"Understand the Architecture","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/architecture.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
{"description":"Naming system feature comparison","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/comparison.html","headline":"Naming system feature comparison","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/comparison.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/comparison.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Naming system feature comparison","dateModified":"2018-10-17T09:26:44-07:00","description":"Naming system feature comparison","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/comparison.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
{"description":"Creating a Namespace","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/creationhowto.html","headline":"Creating a Namespace","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/creationhowto.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/creationhowto.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Creating a Namespace","dateModified":"2018-10-17T09:26:44-07:00","description":"Creating a Namespace","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/creationhowto.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<li><codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">address</span><spanclass="p">}</span></code> is an on-chain public key hash (e.g. a Bitcoin address).</li>
<li><codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">index</span><spanclass="p">}</span></code> refers to the <codeclass="highlighter-rouge">nth</code> name this address created.</li>
<li><codeclass="highlighter-rouge">{address}</code> is an on-chain public key hash (e.g. a Bitcoin address).</li>
<li><codeclass="highlighter-rouge">{index}</code> refers to the <codeclass="highlighter-rouge">nth</code> name this address created.</li>
</ul>
<p>For example, the DID for <codeclass="highlighter-rouge">personal.id</code> is
@ -345,20 +349,20 @@ for subdomains, so the software can determine which code-path to take.</p>
<ul>
<li>
<p>For on-chain BNS names, the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">address</span><spanclass="p">}</span></code> is the same as the Bitcoin address
<p>For on-chain BNS names, the <codeclass="highlighter-rouge">{address}</code> is the same as the Bitcoin address
that owns the name. Currently, both version byte 0 and version byte 5
addresses are supported (i.e. addresses starting with <codeclass="highlighter-rouge">1</code> or <codeclass="highlighter-rouge">3</code>, meaning <codeclass="highlighter-rouge">p2pkh</code> and
<p>For off-chain BNS subdomains, the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">address</span><spanclass="p">}</span></code> has version byte 63 for
<p>For off-chain BNS subdomains, the <codeclass="highlighter-rouge">{address}</code> has version byte 63 for
subdomains owned by a single private key, and version byte 50 for subdomains
owned by a m-of-n set of private keys. That is, subdomain DID addresses start
with <codeclass="highlighter-rouge">S</code> or <codeclass="highlighter-rouge">M</code>, respectively.</p>
</li>
</ul>
<p>The <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">index</span><spanclass="p">}</span></code> field for a subdomain’s DID is distinct from the <codeclass="highlighter-rouge"><spanclass="p">{</span><spanclass="err">index</span><spanclass="p">}</span></code> field
<p>The <codeclass="highlighter-rouge">{index}</code> field for a subdomain’s DID is distinct from the <codeclass="highlighter-rouge">{index}</code> field
for a BNS name’s DID, even if the same created both names and subdomains.
For example, the name <codeclass="highlighter-rouge">abcdefgh123456.id</code> has the DID <codeclass="highlighter-rouge">did:stack:v0:16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg-0</code>,
because it was the first name created by <codeclass="highlighter-rouge">16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg</code>.
@ -372,7 +376,7 @@ second is encoded with version byte 63).</p>
<p>You can see this play out in practice with the following code snippit:</p>
{"description":"Blockstack Naming Service (BNS)","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/introduction.html","headline":"Blockstack Naming Service (BNS)","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/introduction.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/introduction.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Blockstack Naming Service (BNS)","dateModified":"2018-10-17T09:26:44-07:00","description":"Blockstack Naming Service (BNS)","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/introduction.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
{"description":"Choose a name","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/pickname.html","headline":"Choose a name","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/pickname.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/pickname.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Choose a name","dateModified":"2018-10-17T09:26:44-07:00","description":"Choose a name","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/pickname.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<h2id="list-all-namespaces-in-existence-reference">List all namespaces in existence (<ahref="https://core.blockstack.org/#namespace-operations-get-all-namespaces">reference</a>).</h2>
<h2id="list-all-names-within-a-namespace-reference">List all names within a namespace (<ahref="https://core.blockstack.org/#namespace-operations-get-all-namespaces">reference</a>)</h2>
<h2id="get-the-cost-to-register-a-namespace-reference">Get the Cost to Register a Namespace (<ahref="https://core.blockstack.org/#price-checks-get-namespace-price">reference</a>)</h2>
<p>If you want to register a namespace, please see the <ahref="/core/naming/namespace.html">namespace creation section</a>.</p>
<h2id="getting-the-current-consensus-hash-reference">Getting the Current Consensus Hash (<ahref="https://core.blockstack.org/#blockchain-operations-get-consensus-hash">reference</a>)</h2>
{"description":"Register a name","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/register.html","headline":"Register a name","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/register.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/register.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Register a name","dateModified":"2018-10-17T09:26:44-07:00","description":"Register a name","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/register.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<p>Note the use of <codeclass="highlighter-rouge">jq -r</code> to select the <codeclass="highlighter-rouge">"name_price"</code> field. This API
endpoint may return other ancilliary data regarding transaction fee estimation,
@ -376,12 +380,11 @@ but this is the only field guaranteed by this specification to be present.</p>
<h2id="getting-the-current-consensus-hash-reference">Getting the Current Consensus Hash (<ahref="https://core.blockstack.org/#blockchain-operations-get-consensus-hash">reference</a>)</h2>
{"description":"Resolve a name","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/resolving.html","headline":"Resolve a name","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/resolving.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/resolving.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Resolve a name","dateModified":"2018-10-17T09:26:44-07:00","description":"Resolve a name","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/resolving.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<h2id="look-up-a-names-public-key-and-zone-file-reference">Look up a name’s public key and zone file (<ahref="https://core.blockstack.org/#name-querying-get-name-info">reference</a>)</h2>
<p>Note that the <codeclass="highlighter-rouge">zonefile</code> field is given with the off-chain data that hashes
to the <codeclass="highlighter-rouge">zonefile_hash</code> field.</p>
<h2id="list-all-names-the-node-knows-about-reference">List all names the node knows about (<ahref="https://core.blockstack.org/#name-querying-get-all-names">reference</a>)</h2>
@ -415,8 +419,7 @@ to the <code class="highlighter-rouge">zonefile_hash</code> field.</p>
<spanclass="s2">"df.id"</span>,
...
<spanclass="o">]</span>
</code></pre>
</div>
</code></pre></div></div>
<p>Each page returns 100 names. While no specific ordering is mandated by the
protocol, the reference implementation orders names by their order of creation
@ -424,7 +427,7 @@ in the blockchain.</p>
<h2id="look-up-the-history-of-states-a-name-was-in-reference">Look up the history of states a name was in (<ahref="https://core.blockstack.org/#name-querying-name-history">reference</a>)</h2>
<p>All of the above information is extracted from the blockchain. Each top-level
field encodes the states the name transitioned to at the given block height (e.g.
@ -552,7 +554,7 @@ under its previous owner, if the name expired and was reregistered.</p>
<h2id="look-up-the-list-of-names-owned-by-a-given-public-key-hash-reference">Look up the list of names owned by a given public key hash (<ahref="https://core.blockstack.org/#name-querying-get-names-owned-by-address">reference</a>)</h2>
{"description":"How to build a Profile Search Index","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/search.html","headline":"How to build a Profile Search Index","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/search.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/search.html","author":{"@type":"Person","name":"Blockstack"},"headline":"How to build a Profile Search Index","dateModified":"2018-10-17T09:26:44-07:00","description":"How to build a Profile Search Index","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/search.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<p><strong>Step 2:</strong> Make sure you have Blockstack Core running locally (see <ahref="https://github.com/blockstack/blockstack-core/blob/master/README.md#quick-start">instructions</a>). We highly
@ -329,38 +332,34 @@ Blockstack Core for re-indexing and remote nodes can slow down performance.</p>
<li><strong>Step 3:</strong> Fetch the data for the .id namespace and respective profiles. Note, you may want to redirect stderr to a file, as there is a lot of debug output.</li>
</ul>
<divclass="highlighter-rouge"><preclass="highlight"><code>$ cd api/
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>$ cd api/
$ python -m search.fetch_data --fetch_namespace
$ python -m search.fetch_data --fetch_profiles
</code></pre>
</div>
</code></pre></div></div>
<ul>
<li><strong>Step 4:</strong> Create the search index:</li>
</span><spanclass="nt">"addressLocality"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"New York, NY"</span><spanclass="p">,</span><spanclass="w">
</span><spanclass="nt">"description"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"Co-founder of Blockstack. Interested in distributed systems and blockchains. Previously, PhD at Princeton."</span><spanclass="w">
</span><spanclass="nt">"message"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"This blockchain ID is reserved for Muneeb Ali. If this is you, please email support@onename.com to claim it for free."</span><spanclass="p">,</span><spanclass="w">
<p>For example, the name <codeclass="highlighter-rouge">verified.podcast</code> once wrote the zone file hash <codeclass="highlighter-rouge">247121450ca0e9af45e85a82e61cd525cd7ba023</code>,
<spanclass="s2">"zonefile_txt"</span>: <spanclass="s2">"</span><spanclass="nv">$ORIGIN</span><spanclass="s2"> 1yeardaily</span><spanclass="se">\n</span><spanclass="nv">$TTL</span><spanclass="s2"> 3600</span><spanclass="se">\n</span><spanclass="s2">_http._tcp URI 10 1 </span><spanclass="se">\"</span><spanclass="s2">https://ph.dotpodcast.co/1yeardaily/head.json</span><spanclass="se">\"\n</span><spanclass="s2">"</span>
<spanclass="o">}</span>
</code></pre>
</div>
</code></pre></div></div>
<p>This information was extracted from the <codeclass="highlighter-rouge">1yeardaily</code><codeclass="highlighter-rouge">TXT</code> resource record in the zone
file for <codeclass="highlighter-rouge">verified.podcast</code>.</p>
@ -381,7 +384,7 @@ updates; only the owner of <code class="highlighter-rouge">1yeardaily.verified.p
<p>The lifecycle of a subdomain and its operations is shown in Figure 2.</p>
@ -413,8 +416,7 @@ Thesubdomain-creation and subdomain-transfer transactions for
"cicero.res_publica.id" are broadcast by the owner of "res_publica.id".
However, any on-chain name ("jude.id" in this case) can broadcast a subdomain
update for "cicero.res_publica.id".
</code></pre>
</div>
</code></pre></div></div>
<p>Subdomain operations are ordered by sequence number, starting at 0. Each new
subdomain operation must include:</p>
@ -442,7 +444,7 @@ Using the BNS API, a developer can:</p>
<h3id="look-up-a-subdomains-public-key-and-zone-file-reference">Look up a subdomain’s public key and zone file (<ahref="https://core.blockstack.org/#name-querying-get-name-info">reference</a>)</h3>
<spanclass="s2">"zonefile_txt"</span>: <spanclass="s2">"</span><spanclass="nv">$ORIGIN</span><spanclass="s2"> aaron.personal.id</span><spanclass="se">\n</span><spanclass="nv">$TTL</span><spanclass="s2"> 3600</span><spanclass="se">\n</span><spanclass="s2">_https._tcp URI 10 1 </span><spanclass="se">\"</span><spanclass="s2">https://gaia.blockstack.org/hub/1PwztPFd1s2STMv4Ntq6UPBdYgHSBr5pdF/profile.json</span><spanclass="se">\"\n</span><spanclass="s2">"</span>
<spanclass="o">}</span>
</code></pre>
</div>
</code></pre></div></div>
<h3id="look-up-a-subdomains-transaction-history-reference">Look up a subdomain’s transaction history (<ahref="https://core.blockstack.org/#name-querying-name-history">reference</a>)</h3>
@ -471,19 +472,17 @@ Using the BNS API, a developer can:</p>
<spanclass="o">}</span>
<spanclass="o">]</span>
<spanclass="o">}</span>
</code></pre>
</div>
</code></pre></div></div>
<h3id="look-up-the-list-of-names-and-subdomains-owned-by-a-given-public-key-hash-reference">Look up the list of names and subdomains owned by a given public key hash (<ahref="https://core.blockstack.org/#name-querying-get-names-owned-by-address">reference</a>)</h3>
{"description":"Subdomain Design and Implementation","author":{"@type":"Person","name":"Blockstack"},"@type":"BlogPosting","url":"https://docs.blockstack.org/core/naming/tutorial_subdomains.html","headline":"Subdomain Design and Implementation","dateModified":"2018-09-27T16:58:29-07:00","datePublished":"2018-09-27T16:58:29-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/tutorial_subdomains.html"},"@context":"http://schema.org"}</script>
{"url":"https://docs.blockstack.org/core/naming/tutorial_subdomains.html","author":{"@type":"Person","name":"Blockstack"},"headline":"Subdomain Design and Implementation","dateModified":"2018-10-17T09:26:44-07:00","description":"Subdomain Design and Implementation","datePublished":"2018-10-17T09:26:44-07:00","mainEntityOfPage":{"@type":"WebPage","@id":"https://docs.blockstack.org/core/naming/tutorial_subdomains.html"},"@type":"BlogPosting","@context":"http://schema.org"}</script>
<p>Or, if the subdomain has already been submitted in a transaction:</p>
<divclass="highlighter-rouge"><preclass="highlight"><code><spanclass="p">{</span><spanclass="nt">"status"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"Your subdomain was registered in transaction 09a40d6ea362608c68da6e1ebeb3210367abf7aa39ece5fd57fd63d269336399 -- it should propagate on the network once it has 6 confirmations."</span><spanclass="p">}</span><spanclass="w">
</span></code></pre>
</div>
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>{"status": "Your subdomain was registered in transaction 09a40d6ea362608c68da6e1ebeb3210367abf7aa39ece5fd57fd63d269336399 -- it should propagate on the network once it has 6 confirmations."}
</code></pre></div></div>
<p>If the subdomain still hasn’t been submitted yet:</p>
<divclass="highlighter-rouge"><preclass="highlight"><code><spanclass="p">{</span><spanclass="nt">"status"</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s2">"Subdomain is queued for update and should be announced within the next few blocks."</span><spanclass="p">}</span><spanclass="w">
</span></code></pre>
</div>
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>{"status": "Subdomain is queued for update and should be announced within the next few blocks."}
</code></pre></div></div>
<p>If an error occurred trying to submit the <codeclass="highlighter-rouge">UPDATE</code> transaction, this endpoint will return an error
message in the <codeclass="highlighter-rouge">"error"</code> key of a JSON object.</p>
@ -501,7 +497,7 @@ The endpoints which <em>are</em> subdomain aware are marked as such in
<p>The lookups work just like normal – it returns the user’s
<p>The API endpoints <codeclass="highlighter-rouge">/v1/users/<foo.bar.tld></code>,
<codeclass="highlighter-rouge">/v1/names/<foo.bar.tld></code>, and <codeclass="highlighter-rouge">/v1/addresses/bitcoin/<foo.bar.tld></code> all work, so if you query the core API, you’ll get a response.</p>
"zonefile_txt": "$ORIGIN bar\n$TTL 3600\n_file URI 10 1 \"file:///tmp/baz.profile.json\"\n"
}
</code></pre></div></div>
<h3id="running-an-interactive-testing-environment-with-the-subdomain-registrar-service">Running an interactive testing environment with the Subdomain Registrar service</h3>
@ -612,9 +601,8 @@ correct environment variables for it to run).</p>
<p>Here’s the full command you’d run to start the interactive testing scenario:</p>
magic op hash128(name.ns_id,consensus hash) zone file hash
</code></pre>
</div>
</code></pre></div></div>
<p>Note that <codeclass="highlighter-rouge">hash128(name.ns_id, consensus hash)</code> is the first 16 bytes of a SHA256 hash over the name concatenated to the hexadecimal string of the consensus hash (not the bytes corresponding to that hex string).
See the <ahref="#method-glossary">Method Glossary</a> below.</p>
<h2 id="example-of-code-block">Example Of Code Block</h2>
<p>In accumsan lacus ac neque maximus dictum. Phasellus eleifend leo id mattis bibendum. Curabitur et purus turpis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;</p>
<h2 id="text-and-quote">Text and Quote</h2>
<p>Cras at dolor eget urna varius faucibus tempus in elit. Cras a dui imperdiet, tempus metus quis, pharetra turpis. Phasellus at massa sit amet ante semper fermentum sed eget lectus. Quisque id dictum magna turpis.</p>
<h3id="use-npm-to-install-yeoman-and-the-blockstack-app-generator">Use npm to install Yeoman and the Blockstack App Generator</h3>
@ -332,16 +329,14 @@ existing projects.</p>
<li>
<p>Install Yeoman.</p>
<divclass="language-bash highlighter-rouge"><preclass="highlight"><code> npm install -g yo
</code></pre>
</div>
<divclass="language-bash highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> npm <spanclass="nb">install</span><spanclass="nt">-g</span> yo
</code></pre></div></div>
</li>
<li>
<p>Install the Blockstack application generator.</p>
<p>The command creates a <codeclass="highlighter-rouge">Podfile</code> in the directory.</p>
</li>
@ -595,7 +579,7 @@ lines after.</p>
<li>
<p>Add a line stating the Blockstack dependency.</p>
<divclass="highlighter-rouge"><preclass="highlight"><code># Uncomment the next line to define a global platform for your project
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code># Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'hello-blockstack-ios' do
@ -610,8 +594,7 @@ target 'hello-blockstack-ios' do
# Pods for testing
end
end
</code></pre>
</div>
</code></pre></div></div>
</li>
<li>Save and close the <codeclass="highlighter-rouge">Podfile</code>.</li>
</ol>
@ -624,7 +607,7 @@ end
<li>
<p>Initialize the project with Cocoapods.</p>
<divclass="highlighter-rouge"><preclass="highlight"><code> $ pod install
<divclass="highlighter-rouge"><divclass="highlight"><preclass="highlight"><code> $ pod install
Analyzing dependencies
Downloading dependencies
Installing Blockstack (0.2.0)
@ -637,20 +620,18 @@ end
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
[!] Automatically assigning platform `ios` with version `11.4` on target `hello-blockstack-ios` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
</code></pre>
</div>
</code></pre></div></div>
<p>This command creates a number of files</p>
</li>
<li>
<p>Review the files that the <codeclass="highlighter-rouge">pod</code> installation created:</p>
<p>Immediately after scenes but before the close of the <codeclass="highlighter-rouge"></document></code> tag add the following <codeclass="highlighter-rouge"><resources></code>.</p>
<p>Choose <strong>Run > Run app</strong> in the emulator.</p>
@ -798,7 +777,7 @@ functionality to your code.</p>
<li>
<p>Within the <codeclass="highlighter-rouge"><viewController></code> element, replace the existing <codeclass="highlighter-rouge"><view></code> subelement with the following:</p>
<p>Just before the <codeclass="highlighter-rouge">didReceiveMemoryWarning</code> function a private <codeclass="highlighter-rouge">updateUI()</code> function.</p>
<p>This function takes care of loading the user data from Blockstack.</p>