Did I Improve ThisBlogAbout

Lighthouse

25 February, 2023 - 4 min

What is Lighthouse?

Lighthouse is a decentralized file storage protocol that utilize IPFS and Filecoin to provide permanent and secure file storage. The protocol leverages IPFS to temporarily store files before they are sent to miners on the Filecoin network for long-term storage.

To ensure a sustainable approach to payments for storage deals, Lighthouse employs a smart contract endowment pool strategy. This means that when a client pays for a storage deal, a portion of the payment is used to compensate the Filecoin miner for the initial storage deal, while the remaining amount goes to a common pool (the endowment pool). This pool is used to pay for all storage deals when it's time to renew them. Using mechanisms such as staking and farming (endowment strategy), it is able to expand the pool's value and generate enough funds to keep renewing deals indefinitely, making it a reliable and sustainable solution for long-term file storage.

Lighthouse supports many networks (Ethereum, Optymism, Polygon, ..).

Experimenting with Lighthouse CLI

In order to get a better understanding of how things work I decided to give their CLI a test run. Note that I'll be running tests on the goerly testnet which does not require any payment.

Create a new wallet

$ lighthouse-web3 create-wallet --network goerly
Set a password for your wallet: <some-password>
Public Key: 0xF8D8B58432F0277905BB2d663ceeE72c21074B64
Wallet Created!

Create a new api key

$ lighthouse-web3 api-key --new --network goerly
Enter your password:

Api Key: 36d291---782

Upload a file

$ lighthouse-web3 upload ~/Pictures/test.jpeg --network goerly
Name                              Size        Type                    
test.jpeg                    220 KB      image/jpeg

Summary
Total Size: 220 KB
Data Limit: 1 GB
Data Used : 0 Byte
After Upload: 1024 MB
Carefully check the above details are correct, then confirm to complete this upload Y/n
 y
Enter your password:
File Uploaded, visit following url to view content!
Visit: https://gateway.lighthouse.storage/ipfs/QmfDJ2aYoKEP4cTNMoyXxNbdRbBRC49pxvSbqzUJBT73VU
       https://ipfs.io/ipfs/QmfDJ2aYoKEP4cTNMoyXxNbdRbBRC49pxvSbqzUJBT73VU
CID: QmfDJ2aYoKEP4cTNMoyXxNbdRbBRC49pxvSbqzUJBT73VU

Upload an encrypted file

$ lighthouse-web3 upload-encrypted ~/Pictures/test.jpeg --network goerly
Name                              Size        Type                    
test.jpeg                    220 KB      image/jpeg

Summary
Total Size: 220 KB
Data Limit: 1 GB
Data Used : 0 Byte
After Upload: 1024 MB
Carefully check the above details are correct, then confirm to complete this upload Y/n
 y
Enter your password:
File Uploaded, visit following url to view content!
lighthouse-web3 upload-encrypted ~/Pictures/test.jpeg --network goerly                                                                ─╯
Name                              Size        Type                    
test.jpeg                    220 KB      image/jpeg

Summary
Total Size: 220 KB
Data Limit: 1 GB
Data Used : 220 KB
After Upload: 1024 MB
Carefully check the above details are correct, then confirm to complete this upload Y/n
 y
Enter your password:
File Uploaded, visit following url to view content!
Visit: https://files.lighthouse.storage/viewFile/QmYp7phu5zjzcfyhngDizYmKftJJimRo3fXJoBnURyvz29
CID: QmYp7phu5zjzcfyhngDizYmKftJJimRo3fXJoBnURyvz29

Download encrypted file

$ lighthouse-web3 decrypt-file --cid QmYp7phu5zjzcfyhngDizYmKftJJimRo3fXJoBnURyvz29 --network goerly
Enter your password:
test.jpeg Decrypted

Deal status

$ lighthouse-web3 deal-status --cid QmYp7phu5zjzcfyhngDizYmKftJJimRo3fXJoBnURyvz29 --network goerly
Deal creation in progress

Get uploads

$ lighthouse-web3 get-uploads --network goerly
    CID                                               File Name     File Size
    QmYp7phu5zjzcfyhngDizYmKftJJimRo3fXJoBnURyvz29    test.    220 KB

    QmfDJ2aYoKEP4cTNMoyXxNbdRbBRC49pxvSbqzUJBT73VU    test.    220 KB

That was an interesting initial dive into Lighthouse, hope it was useful!

Vicente




Articles in this web3 series

  1. Blockchain - What is a Blockchain?
  2. Ethereum Tokens - What are Ethereum Tokens?
  3. Filecoin Lite Node - How to setup a Filecoin Lite Node locally

4. Lighthouse - A perpectual storage solution using IPFS and Filecoin 5. Boost - Filecoin deal management tool for Storage Providers