DEV Community

azwyane
azwyane

Posted on • Originally published at altechnep.blogspot.com on

Configuring IPFS part 2

Now we need to install our required dependencies.

GETTING IPFS :

To install IPFS, Go makes it relatively straightforward to install dependencies directly from its source.

In you console type:

$ go get -d github.com/ipfs/go-ipfs $ cd /go/src/github.com/ipfs/go-ipfs$ make install
Enter fullscreen mode Exit fullscreen mode

We now need to install ipfs-update module.For that go to here and download the zip file then extract it to the go/src/github.com/ipfs/go-ipfs Then open the terminal, at that position inside ipfs-update and type:

$ ./install.sh
Enter fullscreen mode Exit fullscreen mode

Now, again type :

$ ipfs-update

$ ipfs-update versions

$ ipfs-update install \<your selected version\>
Enter fullscreen mode Exit fullscreen mode

The version you selected will update your go-ipfs.

Now, you can use the command 'ipfs'.

Initializing

Before we can use IPFS, we must initialize a local repository. This repository contains the settings and internal data for your user account. It also generates a peer identity key to sign any content you create cryptographically.

$ ipfs init
Enter fullscreen mode Exit fullscreen mode

The init command outputs your peer identity key. This key is similar to an account number.

$ ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme
Enter fullscreen mode Exit fullscreen mode

You should see Hello and welcome to IPFS:

Your IPFS repository is located by default to location in a .ipfs folder in your home folder, where all your content is stored.

Basic Commands

Note: The quick start guide from the readme gives a list of all commands to assist with getting started.

Creating & Adding a File to IPFS

Navigate to a directory where you would like to create a file and try the following:

$ mkdir ipfs_dir

$ cd ipfd_dir
Enter fullscreen mode Exit fullscreen mode

Now let's create a file inside this folder.

$ echo "hello world" >hello.txt
Enter fullscreen mode Exit fullscreen mode

The text file hello.txt contains "hello world ". Next, add the file to IPFS.

$ ipfs add hello.txt
Enter fullscreen mode Exit fullscreen mode

You see the following type of output(may not be exact but kind of):

$ added QmYBmnUzkvvLxPksYUBGHy2sqbvwskLQw5gK6whxHGcsa8 hello.txt
Enter fullscreen mode Exit fullscreen mode

The combination of letters and numbers is the hash that's associated with this text file. The hash is created based on the contents of the file. If you change the contents of the file, the hash changes, save this hash to access the file later on.

Reading content:

Without using IPFS, we can read the contents of the hello.txt file with the following command:

$ cat mytextfiletxt
Enter fullscreen mode Exit fullscreen mode

We can read it through IPFS as well. Using the hash generated earlier, enter the following to return the contents of the file:

ipfs cat QmYBmnUzkvvLxPksYUBGHy2sqbvwskLQw5gK6whxHGcsa8
Enter fullscreen mode Exit fullscreen mode

Note:

If we change the text inside our hello.txt file,we will receive a new hash. Using the cat command, we see that our helloworld.txt file was updated with the new text.

Connecting to the Web

So far we've worked with IPFS locally. Now we're ready to try things online. Open another terminal and run the daemon command.

$ ipfs daemon
Enter fullscreen mode Exit fullscreen mode

The daemon allows us to interact with the IPFS network through localhost in our browser. Switch back to the other terminal to take a look at our peers.

$ ipfs swarm peers
Enter fullscreen mode Exit fullscreen mode

This command results in a bunch of addresses flashing across the terminal. We opened the swarm component that allows us to listen and maintain connections with other peers on the network. The peers command allows us to see every peer that has an open connection.

We've successfully connected to the IPFS network and from here can get content from other nodes if we know the hash of the content.

Web Console

As we've successfully connected our node to the network we can use the IPFS Web Console.

http://localhost:5001/webui

In the console, we can:

  • check the status of your node
  • upload files to IPFS
  • explore files
  • see your peers
  • adjust settings for your node

The web console is the best tool for managing IPFS node.

Check my first post here

Happy configuring. _x_

Top comments (0)