Introduction & Setup

Introduction

The BTFS Testnet allows developers to access the full functionalities of BTFS in a controlled test environment. The following guide walks the user through connecting to the Testnet, storing a file, and retrieving the file. With every new BTFS node ID, you will automatically be assigned 123,456.789789 Testnet BTT. Should you run out of Testnet BTT, simply generate a new BTFS ID, launch the daemon, and apply the Testnet profile.

Install BTFS

Install BTFS by following the BTFS install guide. Once BTFS is installed, initialize the daemon

// Initialize BTFS

$ btfs init
initializing BTFS node at /Users/user/.btfs
generating 2048-bit Secp256k1 keypair...done
peer identity: 16Uiu2HAmGj8NxjMqTYPYGYdAXy1bZv7o1Nr8cKnXSaA1AP5v987g
to get started, enter:

	btfs cat /btfs/QmZjrLVdUpqVU6Pnc8pBnyQxVdpn9J8tfcsycP84W6N93C/readme

Testnet Configuration

Apply the testnet configuration profile.

// Renter Testnet Configuration Setup:

$ btfs config profile apply storage-client-testnet

// The services URLs should be staging in your configuration file:

$ btfs config show
  ...
  "Services": {
    "EscrowDomain": "https://escrow-staging.btfs.io",
    "EscrowPubKeys": [
      "CAISIQJOcRK0q4TOwpswAkvMMq33ksQfhplEyhHcZnEUFbthQg=="
    ],
    "GuardDomain": "https://guard-staging.btfs.io",
    "GuardPubKeys": [
      "CAISIQJhPBQWKPPjYcuPWR9sl+QlN0wJSRbQs3yUKmggvubXwg=="
    ],
    "HubDomain": "https://hub-staging.btfs.io",
    "StatusServerDomain": "https://status-staging.btfs.io"
  },
  ...
  
// Host Testnet Configuration Setup:

$ btfs config profile apply storage-host-testnet

Start the daemon

// Start the BTFS daemon

$ btfs daemon
Initializing daemon...
go-btfs version: 1.0.0-393e1b341
Repo version: 7
System version: amd64/darwin
Golang version: go1.13.10
Swarm listening on /ip4/10.0.0.101/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.16.0.15/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/38.142.72.82/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
HostUI: http://127.0.0.1:5001/hostui
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Remote API server listening on /ip4/127.0.0.1/tcp/5101
Daemon is ready
Storage host info will be synced at [TESTNET] mode
BTFS is up-to-date.

File Upload

Store a file to the BTFS network.

❗️

Warning

Files uploaded to the testnet will be purged periodically. Do not use the testnet for persistent storage.

// Add a file to your local node

$ btfs add --chunker=reed-solomon <file>
added QmSRyqAayqX3Vy4sA8bEuEbNgQhYEyoHXTmg1fH6AViwQR file
 2.37 KiB / 2.37 KiB [===================================================================================================] 100.00%

// Store the file to the BTFS network

$ btfs storage upload QmSRyqAayqX3Vy4sA8bEuEbNgQhYEyoHXTmg1fH6AViwQR
{"ID":"dcf019a9-842d-49cb-9690-2dd4c8829ca2"}

Query the storage process by running btfs storage upload <ID> status | jq. Storage upload process is complete once all shards show complete and the file level storage shows complete.

$ btfs storage upload dcf019a9-842d-49cb-9690-2dd4c8829ca2 status | jq

File Retrieval

Retrieve the file from the BTFS network by first removing the file from your local node, and then running btfs get.

// First remove the file from your local node:

