Prerequisites

Downloading

In this post, we install from a prebuilt package. Download the appropriate binary from the link above.

Unzip the package where you want to store the IPFS binary, and add the IPFS binary to your PATH.

Open your terminal and try the following to test that your install works:

Note: For Windows users, I recommend Powershell over Command Prompt.

ipfs help

That's It! You now have the IPFS installation on your machine.

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

The init command outputs your peer identity key. This key is similar to an account number. The init command suggests the following command to try:

ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

You should see something like the below:

Hello and Welcome to IPFS!
██╗██████╗ ███████╗███████╗
██║██╔══██╗██╔════╝██╔════╝
██║██████╔╝█████╗ ███████╗
██║██╔═══╝ ██╔══╝ ╚════██║
██║██║ ██║ ███████║
╚═╝╚═╝ ╚═╝ ╚══════╝
If you see this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!-------------------------------------------------------| Warning:|| This is alpha software. use at your own discretion!|| Much is missing or lacking polish. There are bugs.|| Not yet secure. Read the security notes for more.|-------------------------------------------------------
Check out some of the other files inthis directory:./about
./help
./quick-start <-- usage examples
./readme <--this file
./security-notes

You can try the other files suggested by replacing readme in the last command.

It's important to know where your IPFS repository is located because this is where all your content is stored. The default location is a .ipfs folder in your home folder.

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:

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 helloworld.txt file with the following command:

cat mytextfiletxt

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

Changing the Content

Let's see what happens if we change the text inside our helloworld.txt file.

Remove a Pin

The first command removes the pin. When we garbage collect, it's removed from our node. The file is still available in our local directory stored on our computer, but we are no longer hosting it on the node.

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

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

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.

Note: If you ever get an error message saying "API not found," run the daemon command and continue where you left off. To ensure that IPFS runs correctly it is suggested to run the daemon command every time you use IPFS, even locally.

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.

If we know the hash of a file and want to save it on our computer we can do the following:

Article Author

0 Comments

Related Articles

Peer-to-peer hypermedia with IPFS

InterPlanetary File System, also known as IPFS, is a peer to peer media protocol that means to make the web faster, safer, and open sourced. Right now were in need of a system that has fast performance, continuous access to content, efficient data transfer, easy naming conventions, and low cost. Although IPFS is in its early stages, it can do all of these things. What Were Using Right Now In the current implementation of the web, we are using a service called hypertext transfer protocol, also kn

Using Besu, the Java Ethereum Client with Linux/MacOS

Toolbelt: Besu included! Original photo by Jesse Orrico Update: Pantheon is now Hyperledger Besu. For more information, see here. This is the Linux/MacOS version of an article on installing Besu, the Java client for Ethereum: Linux Windows Having some powerful tools in your toolbelt is essential for a Java developer, and one of the crucial tools for an Ethereum blockchain developer is the network client. This is the piece of software that communicates data to and from the blockchain. Among other