Token-gated repositories via GitHub API.

Overview

GateRepo

About | Implementation | License

About

Simple implementation of ERC20 token-gating GitHub repositories.

Fueled by Mike's tweet.

Implementation

  1. Users login with GitHub OAuth, we store their access token to take actions on their behalf.
  2. Users can create new Gates for their repositories, specifying contract address, number of tokens needed, and number of invites to open. In the back-end, token name + decimals, and current latest block number is stored.
  3. Users can share links to Gates.
  4. Upon accessing a Gate invitation, users can sign-in with GitHub (again giving us their access token). Then, they connect their wallet and sign a message to verify ownership for our back-end.
  5. Finally, in /api/gates/access we run a multi-step process:
    1. Check that requesting user is authenticated
    2. Check that all parameters have been posted (address, signature, gated repo ID)
    3. Verify address ownership by matching address to signature
    4. Check if gated repo by ID exists
    5. Check if gated repo has available open invitations
    6. Check if address held necessary balance at block number
    7. Check if we have access token for requesting user
    8. Check if requesting user is not already a collaborator on private repo
    9. Check if we have access token for private repo owner
    10. Send invite from owner to requesting user to join private repo
    11. Accept invite from owner via requesting user to join private repo
    12. Increment number of used invites (decreasing available slots)

Build and run locally

# Collect repo
git clone https://github.com/anish-agnihotri/GateRepo
cd GateRepo

# Install dependencies
npm install

# Update environment variables
cp .env.sample .env
vim .env

# Run application
npm run dev

Environment variables

  1. NEXTAUTH_URL: Site link, http://localhost:3000 if developing locally, https://gaterepo.com for this deployed instance
  2. NEXTAUTH_SECRET: Any randomly generated string as a secret, e.g.: NpUFdWakhCjbuIIogCvj
  3. GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET: Follow the instructions here for spinning up a new GitHub OAuth application. When asked, the authorization callback URL is http://localhost:3000/api/auth/callback/github (local) or https://your_domain.com/api/auth/callback/github (deployed). Once setup, your OAuth applications Client ID is your GITHUB_CLIENT_ID and your Client Secret is your GITHUB_CLIENT_SECRET
  4. DATABASE_URL: Postgres database connection URL
  5. RPC_API: Any Ethereum Mainnet JSON-RPC endpoint

Limitations

  1. GitHub API has a rate-limit of sending a maximum of 50 invitations for a repository per 24 hour period.
  2. Application does not run a scheduled job to check continuing token ownership (to remove users who transfer their tokens). This is deferred to the user if desired functionality.
  3. Application currently only supports ERC20 tokens but is easily extensible to other token formats by updating the snapshot strategy in /pages/api/gates/access.ts.
  4. Allows a single address to verify token ownership on behalf of multiple GitHub users (not a one-to-one between GitHub users and addresses). Easily changeable should user require uniqueness by tracking address-to-gateId in database in /pages/api/gates/access.ts.
  5. GitHub OAuth scopes are fairly invasive (repo,read:user,user:email). If you are privacy-aware, I'd recommended running your own fork or migrating to an app-based system?

License

GNU Affero GPL v3.0

You might also like...

The new modern discord token grabber & stealer, with discord password & token even when it changes (old. PirateStealer)

