Coder Social home page Coder Social logo

thirdweb-example / community-rewards Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 16.0 209 KB

Reward your community using NFTs and thirdweb's signature based minting.

Home Page: https://community-rewards.thirdweb-example.com

License: Apache License 2.0

JavaScript 1.17% CSS 16.01% TypeScript 82.82%
nft-collection signature-based-minting

community-rewards's Introduction

Important

This repository is referencing the mumbai chain.

Mumbai is deprecated since 08/04/2024, meaning the code in this repository will no longer work out of the box.

You can still use this repository, however you will have to switch any references to mumbai to another chain.

Community Rewards

Introduction

This example utilizes signature-based minting of NFTs as a mechanism to reward users of a specific community. We connect user's with their Discord account, and generate signatures for an NFT if the user is a member of the Discord server.

Using This Template

Create a project using this example:

npx thirdweb create --template
community-rewards
  • Create an NFT Collection contract using the dashboard.
  • Update the contract address and discord server id in the consts file.

Setting up Discord OAuth

Head to the Discord Developer portal and create a new application.

Under the Oauth2 tab, copy your client ID and client secret. We need to store these as environment variables in our project so that we can use them on the API routes in our application.

Create a file at the root of your project called .env.local and add the following lines:

CLIENT_ID=<your-discord-client-id-here>
CLIENT_SECRET=<your-discord-client-secret-here>

Back in the Discord portal, under the Redirects section, you need to add the following value as a redirect URI:

http://localhost:3000/api/auth/callback/discord

You need to have an environment variable called NEXTAUTH_SECRET for the Discord Oauth to work.

You can learn more about it here: https://next-auth.js.org/configuration/options

You can quickly create a good value on the command line via this openssl command.

openssl rand -base64 32

And add it as an environment variable in your .env.local file:

NEXTAUTH_SECRET=<your-value-here>

Other Environment Variables

To run this project, you will need to add the following environment variables to your .env.local file:

WALLET_PRIVATE_KEY= NEXT_PUBLIC_TEMPLATE_CLIENT_ID= TW_SECRET_KEY=

  • Generate your TW_SECRET_KEY and NEXT_PUBLIC_TEMPLATE_CLIENT_ID via thirdweb's dashboard.
  • For WALLET_PRIVATE_KEY export your wallet private key from your wallet.

Run Locally

Install dependencies

  # npm
  npm install

  # yarn
  yarn install

Start the server

  # npm
  npm run start

  # yarn
  yarn start

Additional Resources

Contributing

Contributions and feedback are always welcome! Please check our open source page for more information.

Need help?

For help, join the discord or visit our support page.

community-rewards's People

Contributors

avneesh0612 avatar jarrodwatts avatar jnsdls avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

community-rewards's Issues

Depreciated modules

There's a few depreciated modules specifically unstable_getServerSession and getNFTCollection. I changed to getServerSession and getContract. I've added my .env.local and added my Client ID, Client Secret and private key but instead of < > I used " " because I was receiving an error.
I've changed the NFT Collection address to my own on the generate-signature.js and the index.js and added my Discord Server ID to the check-is-in-server.js and generate-signature.js.

Now, I receive a decryption operation failed error and data?.find is not a function error from the check-is-in-server.js.

Not sure if I'm doing something wrong, I followed the readme 3 different times and for a beginner I'm normally pretty good at figuring stuff out but I think this might be an error in the code somewhere.

When I run dev it just gets stuck on Checking...

When I run my console on chrome it states "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.