Skip to content

hansy/sol-vod

Repository files navigation

Web3 VOD on Solana

This is an experiment in "gating" online videos with a Solana paywall. Users can unlock videos by paying the fee set by the video's creator.

The repo is broken up into two parts:

  1. Vue frontend in the /app directory
  2. Solana program in the /programs directory

Requirements

  • Anchor Framework (instructions include installing Solana and Rust)
  • NodeJS + Yarn/Npm

Building + Deplying program

Switch network

Right now this program can only be deployed on devnet because it uses a chainlink oracle that's on devnet.

$: solana config set --url https://api.devnet.solana.com

Generate CLI wallet

$: solana-keygen new

After generating a wallet, update Anchor.toml with the path to the generated wallet

Airdrop SOL to wallet

$: solana address # outputs wallet pubkey
$: solana airdrop 2 <SOLANA pubkey> # airdrop 2 SOL to address

Build program

$: anchor build

After building the program, run solana address -k target/deploy/sol_vod-keypair.json. This will generate the Program ID. Replace the above Program Id in these two files:

  • Anchor.toml (under programs.localnet)
  • /programs/sol-vod/src/lib.rs (inside declare_id!())

Building the program should also generate an IDL file in target/idl/sol_vod.json. It should have a metadata.address key with the value of the Program ID above. If not, add that key. E.g.:

// sol_vod.json
{
  ...
  "metadata": {
      "address": <PROGRAM ID>
  }
}

Technically the above approach is incorrect, as a missing metadata key in the IDL indicates something went wrong with the build. Sometimes changing Anchor versions helps solve this issue.

Deploy program

$: anchor deploy

# alternatively, to build + test + deploy in one command
$: anchor test

Running client

In a seperate terminal:

$: cd app/

# install dependencies
$ yarn

# run app
$ yarn serve

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published