PowerGate Basics Tutorial
In this tutorial, I will demonstrate the basic functionalities of Textile’s PowerGate. From setup to finally storing and retrieving data placed onto the network.
What is PowerGate? (Brief Introduction)
PowerGate is an API solution created by Textile.io to help developers test and navigate the decentralized storage solution IPFS / FileCoin. For those of you unfamiliar with IPFS and FileCoin please refer to the following this IPFS / FileCoin introduction.
Getting Started
Connecting to FileCoin Network
FileCoin in its current form has various networks that you can connect to. For the purposes of this tutorial we will be connecting to PowerGate’s lightweight Localnet. To setup you will need have Docker Desktop installed and running as well as the latest Dockerfile downloaded from the PowerGate release page.
With both Docker Desktop running and Dockerfile downloaded, cd into the directory and run the Localnet by running the following in terminal:
BIGSECTORS=true make localnet
If successful, you should see a rolling log displaying miners as well as other lotus PowerGate information.
Installing PowerGate
From PowerGate release page download the latest release of PowerGate for your platform. Textile’s PowerGate supports Linux, Microsoft and Mac platforms. Once downloaded cd into the directory and following command to install in a separate terminal from the previous one.
./install
To check if the installation is successful run:
pow help
You should get the following:
Running and using PowerGate
Storing data on PowerGate
Now let us store some data onto the network!
pow ffs create
ffs create
creates an ffs instance allowing you to utilize the ffs API. Token created is used to track the ffs instance. This Token is very important and needs to be logged in every step with a -t
.
To avoid having to do this tedious operation we will store the token as a variable.
export POW_TOKEN=<token>
Now that all the setup is done we can start storing files onto the network. Let’s store this cute picture of favorite Pokemon. To store a file we can run the following:
pow ffs stage Pokémon_Pikachu_art.png> Success! Cached file in FFS hot storage with cid: QmUVReQjNUHZLbDaySPG9Bt2qcsBMBi2NmU4jwZvfiNR9x
pow ffs
stage is used to make the file or data available over ipfs. Files stored on IPFS have content base addressing so files have retrieved with a hash. So when you run ffs stage it generates a CID. Identical files will generate the same CID.
We can complete the storing process with the following:
pow ffs config push QmUVReQjNUHZLbDaySPG9Bt2qcsBMBi2NmU4jwZvfiNR9x
pow ffs config push
stores files depending on your StorageConfig. PowerGate FFS is a layer solution that contains both IPFS and FileCoin storage. PowerGate describes it as Hot and Cold. Hot storage means that the data is stored on IPFS network. Cold storage data is stored by miners in the FileCoin network. By default (if not specified in StorageConfig) PowerGate will store your data in both IPFS and FileCoin.
Retrieving Data
To test to see if this was all successful let’s try to retrieve our Pokemon picture from the network.
pow ffs get QmUVReQjNUHZLbDaySPG9Bt2qcsBMBi2NmU4jwZvfiNR9x retrieval.pngopen retrieval.png
The result should be the following:
Something Missing?
One key feature of storing files on FileCoin is making deals with miners. The file storage process outlined above seems to be missing this step. The reason for this is because PowerGate does the work for you by collecting information about miners such as power, and price and ranks them. When pushing data onto Cold storage, PowerGate FFS will automatically find suitable miners and initiate deals. These settings can be adjusted manually through StorageConfig
.
Trying out yourself
Now that PowerGate is setup and learned about the basic functionality the next step will be to play with the other features. Have fun!