Storage Rental

Guide on CLI commands for renting storage on the BTFS network

Renter

Please refer to Deposit BTT to BTFS guide here: https://docs.btfs.io/docs/deposit-btt-to-btfs#section-get-private-key-in-hex-format

Setup

Users who have set up a BTFS node can immediately begin renting storage on the BTFS network via the command line functions. The storage process is comprised of the following steps:

  1. Apply the BTFS renter config settings.
  2. Upload the file to your local go-btfs node.
  3. Upload the file hash onto the BTFS storage network.
  4. Query your upload status.

Renter Config Settings

Enable BTFS renter settings by running the following command:

btfs config profile apply storage-client

Check your updated config settings:

btfs config show

// Under "Experimental", the StorageClientEnabled setting is set to true

"StorageClientEnabled": true,

Sync BTFS hosts and view the hosts info:

btfs storage hosts sync
btfs storage hosts info | jq

BTFS Add

Add your desired file by running btfs add.

Type 1: This command directly uploads it to your local node.

btfs add <file-name>

// Sample Output
added QmdBX8seLx4TGHwr8Tu9L2QSByaJ9bbFUpxFvKAYyxCmnb <file-name>
 163 B / 163 B [=======================================================] 100.00%

Type 2: This command encodes the file with Reed-Solomon encoding and uploads it to your local node.

btfs add --chunker=reed-solomon <file-name>

// Sample Output
added QmdBX8seLx4TGHwr8Tu9L2QSByaJ9bbFUpxFvKAYyxCf7b <file-name>
 242 B / 242 B [=======================================================] 100.00%

Option

Description

Flag

Reed Solomon Chunker

File is encoded with Reed-Solomon encoding, then uploaded to your local BTFS daemon.

--chunker=reed-solomon

BTFS Storage Upload

Type 1: If it is added by btfs add <file-name>, upload the file into the BTFS storage network.

btfs storage upload <file-hash> --copy=num

Type 2: If it is added by btfs add --chunker=reed-solomon <file-name>, upload the file into the BTFS storage network.

btfs storage upload <file-hash>

Storage Options

Option

Description

Flag

Leaf Hash

Flag to specify given hash(es) is leaf hash(es). Default: False

[--leaf-hash | -l]

Price

The price in JUST (10^-6 BTT) for storage.

[--price= | -p]

Replication Factor

Replication factor for the file with erasure coding built-in. Default: 3

[--replication-factor= | -r]

Host Select Mode

Based on mode to select the host and upload automatically.

[--host-select-mode= | -m]

Host Selection

Use only these selected hosts in order on 'custom' mode. Use ',' as a delimiter.

[--host-selection= | -s]

Host Search Local

Enable host search under all domains 0.0.0.0 (useful for local test). Default: True

[--host-search-local=false]

Storage Length

The length in Days to store the file.
Default: 30 days

[--storage-length= | --len]

Copy Num

Set num copy to upload. If set --copy=1, will be 1(origin) + 1(copy) =2 to upload.

[--copy=num]

Usage Examples

// Store a file to BTFS with storage length of 35 days and price of 0.75 BTT/GB/day

btfs storage upload QmdBX8seLx4TGHwr8Tu9L2QSByaJ9bbFUpxFvKAYyxCf7b --storage-length=35 --price=750000

// Sample Output
{"ID":"15f635e0-3171-445f-b089-95c04ecb3d83"}

Use the outputted Session ID from btfs storage upload to check the storage upload status.

btfs storage upload <session-id> status | jq '.Status'

// Install the "jq" utility to parse the JSON output in the terminal

Retrieve File from BTFS

btfs get <file-hash>

Remove File from BTFS (Locally)

btfs rm <file-hash>
// Remove stored file on host before contract expires

btfs rm --force <file-hash>