<p>To participate in application mining your application must integrate Blockstack authentication.
</p>
</div>
### Get and put user data to a Gaia Hub
Gaia is the Blockstack data storage hub (https://hub.blockstack.org). Once a user
authenticates, the application can get and put application data in the user's
storage. After a user signs in, the `SignedIn.js` code checks the user's Gaia
profile by running the `loadMe()` method.
```js
loadMe() {
const options = { decrypt: false }
this.userSession.getFile(ME_FILENAME, options)
.then((content) => {
if(content) {
const me = JSON.parse(content)
this.setState({me, redirectToMe: false})
} else {
const me = null
this.setState({me, redirectToMe: true})
}
})
}
```
Most of the imports in this file are locally coded React components. For example, `Kingdom.js`, `EditMe.js`, and `Card.js`. The key Blockstack imports is the `UserSession` and an `appConfig` which is defined in the `constants.js` file.
The `loadMe()` code uses the Blockstack's `UserSession.getFile()` method to get
the specified file from the applications data store. If the users' data store on
Gaia does not have the data, which is the case for new users, the Gaia hub
responds with HTTP `404` code and the `getFile` promise resolves to null. If you
are using a Chrome Developer Tools with the DApp, you'll see these errors in a
browser's developer **Console**.
<imgsrc="images/kingdom-errors.png"alt="">
After a user chooses an animal persona and a territory, the user presses **Done**
The Blockstack <ahref="https://blockstack.github.io/blockstack.js/#putfile"
target="\_blank"><code>putFile()</code></a> stores the data provided in the
user's DApp data store. You can view the URL for the data store from a user's
profile.
If you tested your Animal Kingdom, you can see this on your profile. To see your
profile, go to the <ahref="https://explorer.blockstack.org">Blockstack
explorer</a> and search for your ID:
<imgsrc="images/explorer.png"alt="">
<divclass="uk-card uk-card-default uk-card-body">
<h5>App Mining Optional: Gaia Storage</h5>
<p>Use of Gaia storage is not required for application mining. Keep in mind, using Gaia may make data storage easier as it is designed to work in the Blockstack Ecosystem.
</p>
</div>
### Application configuration
Your DApp contains three pages **Animals**, **Territories**, and **Other
Kingdoms** that are derived from three code elements:
* The `src/constants.js` file defines the application's data profile (`AppConfig`).
* The `public\animals` directory which contains images.
* The `public\territories` directory which contains images.
In the next section, you extend your Kingdom's configuration by modifying these files.
## Add a territory
If your application is still running in localhost stop it with a `CTRL-C` from
your keyboard.
1. Decide what kind of territory to add — desert, ocean, or city!
This example adds Westeros, a fictional territory.
2. Search for an image to represent your new territory.
Google images is a good place to find <ahref="images/westeros.jpg"target="\_blank">a JPEG image of Westeros</a>.
3. Save the image to the `public/territories` folder in your Animal Kingdom project code.
{% include warning.html content="The territory filename must be all lower case and have a <code>.jpg</code> extension.
For this example, the territory image is saved in the <code>westeros.jpg</code> file." %}
4. Use the `ls` command to confirm your file appears in `territories` directory and has the correct name.
```bash
PS C:\animal-kingdom-master> ls .\public\territories\
<p>To participate in application mining your application must be available for review. Open source projects must provide the URL to their code. Projects with private repositories can provide their application in a package form.
</p>
</div>
Before you begin, you need to build a site that is ready to deploy.
1. In your terminal, press `CTRL-C` on your keyboard to stop your `npm start` build.
2. Build a website from your code by entering the `npm run build` command:
```bash
npm run build
```
<imgsrc="images/run-build-win.png"alt="">
When the command completes, you should have a new `build` subdirectory in your project.
3. Open your project in the Finder.
4. Locate the newly created `build` subfolder.
<imgsrc="images/finder-build-win.png"alt="">
5.<ahref="https://app.netlify.com/signup"target="\_blank">Sign up for a free Netlify account</a>
This example assumes you create an account by providing an email and password.
<imgsrc="images/netlify-account.gif"alt="">
6. In your email inbox, find Netlify's welcome email and verify your account.
<imgsrc="images/netlify-verify.png"alt="">
7. Log into Netlify and go to the **Overview** page in your browser.
8. Drag your `build` subdirectory from the Finder into the drop zone in Netlify.
<imgsrc="images/netlify-deploy.gif"alt="">
After a moment, Netlify builds your code and displays the location of your new website.
<imgsrc="images/kingdom-build.png"alt="">
9. Click on your website name to display the website.
You are prompted to sign into this new site with your Blockstack ID.
10. Click **Sign in with Blockstack**.
After you sign in, your website presents you with this message:
<imgsrc="images/kingdom-failed.png"alt="">
You get this message because, when you authenticate, your DApp at one URL
requested a resource (an identity) from another DApp, the Blockstack
Browser. A request for a resource outside of the origin (your new website)
is called as a _cross-origin request_(CORs). Getting data in this manner can
be risky, so you must configure your website security to allow interactions
across origins.
<divclass="uk-inline">
<buttonclass="uk-button uk-button-primary"enter="button">Click me to learn how CORS is like borrowing a ladder.</button>
<divuk-dropdown>
You can think of CORS interactions as an apartment building with Security.
For example, if you need to borrow a ladder, you could ask a neighbor in
your building who has one. Security would likely not have a problem with
this request (i.e., same-origin, your building). If you needed a particular
tool, however, and you ordered it delivered from an online hardware store
(i.e., cross-origin, another site), Security may request identification
before allowing the delivery man into the apartment building.
The Animal Kingdom is identified by its location on the Internet, remember?
So, the animal kingdom you created on your local workstation is different
than the one you create on Netlify.
## Add your Kingdom to our Clan
At this point, your kingdom is isolated. If you know another kingdom, you can
add subjects from that kingdom but other kingdoms can't access your subjects. In
this section, you use a free GitHub account to add your kingdom to the
Blockstack kingdom.
1. If you have a GitHub account, go to step 2 otherwise go to GitHub <ahref="https://github.com/"target="\_blank">site and create a new account</a>.
2. Go to the <ahref="https://github.com/blockstack/animal-kingdom/issues"target="\_blank">https://github.com/blockstack/animal-kingdom/issues</a> repository on Github.
2. Click **New Issue**.
The new issue dialog appears.
3. Fill out the issue with the URL from Netlify and your Blockstack id.
When you are done, your issue will look like the following:
<imgsrc="images/kingdom-issue.png"alt="">
4. Press **Submit new issue**.
The Blockstack team will add your Netlify kingdom to ours. When we do that, we will notify you on the issue and you'll also get an email.
5. When you receive the email, login to the Blockstack Animal kingdom to see your kingdom under **Other Kingdoms**.
## Next steps (and a cool tshirt!)
{:.no_toc}
In the next part, you learn about how application mining can fund your DApp
development efforts. And you will take a couple of minutes to [add your Animal Kingdom DApp to App.co
— the Universal App store](zero_to_dapp_4.html). Completing this step earns you a
limited edition t-shirt.
If you have a twitter account, why not tell some folks about your progress?