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

Was this helpful?

Edit on GitHub
  1. Tutorials

Pay to View Application

In this example, file owners let only those who access a particular file who have minted NFT from the contract defined by the owner in access conditions.

PreviousPay Per DealNextUse Python SDK

Last updated 4 months ago

Was this helpful?

Step 1: The user uploads an encrypted file to the Lighthouse IPFS node. Refer to this NodeJS Encryption Upload or ReactJS Browser Encryption Upload code example.

Lighthouse node returns an IPFS CID/Hash for the encrypted file.

Step 2: Suppose the user(file owner) wants only people who buy an NFT from a particular collection to access the encrypted file; he applies access control to the encrypted file.

For example, in the case of NFT

// If a user owns at least one NFT of a given contract deployed on the Shardeum chain.
{
    id: 1,
    chain: "shardeum",
    method: "balanceOf",
    standardContractType: "ERC721",
    contractAddress: "0x93a347e0fe192a31a0c81e23b4238489043a97f8",
    returnValueTest: { comparator: ">=", value: "1" },
    parameters: [":userAddress"],
}

After applying the access condition, only the user who owns NFT from that particular collection can get access to the file.

Note: access conditions are not only restricted to NFT. Users can apply custom contracts, time-based, and native token-based conditions also.

Step 4: NFT can also be made a soul-bound token (SBT) so that the owner is not able to transfer to any other address

Step 3: can be used to view the encrypted file and displays it at the user end, or the user can build a custom decryption view page, refer to this .

💸
Check code example
Lighthouse view URL
code example