Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nandit123/lighthouse

Get verifiable storage on Filecoin Network directly from Ethereum Smart Contracts
https://github.com/nandit123/lighthouse

cross-chain ethereum filecoin lighthouse-node textile-powergate vulcanize

Last synced: 5 days ago
JSON representation

Get verifiable storage on Filecoin Network directly from Ethereum Smart Contracts

Awesome Lists containing this project

README

        

# Lighthouse Node
This project provides a way for Ethereum smart contracts to request Filecoin storage of CIDs in IPFS via Powergate. Hence, Ethereum developers can use this to request verifiable storage of data to Filecoin from Ethereum smart contracts.

### Website
http://lighthouse.ninja
### Blog Post
Read more about it on the blog here - https://nanditmehra123.medium.com/lighthouse-filecoin-ethereum-cross-chain-infra-project-66c041a1a1db
### Demo Video
https://vimeo.com/552468707

https://www.youtube.com/watch?v=E2-cfbdSXtM

![alt text](https://github.com/nandit123/lighthouse/blob/master/res/lighthouse.png?raw=true)

The parser at src/parser:

1. Takes data feed from external sources VulcanizeDB.
2. Parses the data feed into a set of parameters which can be passed to the storage-adapter.

The Storage adapter at src/storage-adapter:

1. Accepts the arguments passed from the parser. (storage adapter is modular enough to be taken out of this repo and used as an dependency. It can be used by any other project.)
2. Uses the arguments passed to store the data (cid) according to the config.
3. Publishes storage status via websocket.

## How to run

1. Clone this repo
2. Open a terminal window and run `> npm install`
3. To start the lighthouse node run `> node src/index.js`

Now the lighthouse node is up and running, feel free to run it locally on your system or host on a server.

This node also starts a socket.io server at port 3002 with which a socket.io client can interact to get the storage info of a file.

**Sample code for socket.io client -**
```js
const io = require("socket.io-client");
const socket = io("ws://localhost:3002");

// handle the event sent with socket.send()
socket.on("message", data => {
console.log(data);
});

socket.on("connect", () => {
// or with emit() and custom event names
socket.emit("cid", "QmbazJSQWTwmtAFqDgqxMG5JxGhg3kgYwdapaQDMM88HTP"); // put in your here for which storage-info is requested
});

// handle the event sent with socket.emit()
socket.on("storageInfo", (storageInfo) => {
console.log('storageInfo for cid:', storageInfo);
});
```

## Use Truffle box to Interact with Lighthouse
Demo Video - https://vimeo.com/552468707
- make a new directory -

      mkdir lighthouse

- cd into that -

      cd lighthouse

- run the following command -

      truffle unbox nandit123/lighthouse

- Install the packages -

      npm i

- Compile Smart Contracts -

      truffle compile

- Migrate and Deploy -

      truffle migrate --network rinkeby

- Now start truffle console using -

      truffle console

- Run the following command to get the instance of the deployed smart contract -

      let specificInstance = await FPS.at("0xdFEa08D7c2B43498Bfe32778334c9279956057F0");

- Now run this command to store data to filecoin -

      let result = specificInstance.store("sampleCid", "SampleConfig");

- You can get the transaction hash of the previous call by typing in -

      result

- To get the storageInfo replace your cid in the client.js file and run -

      node client.js