Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 1.89 KB

create-pay-to-view-media.md

File metadata and controls

44 lines (27 loc) · 1.89 KB
description
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.

💸 Pay to View Application

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"],
}

Check code example

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 3: Lighthouse view URL 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 code example.

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