FileCoin: Talking to Miners and Storing Files

Ethan Wu
Numbers Protocol
Published in
4 min readOct 20, 2020

--

In our previous discussion, Beginners Guide To FileCoin (macOS), we discussed how to set up and get started running the decentralized network. If you haven’t already set up your daemon, feel free to take a look at the article.

Overview

In this discussion, we will be diving into some lotus commands and exploring how to utilize lotus to communicate with miners and storing our files. In FileCoin, the players involved are known as the client (user) and the miner. Miners are individuals in the network offering up storage space for a price. If you are interested in learning more about FileCoin and decentralized storage take a look at our FileCoin / IPFS Introduction. Utilizing lotus we can “shop” storage options and initiate storage deal communication with miners on the network.

Prerequisites

In order to do this, you will need to have an active lotus daemon running and a full chain sync to whatever network you decided to connect to. In this tutorial, we are connected to devnet nerpa.

To check to see if you have a full chain sync run the following in the terminal:

lotus sync status

You should expect to see “complete” status under the stage tag.

Creating Wallet and Adding Funds

Once this has been confirmed, the first order of business is to set up our FileCoin wallet as we cannot initiate storage deals without any FileCoin currency.

Running the following command will generate a FileCoin address. You can have multiple wallets:

lotus wallet new bls

You can list out all your wallets with the following:

lotus wallet list

This command will generate all your FileCoin addresses. The address is important because it is the reference point for sending currency. You can now navigate to the following page: https://faucet.nerpa.interplanetary.dev/ and enter the address to send funds.

The process takes about 3 minutes to complete. Once it’s done you can check the wallet balance by running:

lotus wallet balance

Preparing data for storage

Data stored in FileCoin needs to be packaged into a CAR file. This can be done through the lotus client by running:

lotus client import <filename>.txt

This command returns a CID, and unique identifier based on the data content’s cryptographic hash. This piece of information is important as it will be used to make deals as well as store and retrieve files.

Window Shopping for Miners

Now comes the fun part. We can search for miners by running:

lotus state list-miners

This will list out all the available miners on the network. As a client, you can do some window shopping by running:

lotus client query-ask <miner>

When you run this command you can see the details such as asking price and storage specification.

Making the deal

After viewing all the options and finding the right option for your data storage purposes, you can jump initiate the a deal by running:

lotus client deal <data CID> <miner> <price> <duration>

Once this has been done, we will need to wait for the miner to approve the deal and go through a process known as sealing, a proof that your data is being stored. The status can be checked by running:

lotus client list-deals

If the state field reads StorageDealActive this indicates that your data has been stored successfully. To learn more about how to verify your deal consider checking out ProtoSchool’s Verifying Storage on FileCoin.

Conclusion

That’s it! We have gone through setting up the wallet, preparing our data for storage and storing our data. For more information, check out the official FileCoin documentation. If you run into any issues feel free to leave a comment. I will respond to any inquiries. Alternatively, the FileCoin Slack channel is a great place to find answers.

Sources:Image: https://www.8ways.ch/application/files/1115/4278/8120/text-mining-icon-2793702_640.pngFileCoin Documentation: https://docs.filecoin.io/Verifying Data on FileCoin: https://proto.school/verifying-storage-on-filecoin/06

--

--

Ethan Wu
Numbers Protocol

Recent M.S Graduate and Numbers Software Developer & Developer Relations/Community Manager