🧑‍🔧Internals

This page helps readers

1. Integration of BTFS

  • Initialization: The system prepares the necessary parameters and ensures all dependencies are ready.

  • File Selection: The user is prompted to select the file(s) for upload.

  • Data Packaging: The selected files are packaged into the appropriate format for transmission.

  • Transmission: The formatted data is sent to the Btfs network for storage.

  • Confirmation: Once the upload is successful, a confirmation is sent back to the user interface, updating the status.

When a file is uploaded to the BTFS (BitTorrent File System) server, it is stored in a decentralized manner. Upon clicking the upload button, the file is split into smaller chunks, each assigned a unique cryptographic hash to ensure security and integrity. These chunks are then distributed across multiple nodes in the BTFS network, leveraging its peer-to-peer architecture. This decentralization ensures that the file remains accessible even if some nodes go offline.

To ensure the file’s persistence, it is pinned to the BTFS network, meaning specific nodes commit to storing and maintaining it. This prevents the file from being removed and ensures continuous availability.

Once the file is uploaded and pinned, BTFS generates a unique Content Identifier (CID). This CID serves as a permanent reference to the file, ensuring its authenticity and enabling others to retrieve it. Users can use the CID to access the file, which is seamlessly reassembled from the distributed chunks across the network.

2. Internal Working of Upload Button

When you click the upload button, the following sequence of events occurs:

Here is a flowchart of what goes behind on clicking the upload button

  1. Interaction with Tron Blockchain

Basic flow is given below and all the functions mentioned are called from contract deployed on nile test net and address is

  const contractAddress = "TRQojfypg3RAjrsF4B2QPtJLcKbuwbBjFh";

And also attaching the contract code

https://github.com/KPR-V/Tronent/blob/main/backend/blockchain/src/btfsContract.sol

File upload Internal functioning
  • Retrieving CID from Blockchain

Retrieving files
  • Similarly during Deletion of any version or folder, delete function from the contract is called.

Last updated