⚙️Internals

Internals: Understanding the Inner Workings of StableStore

Overview

The Internals page provides an in-depth look at the technical processes that power StableStore, from monitoring deals to handling payments. This guide details how StableStore interacts with the Filecoin network, manages data, and processes transactions. All th working here has been shown for the Squid router .

Filecoin Address Monitoring

  1. User Configuration: When a user provides their Filecoin address for the calibration network, our backend begins continuous monitoring.

  2. API Request:

    • Every 10 seconds, our system sends a request to the Filecoin network using the following curl command:

      curl -X POST -H "Content-Type: application/json" --data '{
         "jsonrpc": "2.0",
         "method": "Filecoin.StateMarketDeals",
         "params": [[{"/": "bafy2bzacebbwr5k7x6aunp3wtvf2cp33zsukpq3pz3dz6bfughczf2wyfeugi"}]],
         "id": 1
      }' https://filecoin-calibration.chainup.net/rpc/v0
    • Warning: Using this curl command manually might generate a lot of information and potentially clutter your terminal.

  3. Data Parsing:

    • The response from the above request is parsed to extract information about the current deals, including the total GB used and details about the storage provider.

Utilizing Beryx for Data

  • Beryx Integration: StableStore uses Beryx to gather and display data related to the storage provider. However, Beryx does not index deals, so additional steps are necessary.

  • Zondax API: We have developed an API with Zondax to index deals and provide comprehensive deal information, ensuring that users can view detailed deal metrics on their dashboard.

Escrow Wallet Setup

  • Escrow Address Provision: Each storage provider is given a unique escrow wallet address during setup. This address must be configured on the provider's nodes to ensure that all payments from clients are directed to this wallet.

Withdrawals

  1. Modal Dialog:

    • Users can initiate a withdrawal by clicking the "Withdraw" button on the dashboard. This action opens a modal dialog box offering two options:

      • Withdraw as USDC: Convert and withdraw funds as USD Coin for stability.

      • Withdraw as FIL: Withdraw funds as Filecoin. For this we hit the locus RPC endpoint in a systematic way to first get the nonce , then use this nonce to construct the message and entering the request data and the addresses of the sender and receiver and then signing the message , waiting for it to confirm and then verify the message.All of this is done using a JS script.

  2. Squid Router Integration:

    • Withdrawals are processed using the Squid Router. The integration involves the following steps:

      • MetaMask Connection: Users connect their MetaMask wallet to the platform.

      • JS Script: A JavaScript script utilizing the Squid SDK is employed to create a bridge and swap the tokens as per the user's choice.

API integraton for beryx

As Beryx and Zondax currently do not index deals, we have developed a custom API endpoint to provide necessary data for the StableStore dashboard. This API delivers comprehensive information about the storage data used and all the deals conducted by the storage client.

API Endpoint

Endpoint URL: /api/v1/storage-deals/{provider-id}

Method: GET

Request Parameters

  • filecoinAddress (string, required): The Filecoin address of the storage provider.

  • startDate (string, optional): The start date for filtering deals (format: YYYY-MM-DD).

  • endDate (string, optional): The end date for filtering deals (format: YYYY-MM-DD).

Response Format

The response will be in JSON format and includes details such as total storage used and a list of all deals.

Example Response:

{
  "storageProvider": "t01234",
  "totalStorageUsedGB": 5000,
  "deals": [
    {
      "dealId": "bafyreid2d3eegr",
      "client": "t099",
      "pieceCID": "baga6ea4seaqa",
      "sizeGB": 32,
      "priceFIL": 0.5,
      "status": "active",
      "startTime": "2024-01-01T00:00:00Z",
      "endTime": "2025-01-01T00:00:00Z"
    },
    {
      "dealId": "bafyreihsh7df2",
      "client": "t101",
      "pieceCID": "baga6ea4seaqb",
      "sizeGB": 64,
      "priceFIL": 1.0,
      "status": "completed",
      "startTime": "2023-06-01T00:00:00Z",
      "endTime": "2023-12-01T00:00:00Z"
    }
  ]
}

Summary

The Internals page of StableStore provides transparency into the backend processes, ensuring users understand how their deals are monitored, how data is managed, and how transactions are processed. By leveraging tools like Beryx and Zondax, and integrating with the Squid Router for flexible withdrawals, StableStore ensures a robust and efficient experience for Filecoin storage providers.

Last updated