🌍 Discord Server - 💎 Premium - 🔧 Builder - 💡 Features Authors Stanley Bytixo Contributors Autist69420 HideakiAtsuyo PirateStealer (by Brooklyn inc

Apr 12, 2022

portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project Those days of manually updating portfolio website after every new project made are gone ⚡ Yesss . . . you read that right. 😉 portfo

Aug 3, 2021

🚀 📈 Stock market game where the stocks are github repositories

GitHubStonks What is githubstonks ? githubstonks.com Githubstonks is a stock market game where the stocks are popular GitHub repositories. You can buy

Sep 27, 2022

Cloney - Clone all Github repositories from a user or organization

 Cloney - Clone all Github repositories from a user or organization

Cloney - Clone all Github repositories from a user or organization How to use $ cloney (users|orgs) (name) Preview Installation Prerequisites NodeJS E

May 28, 2022

GitHub action to automate managing repositories with labels, milestones and projects.

triagecat GitHub action to automate managing repositories with labels, milestones and projects. Link issues and PRs labels. Add issues and PRs to a pr

Jun 14, 2022

Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu

Tool for GitHub/GitLab to keep Repositories/Projects you are interested in and their Pull/Merge Requests in desktop Tray Menu. More info in User Guide.

Jul 31, 2022

Use signature-based minting to allow users who have contributed to your github repositories to claim an NFT!

GitHub contributors NFT rewards This project demonstrates how you can build a full-stack web3 application that allows github contributors of certain r

Nov 5, 2022

Manage GitHub resources like repositories, teams, members, integrations and workflows with the AWS CDK as Custom Resources in CloudFormation.

CDK Github Manage GitHub resources like repositories, teams, members, integrations and workflows with the AWS CDK as Custom Resources in CloudFormatio

Nov 25, 2022
Comments
  • More information around environment variables

    More information around environment variables

    I'm looking to get this up and running but unsure about these three environment variables:

    NEXTAUTH_URL=""
    NEXTAUTH_SECRET=""
    DATABASE_URL=""
    

    I'm guessing that NEXTAUTH_URL and NEXTAUTH_SECRET are referring to the configuration for next-auth? What about the DATABASE_URL?

    The others make sense already. It would be helpful to get these documented or commented somewhere to provide enough context to get started building with this.

    Thanks!!

    opened by dabit3 2
  • Add read-only option for organization-owned repos

    Add read-only option for organization-owned repos

    When giving access to repos owned by an organisation, new members get "write" access by default. This may be undesirable.

    • Added read-only option during gate creation (only shows up if repo is owned by an org)
    • Added readOnly to Gate in db schema
    • Added frontend elements related to read-only option
    • Changed .env.sample and readme
    • Fixed links that were hardcoded to 'gaterepo.com'

    Btw great work doing this, love this project ❤️

    opened by jjranalli 1
  • Add read-only permission for organizations and dynamic token check at current block

    Add read-only permission for organizations and dynamic token check at current block

    Read Only

    When giving access to repos owned by an organisation, new members get "write" access by default. This may be undesirable.

    • Added read-only option during gate creation (only shows up if repo is owned by an org)
    • Added readOnly to Gate in db schema
    • Added frontend elements related to read-only option
    • Changed .env.sample and readme
    • Fixed links that were hardcoded to 'gaterepo.com'

    Dynamic Check

    Checking number of tokens held dynamically and not at a specific block might be desirable in some scenarios. For example, it avoids having to periodically create new links to allow new holders to get access to the repo.

    • Added Dynamic check option during gate creation
    • Added required logic in api/gates endpoints
    • Added dynamicCheck to Gate in db schema + added default values to both dynamicCheck and readOnly proposed in #3 (should prevent issues during db migration)
    • Added frontend elements related to dynamic check option

    Btw great work doing this ❤️

    opened by jjranalli 0
Owner
Anish Agnihotri
blockchain, hackathons, econ, and chipotle
Anish Agnihotri
Decentralized, token-gated discussion platform for DAOs

ETHCC Hackathon 2022 -- Debate3 This is the official ETHCC Hackathon 2022 submission for our project Debate3 ?? . Project Description Debate 3 is a De

Dennis Zoma 8 Nov 8, 2022
The new modern discord token grabber & token stealer, with discord password & token even when it changes

The new modern discord token grabber & token stealer, with discord password & token even when it changes

Stanley 143 Jan 6, 2023
Angular JWT refresh token with Interceptor, handle token expiration in Angular 14 - Refresh token before expiration example

Angular 14 JWT Refresh Token example with Http Interceptor Implementing Angular 14 Refresh Token before Expiration with Http Interceptor and JWT. You

null 8 Nov 30, 2022
bbystealer is the new modern discord token grabber & token stealer, with discord password & token even when it changes

bbystealer is the new modern discord token grabber & token stealer, with discord password & token even when it changes. Terms Educational purpose only. Reselling is forbidden. You can use the source code if you keep credits (in embed + in markdown), it has to be open-source. We are NOT responsible of anything you do with our software.

null 10 Dec 31, 2022
a cobbled together alternative UI to launchdarkly, allowing read/write access via LD API access token

discount-launchdarkly a cobbled together alternative UI to launchdarkly, allowing read/write access via LD API access token setup make sure you have a

null 9 Oct 19, 2022
Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

null 2 Jan 5, 2022
Ethernaut.5.token - Exercice 5 (Token) on Ethernaut

Advanced Sample Hardhat Project This project demonstrates an advanced Hardhat use case, integrating other tools commonly used alongside Hardhat in the

Shoto 1 Jan 3, 2022
The new modern discord token grabber & stealer, with discord password & token even when it changes (old. PirateStealer)

?? Discord Server - ?? Premium - ?? Builder - ?? Features Authors Stanley Bytixo Autist69420 PirateStealer (by Brooklyn inc) The new modern discord to

Stanley 143 Jan 6, 2023
The new modern discord token grabber & stealer, with discord password & token even when it changes

?? Discord Server - ?? Premium - ?? Builder - ?? Features Authors Râider.#0004 Syborg#0004 Contributors Râider.#0004 Syborg#0004 BbyStealer The new mo

Râider 4 Jul 23, 2022