Set up

Setting up, storing, and retrieving using the Filecoin network

Before we start

The process is split into three main parts: the set-up, storing your data and retrieving your data. Each section has several sub-processes that we need to follow.

SectionSub-tasks
Set up1. Get access to a Lotus full-node.
2. Start a Lotus lite-node on your local computer.
3. Get a FIL address.
4. Sign up for Filecoin Plus.
Store data1. Package your data.
2. Import your data into Lotus.
3. Find a storage provider through the Filecoin Plus Registry.
4. Create a storage deal.
5. Wait for the deal to complete.
Retrieve data1. Create a retrieval deal.
2. Download your data.

It will take about an hour to complete this tutorial. While there aren’t too many steps involved, there’s a bit of waiting around for the network to process your requests.

Take notes

There are a few things to remember throughout this tutorial, such as Miner IDs and addresses. There is a table at the end of each section showing the information you should record:

VariableDescriptionExample
Miner IDThe unique identifier for each storage provider.f01000

The above table is an example of what you will see throughout the tutorial; you don’t have to copy it down.

Terms and phrases

This tutorial contains some words and phrases that you might not be familiar with. Refer back to this table if you encounter something you don’t understand:

WordDefinition
AddressA string of letters and numbers that other users can send FIL to.
Block explorerA service, usually a website, that lets you view details of a blockchain such as transactions, deals, and addresses.
DealAn agreement between two computers about what to do with some data.
FILThe shorthand representation of the filecoin cryptocurrency. For example: We charge 0.5 FIL per GiB.
Filecoin (upper-case F)The network that transactions and storage deals take place on. For example: Museums can use the Filecoin network to store their digital archives.
filecoin (lower-case f)The cryptocurrency that the Filecoin network runs on. For example: You can use filecoin to pay for your transactions.
MinerAn alternate name for a storage provider.
Private keyA string of letters and numbers that programs use to interact with the Filecoin network. Keep your private key safe, and don’t share it with anyone.
Storage dealAn agreement between a storage provider and a client about what data to store, how long for, and how much the storage provider can charge for storage.
Retrieval dealAn agreement between a storage provider and a client about how much the storage provider can charge to send data to a client.
Storage clientThe user that wants to store something on the Filecoin network. In this tutorial, you are the storage client.
Storage providerA computer on the Filecoin network offering storage space to other users who want to store data. Storage providers are sometimes called miners.
WalletA collection of addresses. Think of each wallet as a folder and each address as a single file in that folder.

Set up

Before you begin storing any data on the Filecoin network, you need to run through a few steps to get everything set up. This section covers getting access to a Lotus full-node, creating a Lotus lite-node on your computer, getting a FIL address, and signing up to Filecoin+.

Things to note

As you’re going through this section, make a note of the following variables:

VariableDescriptionExample
Your Filecoin addressThe public part of your Filecoin address. This address is what other users can use to send your FIL.f1fwavjcfb32nxbczmh3kgdxhbffqjfsfby2otloi

Access a full-node

A Lotus full-node is a computer running the lotus daemon. Full-nodes are unique because they have complete access to the Filecoin blockchain. The computer specifications required to run a Lotus full-node are relatively high and might be out of reach for most end-user laptops and PCs.

Usually, we’d have to spin up a full-node, but in this tutorial, we’re going to use the lotus gateway service api.chain.love.

Install a lite-node

A lite-node lets your computer interact with the Filecoin network without having to run a resource-intensive full-node! Lite-nodes can do things like sign messages and talk to storage providers, but any processes that need data from the blockchain must come from a full-node. Luckily, lite-nodes automatically route any blockchain-based requests to a full-node. For this tutorial, you’re going to run a Lotus lite-node on your local computer and have it connect to a full-node managed by Protocol Labs.

Installing on macOS

  1. Install Lotus from the filecoin-project tap

    brew install filecoin-project/lotus/lotus
    
  2. Lotus is now installed on your computer.

Head onto the next section to run your Lotus lite-node ↓

MacOS build from source

If you prefer to build from source, try these steps.

  1. Check that the XCode command line tools are installed.

    xcode-select -p (if missing, run xcode-select --install )
    
  2. Install the pre-requisites via Homebrew

    brew install go jq pkg-config rustup hwloc coreutils
    
  3. Clone the latest sources

    git clone https://github.com/filecoin-project/lotus.git
    
  4. Switch into the lotus folder

    cd lotus/
    
  5. Checkout the latest release

    git checkout releases
    
  6. Setup some environment variables correctly

    export LIBRARY_PATH=/opt/homebrew/lib
    export FFI_BUILD_FROM_SOURCE=1
    export PATH="$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH"
    
  7. Install Rust (when prompted, choose the default ‘install’ option)

    rustup-init
    
  1. Build the clients

    make all
    
  1. Finally, install the client into your system
    sudo make install
    
  2. Verify the installation
    lotus -v
    

Now, you’re ready to run a Lotus lite node

Linux

  1. Install Lotus dependencies:

Arch:

sudo pacman -Syu hwloc

Ubuntu/Debian:

sudo apt install -y hwloc

Fedora:

sudo dnf -y install hwloc

OpenSUSE:

sudo zypper in hwloc

