Skip to content

unlock-protocol/alphatweet

Repository files navigation

cherry

ALPHAtweet is a open-source project for content sharing powered by Unlock Protocol.

An “Alpha” is a piece of exclusive content that is being shared, where both the creator and the sharer participate in the benefits of sharing when someone unlocks the Alpha.

While this particular ALPHAtweet experiment emphasizes sharing on Twitter, the magic is that these items of Alpha can be shared anywhere by way of share links and, in every case, the creators and sharers both have the opportunity to be compensated across any platform, every time an Alpha is shared.

This is not something that could be done before today.

Creators set their own price for unlocking their premium content, the Alpha. They also set a referral percentage bonus that is split with those who share or amplify the content.

In this model, the creator can set the referral percentage bonus to any level they want, based on the creator’s own goals.

Supabase

We use supabase for powering our backend. You can create a free account at supabase. You will need to create a new project on supabase and link it using the supabase cli.

# start local supabase instance. This will start a docker container and spin up a local supabase instance. You can copy paste the variables from the output and add them to your .env.local file
yarn supabase start


# reset your local supabase instance
yarn supabase db reset

Supabase migrations

We use supabase migrations to manage our database schema. You can find the migrations in the migrations folder. You can read more about supabase migrations here.

  1. Create a new migration
yarn supabase migrate create --name <migration-name>

# Add the sql to the migration file. You can find the migration file in the `migrations` folder. 

# If you use supabase studio to create your tables, then you can run the following command to generate the migration file

yarn supabase db diff -f <migration-name>
  1. Apply the migration
yarn supabase db reset

Pushing changes to hosted supabase instance

Once you have created the migration, you can push the changes to your hosted supabase instance.

# Login into supabase. You will need to provide an access token which you can generate from user settings
yarn supabase auth login

# link your project - you can find the project ref in the project settings
yarn supabase link --project-ref <project-ref>

# push the changes
yarn supabase db push

Develop

  1. Clone the repo

  2. Install dependencies

yarn install
  1. Rename .env.template to .env.local and fill in the values.
NEXT_PUBLIC_SUPABASE_URL= # you can get this from your project supabase settings
NEXT_PUBLIC_SUPABASE_PUBLIC_KEY= # you can get this from your supabase project settings
SUPABASE_SERVICE_ROLE_KEY= # you can get this from your supabase project settings
SESSION_SECRET= # generate a random string that is at least 32 characters long. You can run `node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"`
NEXT_PUBLIC_WALLET_CONNECT_ID= # you can get this from https://www.walletconnect.org/apps
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID= # optional
NEXT_PUBLIC_HOT_JAR_ID= # optional
NEXT_PUBLIC_UNLOCK_APP_URL=https://app.unlock-protocol.com # The URL of the Unlock app you want to use. Staging or production.
  1. Run the development server
yarn dev

Production

For production deployment, you should use the hosted supabase instance. You can apply migration to your hosted instance using the following command

# Login into supabase. You will need to provide an access token which you can generate from user settings
yarn supabase auth login

# link your project - you can find the project ref in the project settings
yarn supabase link --project-ref <project-ref>

# push the changes
yarn supabase db push