Lighthouse Filecoin-Ethereum Cross Chain Infra Project

The Lighthouse project provides a way for Ethereum smart contracts to request Filecoin storage of CIDs in IPFS via Textile.io’s Powergate, which simplifies Filecoin storage workflows from IPFS. Using Lighthouse, Ethereum developers can request verifiable storage of data to Filecoin from Ethereum smart contracts.

The project allows Ethereum developers to easily extend their IPFS storage with cryptographically verifiable and incentivized storage on Filecoin. Lighthouse greatly reduces the friction for Ethereum developers to interact with the Filecoin storage network by allowing them to store files on Filecoin by directly interacting with a Lighthouse smart contract deployed on Ethereum. This project was originally inspired by the [Quasar](https://github.com/infinitescroll/quasar) project that had been explored for Aragon and IPFS.

How it works

2) When a transaction is made, the smart contract emits an event with the CID and config which is intercepted by a Vulcanize DB instance. Vulcanize DB is an open source Postgres database of the Ethereum chain based on IPLD.

3) A Lighthouse node listens to this Vulcanize instance and receives the CID and config from the Vulcanize instance. Then the Lighthouse node prepares the CID and config to be sent to a Powergate instance which has been set up to make a storage deal with the Filecoin network on behalf of users. The Lighthouse node also exposes a WebSocket which gives out the storage info of a particular CID.This WebSocket is also used to retrieve back the file stored on the Filecoin network.

4) The Lighthouse node interacts with the Powergate instance to retrieve the storage info and the file itself from the Filecoin network on request.

How can you use Lighthouse?

0xdFEa08D7c2B43498Bfe32778334c9279956057F0

You can interact with the contract by calling the store function which accepts two parameters, CID and Config via Remix or other IDE / web3 library.

Example Inputs to try -

  • CID —QmTJYDuVWNnRn6g4AjRE5adZ9GwTm7Sgu2Zj75a3xibDRJ
  • Config
{  "hot": {    "enabled": true,    "allowUnfreeze": true,    "ipfs": {      "addTimeout": 900    },    "unfreezeMaxPrice": 0},  "cold": {    "enabled": true,    "filecoin": {      "replicationFactor": 1,      "dealMinDuration": 518400,      "excludedMinersList": [],      "trustedMinersList": [],      "countryCodesList": [],      "renew": {        "enabled": true,        "threshold": 1      },      "address": "f3rpbm3bt4muydk3iq5ainss6phht4bjbe5dq6egrx4rwzqjgwc5eruyloozvf6qjunubo467neaqsvbzyxnna",      "maxPrice": 100000000000,      "fastRetrieval": true,      "dealStartOffset": 8640,      "verifiedDeal": true    }  },  "repairable": false}

The CID is a unique id of the file and the Config represents the configuration of the file to be stored on the Filecoin. The Lighthouse node uses the Textile.io’s Powergate config to store data on Filecoin which you can read more about here.

When you submit the transaction to call Lighthouse, you can receive the storage status and retrieve the stored file from the WebSocket that the Lighthouse node exposes. You can run the following example of client code to achieve this:

https://github.com/nandit123/lighthouse/blob/master/client.js

node client.js

The above client code connects to the hosted Lighthouse which exposes a websocket at 13.126.82.18:3002 which you can change to a custom/local host.

Supplying a CID in the above piece of code will return the current storage status and retrieve the file back from the Filecoin network. Retrieval may take some time depending on your file size.

How to run your own Lighthouse node?

To run a Lighthouse node, setup Powergate and Vulcanize are required to have the whole project working end to end:

To run a Lighthouse node,

  • Clone the project repo —

git clone https://github.com/nandit123/lighthouse.git
  • Install all the dependencies —
npm install
  • Install pm2 globally —
npm install pm2 -g
  • Now run the server via —
pm2 start src/index.js --watch
  • Watch logs via —
pm2 logs

Setup Powergate

  • To learn about Powergate and setup — Powergate Docs
  • When you have Powergate running, take the POWERGATE_URL, POW_ID, POW_TOKEN and replace them in the environment file in the Lighthouse project repo

Setup Vulcanize

Applications

  1. Storage of financial data records of defi apps on Filecoin
  2. Long term storage of NFTs which are mostly stored on IPFS or centralized pinning services
  3. Integration of Filecoin storage with your current dapp without adding a new technology into your stack
  4. Dapps where two or more parties transfer data to each other in exchange for Ether or other tokens on the Ethereum blockchain

Future Goals

We are open to any feedback and suggestions and feel free to also propose any future features that you would like to see!

This project was funded by a Filecoin Dev Grant.

Author

Vaibhav Saini Twitter

Blockchain Technology and Cryptocurrencies. Always building things

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store