Amazon Linux 2:

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm; sudo yum install -y hwloc-devel
  1. Download the latest Linux bundle from the Lotus GitHub releases page:

    wget https://github.com/filecoin-project/lotus/releases/download/v1.26.0/lotus_v1.26.0_linux_amd64.tar.gz
    
  2. Extract tar -xvf archive.tar.gz executable:

    tar -xvf lotus_1.26.0_linux_amd64.tar.gz
    
  3. Move the lotus binary to /usr/local/bin:

    sudo mv lotus_1.26.0_linux_amd64/lotus /usr/local/bin/lotus
    

Head onto the next section to run your Lotus lite-node ↓

Run a Lotus lite-node

Now that you have Lotus ready to run, you can start a Lotus lite-node on your computer and connect to the api.chain.love Lotus full-node!

  1. Open a terminal windows and run the lotus daemon --lite command, using api.chain.love as the full-node address:

    FULLNODE_API_INFO=wss://api.chain.love lotus daemon --lite
    
    ...
    2021-06-16T02:00:08.390Z        INFO    markets loggers/loggers.go:56   module ready   {"module": "storage client"}
    2021-06-16T02:00:08.392Z        INFO    markets loggers/loggers.go:56   module ready   {"module": "retrieval client"}
    2021-06-16T02:00:18.190Z        INFO    basichost       basic/natmgr.go:91      DiscoverNAT error:no NAT found
    ...
    
  2. MacOS users may see a warning regarding Lotus. Select Accept incoming connections if you see a warning.

  3. The Lotus daemon will continue to run. You must run further commands from a separate terminal window.

Next up is getting a FIL address ↓

Get a FIL address

Filecoin addresses are similar to regular bank account numbers. Other users can use your address to send you FIL, and you can use your address to pay storage providers for storing and retrieving your data.

There are two parts to a Filecoin address: the public address and the private key. You can freely share your public address with anyone, but you should never share your private key. We’re not going to view any private keys in this tutorial, but it’s essential to understand the difference between your public address and your private key.

  1. Open a new terminal window and create an address using the lotus wallet new command:

    lotus wallet new
    
    f1fwavjcfb32nxbczmh3kgdxhbffqjfsfby2otloi
    

    Lotus outputs your public address. Public addresses always start with f1.

  2. Make a note of this address. We’ll use it in an upcoming section.

Backup your address

Your address is made up of two parts: your public address and your private key. The public address is what you see when you run lotus wallet new, and you’re safe to share that address with whoever you want. Your private key, however, must be kept secret and secure. If you lose your private key, you lose access to any FIL stored in that address.

It is incredibly important that you backup your addresses. Storing a copy of your addresses on another device is a great way to ensure you don’t lose access to your funds.

  1. If your public address f1... is still in the terminal window, copy it to your clipboard. If not, list the addresses associated with your Lotus node and copy your public address:

    lotus wallet list
    
    Address                                    Balance  Nonce  Default
    f1nau67e6k6ggdwluatfz4waexetjfrqmx6fil3nq  0 FIL    0      X
    
  2. Use lotus wallet export to export your private key, replacing f1... with your public key:

    lotus wallet export f1... > my_address.key
    

    This will create a new file called my_address.key in the current directory.

Once you have your address in a file, you can copy it to another drive, securely send it to another computer, or even print it out. It’s important to keep this file safe. If anything happens to your Lotus node, you can still access your funds using this file.

Adding FIL to your wallet or using Filecoin Plus?

Before you can transact on the network, you usually have to add some Filecoin to your wallet. You can do this via an exchange such as Coinbase, but you can bypass this stage by applying for Filecoin Plus Datacap below. If you have Datacap on your wallet, then transaction fees are covered, and you can start doing deals faster.

Filecoin Plus

Storage providers get paid either by receiving FIL directly from users for storing their data, winning block rewards from the network, or both!

Getting paid from users is straightforward. If Laika wants to store some data, and Albert is a storage provider, the two of them can create a deal to store Laika’s data for X amount of time for Y FIL.

Block rewards are randomly given to a storage provider every 30 seconds. The more data that a storage provider is storing, the higher their chances of winning the block reward. So if a storage provider accepts a deal from a user to store 5 GB of data, they have 5 chances to win the block reward for each 30 second round.

DataCap acts as a kind of multiplier for block rewards. If a storage provider accepts a deal from a user with DataCap attached, also known as a verified deal , then the Filecoin network treats that deal as though it’s 10x bigger. So a 5 GB deal gives the storage provider 50 chances to win the block reward instead of the usual 5 chances. Some storage providers find DataCap so valuable that they’re willing to make verified deals without charging any FIL! You can find a list of these storage providers using the Filecoin Plus storage provider registry.

Sign up

Signing up to Filecoin Plus is easy and free!

  1. Go to plus.fil.org.
  2. Under For Clients, click Proceed.
  3. Under Get Verified, click Get Datacap.
  4. Click Automatic Verification.
  5. Click Github to connect to your Github account
  6. In the Request field, enter the public address you got from running lotus wallet list. This step may take a few minutes to complete.

You can check your Filecoin Plus balance with

lotus filplus check-client-datacap f1...

Edit this page on GitHub