Lighthouse
  • 👋Introduction
  • Quick Start
  • How To
    • 🔑Create an API Key
    • 🔼Upload Data
      • 📁File
      • 🔤Text/JSON
      • 🔀Buffer
    • 🔒Upload Encrypted Data
      • 📁File
      • 🔤Text/JSON
      • 🔐Encryption Authentication
        • 📝Method 1: Signed Message
        • ⚕️Method 2: JWT
        • 📲Method 3: Passkey
    • Encryption Features
      • 👯Share File
      • ❌Revoke Access
      • 🔑Check Access Conditions
      • 🚪Token Gating
      • Chains Supported
      • 📃Access Control Conditions
      • 🔓Decrypt File
        • 🌐Browser Decrypt File
        • 💻NodeJS Decrypt File
      • 🚪Access control with zkTLS
      • 👬Account Delegation Tutorial
    • 📂List Files
    • 💁File Info
    • 💰Get Balance
    • 🔁Retrieve File
    • 💾Check for Filecoin Deals
    • 🔄IPNS - Handle Mutable Data
    • 📦Migrate Files
    • 📌Pin CID
    • 💸Pay per use
    • Resize Image
    • 💻Use CLI Tools
  • zkTLS
  • 🤝Account Delegation
  • 💾Filecoin First
    • Usage
    • 💰Pay Per Deal
  • Tutorials
    • 💸Pay to View Application
    • Use Python SDK
    • 📝Update Content with Lighthouse IPNS
    • 📹Add Video Player in UI
    • ✅Document Verification with PoDSI
    • 🎨Minting NFTs on EVM Chains
    • 🪙Minting NFTs on Solana
    • 👩‍💻Programmable Storage with Lighthouse SDK and Filecoin
    • 🔐Secure File Sharing
    • Upload Encrypted Files
    • 📄Token Gating and Custom Contract
    • 🔑Token Gating NFTs
    • 🏖️Pushing File Metadata Onchain
    • Use Radix Wallet on Lighthouse Filesdapp
  • Concepts
    • Glossary
    • IPFS CID Transition to v1
  • Support
    • 📞Contact
Powered by GitBook
On this page
  • Create an API Key
  • Upload File
  • View File
  • Get Filecoin Deal
  • Verify Filecoin Deal

Was this helpful?

Edit on GitHub

Quick Start

PreviousIntroductionNextCreate an API Key

Last updated 7 months ago

Was this helpful?

In this section, we will see how to

This guidance is in Nodejs, but in case you are using any other language, refer to the section to get APIs that can be called directly.

Create an API Key

1. Login into Lighthouse files dapp () 2. Go to the API key section and generate the key

You can also generate the API key from CLI

Upload File

1. Install the lighthouse package in your Node application 2. Run the following script

import lighthouse from '@lighthouse-web3/sdk'

const apiKey = 'YOUR_API_KEY_HERE';
const uploadResponse = await lighthouse.upload(
  '/home/cosmos/Desktop/wow.jpg', 
  apiKey
);

console.log(uploadResponse);

You will get a response like this once file is successfully uploaded:

{
  data: {
    Name: 'wow.jpg',
    Hash: 'QmUHDKv3NNL1mrg4NTW4WwJqetzwZbGNitdjr2G6Z5Xe6s',
    Size: '31735'
  }
}

View File

Get Filecoin Deal

The Filecoin deal can take up to 2 days to show up once the file is uploaded. To get Filecoin deal use the following function of the SDK

const status = await lighthouse.dealStatus('bafkreia4ruswe7ghckleh3lmpujo5asrnd7hrtu5r23zjk2robpcoend34')

The response will look like this

data: [
    {
        "endEpoch": 4490732,
        "chainDealID": 45796363,
        "publishCID": "bafy2bzacec2v6bahuatbgxeocrym6vwduzovopwtairtvcipzj6q6jvq3pmti",
        "storageProvider": "f02620",
        "dealStatus": "Sealing: PreCommit1",
        "dealUUID": "e8ad77c7-0801-4076-80b8-bdabff95cb7b",
        "startEpoch": 3035532,
        "aggregateIn": "b231aeed-59a8-4586-9bf9-e45679895e8f",
        "providerCollateral": "10.282 mFIL",
        "lastUpdate": 1676160004130,
        "pieceCID": "baga6ea4seaqhtz4xcs5d3yrf6hivxp7dbcqg6dwqqojez5ztcq7mycngigptsoy",
        "payloadCid": "bafybeiefcsn6rwyswdlf6mmknaq3kncuee6mwfx7fy4qea7msl2zngnaia",
        "pieceSize": 34359738368,
        "carFileSize": 34091302912,
        "dealId": 45796363,
        "miner": "f02620",
        "content": 31721
    }
]

Verify Filecoin Deal

The file can be viewed from an IPFS gateway

Lighthouse aggregates files uploaded by multiple users into a 32GB CAR file and stores this CAR with a storage provider. To verify that your file was part of the Filecoin deal, you can use the PODSI verification. Refer to the section for more details.

https://gateway.lighthouse.storage/ipfs/QmWC9AkGa6vSbR4yizoJrFMfmZh4XjZXxvRDknk2LdJff
Filecoin Virtual Machine
how-to
https://files.lighthouse.storage/
Create an API Key
Upload a file
View the file
Get Filecoin deals
Verify a Filecoin deal