$ btfs rm QmSRyqAayqX3Vy4sA8bEuEbNgQhYEyoHXTmg1fH6AViwQR
Removed QmVY9J7uq3UF5QWJAX7xTMLPGpR4FUsn3dDnA3LvgqST4v
Removed QmXfwWvQ7E96nVi7tt2Sn4f5R8rPxsGUtz7xHtHpkNAHF9
Removed QmRXFEkL33Qx38cQ6FJC3jf8MjRbnPZSRt1ctoC2o7jcHh
Removed Qme56DjNfkrHfYKZ4oaYFoitJ34gEWxXzQa4PKwTkoNt4v
Removed QmXFsKMpRrQRVY7Z7fghLJfHGxooEwtzE1gVKM7JS8phpz
Removed QmQ47XiSnZAYd9d3z4jfBrdwpYpsv5kyt2pcsPyVety87r
Removed QmevpWogVAgE5czMj5nNSfkvF7yUR3UXK9xyYFRXRZe9iL
Removed QmUuwBFMfUjpWa6pcsJAanuuNKndL7DqrGd8KY5zzs5oGY
Removed QmQfuDyf7NQVQBYsQZGarPBTz3e9R8DH8hjCV5R3UJPxjr
Removed QmcEisTJAdcJMPtg1tMit6t6Go1BqujxiiLiYqmEeGeoBp
Removed QmSTxDHU1AsP5oypyuy6QNR7RTGcQxRPZxvHbeh5Cmy4y9
Removed QmX5n3umQigc5uuWmwapBspjQYD12XNkjYBWLK1Vsdd87g
Removed QmNqpi65L6UNzfUn4by9WxWk6oJKiqikrbZVjQsKkhBkqy
Removed QmYEXeE24veVuRU91KJyTVKc2KgTcmmh5bzBvmU61mGjFg
Removed QmXyN1p5yDjCBZq1jSr2dYnJGfi7FUsSRHAC4jm11zKdkD
Removed QmagvAfRiQVc5NRBoPHMhn2iCLu2Wh6jM13g46ruPNviqE
Removed QmbbkJpWT2wYEUayy6tQ2FMyf5k6MdkvA8ex2R5PCBYkXf
Removed QmWjeG1d1zAs3Ld7wXXvpdyQUQnUtjX96rBzv5pLAyLHYt
Removed QmVDkrKSf2wwuwegcaEqRTYQ6593Y2itJFMbcZY2Tq6doT
Removed QmRxmLvzQVGGCKYig6qX1AY2kuNrEnx8DvEW9kEqHxjW4d
Removed QmPLVcTEwLWYCyNDJznECtBHF4C5XHEuVt89jkdNXX1dkf
Removed QmcBxff4CpD1yKNYb9FdLwSsuCxMELtb8uMHU3kNuJ9eF7
Removed QmNoNkSLpEhtL9KdY2VnQpMqumWkmqQrdmfgTNMAjXFnfZ
Removed QmSCfvqnQYzHkat12qo35EtFdsmnhTHHiPr4SdnJz2pKZQ
Removed QmfYdcV2uTvxvC2Msdmaouu66sek4W1oXBeyFmdpuopXSV
Removed QmVQadM6YzZfV8Lqm2mR3gBrMtmAeA8g1XQysibX6u6ZvT
Removed QmX3ixMPRxmGGPvppsu6o9RZBtJWGgPTwbV6PwUcsa6zoQ
Removed QmfLVJF5ZXgqbUPWNLL7eWywHETaSFooUPo3jvMKmm6FgB
Removed QmQpsXMwzxb7xrmtX2xnmEd3CVHP1UoGb8xaQY2aVP5ikk
Removed QmT85Lf3QL46pwLhErMvV6ks6iDk2bj5hdWxDuexC5uiYM
Removed QmNw8rcKaQtCfHnuZgmrTWaFEQ7Cbakac99eY9Ty1uDsCA
Removed QmVDwuuxsqK4G5wB5PELVCeoW3PMmJwcZkqHLQKnN3YVrE
Removed QmSRyqAayqX3Vy4sA8bEuEbNgQhYEyoHXTmg1fH6AViwQR

// Then retrieve the file from the storage hosts:

$ btfs get QmSRyqAayqX3Vy4sA8bEuEbNgQhYEyoHXTmg1fH6AViwQR
Saving file(s) to QmSRyqAayqX3Vy4sA8bEuEbNgQhYEyoHXTmg1fH6AViwQR
 2.37 KiB / 2.37 KiB [================================================================================================] 100.00% 0s

Replenish Testnet BTT

If you ever run out of testnet BTT balance, in order to replenish, you will need to generate a new BTFS key-pair. This can be achieved by shutting down BTFS, removing the ~/.btfs directory, re-initializing BTFS, applying the storage-client-testnet profile, and finally re-starting the daemon.

❗️

Warning

Removing the .btfs directory results in:

  1. Removal of your existing BTFS node ID.
  2. Removal of files uploaded to your local go-btfs node only.
    Therefore, make sure you back up the .btfs directory and the necessary copies of the files you need, elsewhere.
// Shut down daemon

$ btfs shutdown

// Remove the existing config file

$ rm -r ~/.btfs
override r--r--r--  user/staff for ~/.btfs/blocks/_README? yes

// Initalize BTFS

$ btfs init
...

// Apply the Testnet Config

$ btfs config profile apply storage-client-testnet

// Start the daemon

$ btfs daemon