Punica Box

Interplanetary Album Box

A box has all you need to get started with IPFS and ONT ID(Interplanetary Album) tutorial.


Getting Started

Setting up the development environment

There are a few technical requirements before we start. Please install the following:

Unboxing the dApp

Install Punica CLI.
$ pip3 install punica
Download the interplanetary-album-box.
$ punica unbox interplanetary-album
Create virtual environments (optional).
$ virtualenv --no-site-packages venv
If you choose to create a virtual environment, you may need to activate your project's virtual environment. firstly
Install the necessary dependencies.
$ pip3 install -r requirements.txt

Initialize IPFS Repository

The IPFS stores all its settings and internal data in a directory called the repository. Before using IPFS for the first time, you’ll need to initialize the repository with the ipfs init command:
$ ipfs init
initializing IPFS node at .ipfs
generating 2048-bit RSA keypair...done
peer identity: QmbhtBLaPLLUXgon7Quue1JkLjRmoQmm97cqto9JdJ4KuR
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
The hash after peer identity is your node’s ID and will be different from the one shown in the above output. Other nodes on the network use it to find and connect to you. You can run ipfs id at any time to get it again if you need it.

Create Private IPFS Network (optional)

The IPFS bootstrap list is a list of peers with which the IPFS daemon learns about other peers on the network. You can get you IPFS bootstrap list by bootstrap command.
$ ipfs bootstrap
You must understand the risks of adding or removing nodes form IPFS node's bootstrap list, before you do it.
IPFS comes with a default list of trusted peers, but you are free to modify the list to suit your needs. Therefore, If you want to create your own IPFS network, you need to remove the default list of trusted peers, and add the peers that you trusted.
$ ipfs bootstrap rm --all
With an empty list, we can restore the default bootstrap list by --default option.
$ ipfs bootstrap add --default
To be extra cautious, You can also set the LIBP2P_FORCE_PNET environment variable to 1 to force the usage of private networks. If no private network is configured, the daemon will fail to start.
$ export LIBP2P_FORCE_PNET=1
To create a private network, we also need to create a swarm.key file to enable private network feature of IPFS. We will start by adding a key called the swarm.key that tells the IPFS nodes that they will be a part of a private network which all will share this swarm.key file.
$ go get -u github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen
After install this utility successful, you can run it in one of your node like this:
$ ipfs-swarm-key-gen > ~/.ipfs/swarm.key
After that, you need to copy the file generated to the IPFS directory of each node.
Now, you can add your new bootstrap node to build your private network.
$ipfs bootstrap add /ip4/
added /ip4/

Run IPFS Node

Before we run our dApp, we need to run our IPFS node as a daemon.
$ ipfs daemon
Initializing daemon...
Swarm is limited to private network of peers with the swarm key
Swarm key fingerprint: e06fa4c6c256f4524bc3abb4a1515556
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmauvPUxzGN32aBtHXGRGCbNPxkpCA5ZFc637ABFjGe2mF
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip4/
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/
Gateway (readonly) server listening on /ip4/
Daemon is ready

Run your dApp

At this point, you can run the dApp in your browser:
python3 interplanetary_album.py
If everything goes smoothly, your dApp will run on, and your IPFS node will run on
If you want to quit it, you can press CTRL+C or close the terminal.