This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { getSession } from "next-auth/react" | |
| const API_ENDPOINT = 'https://managed.mypinata.cloud/api/v1' | |
| const IDENTIFIER = '3d5468b3-f0ae-4a16-b726-6f09d009723b' | |
| export default async function handler(req, res) { | |
| const session = await getSession({ req }) | |
| if(req.method === "POST") { | |
| try { | |
| if(!session) { | |
| return res.status(401).send("Not signed in"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect } from 'react' | |
| import { signOut, useSession } from "next-auth/react" | |
| import Link from 'next/link'; | |
| const Gallery = () => { | |
| const { data: session, status } = useSession() | |
| const [loading, setLoading] = useState(true); | |
| useEffect(() => { | |
| if(session) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const validateNFTOwnership = async (address) => { | |
| try { | |
| const { abi } = require("../../../helpers/erc721.js"); | |
| const contractAddress = '0x_NFT_CONTRACT_ADDRESS_HERE' | |
| const provider = await new ethers.providers.JsonRpcProvider(process.env.ALCHEMY_ENDPOINT); | |
| const contract = await new ethers.Contract( contractAddress , abi() , provider ); | |
| const balance = await contract.balanceOf(address); | |
| if(balance.toString() !== "0") { | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async authorize(credentials) { | |
| try { | |
| const siwe = new SiweMessage(JSON.parse(credentials?.message || "{}")) | |
| const domain = process.env.DOMAIN | |
| if (siwe.domain !== domain) { | |
| return null | |
| } | |
| if (siwe.nonce !== (await getCsrfToken({ req }))) { | |
| return null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Head from "next/head"; | |
| import { getCsrfToken, signIn, useSession } from 'next-auth/react' | |
| import { SiweMessage } from 'siwe' | |
| import { useAccount, useConnect, useNetwork, useSignMessage } from 'wagmi'; | |
| import { useRouter } from "next/router"; | |
| import { useEffect } from "react"; | |
| export default function Home() { | |
| const router = useRouter(); | |
| const [{ data: connectData }, connect] = useConnect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import NextAuth from "next-auth" | |
| import CredentialsProvider from "next-auth/providers/credentials" | |
| import { getCsrfToken } from "next-auth/react" | |
| import { SiweMessage } from "siwe" | |
| export default async function auth(req, res) { | |
| const providers = [ | |
| CredentialsProvider({ | |
| name: "Ethereum", | |
| credentials: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { SessionProvider } from "next-auth/react" | |
| import "../styles/globals.css" | |
| import { WagmiProvider } from "wagmi" | |
| export default function App({ Component, pageProps }) { | |
| return ( | |
| <WagmiProvider autoConnect> | |
| <SessionProvider session={pageProps.session} refetchInterval={0}> | |
| <Component {...pageProps} /> | |
| </SessionProvider> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Head from "next/head"; | |
| export default function Home() { | |
| return ( | |
| <div> | |
| <Head> | |
| <title>Members Only Photos</title> | |
| <meta name="description" content="An NFT Powered Members Only Photo App" /> | |
| <link rel="icon" href="/favicon.ico" /> | |
| </Head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const imageDir = fs.readdirSync("./Pinnies"); | |
| imageDir.forEach(img => { | |
| const metadata = { | |
| name: `Pinnie ${img.split(".")[0]}`, | |
| description: "A Pinnie in the Limited Pinata Family Collection", | |
| image: `ipfs://FOLDER_CID/${img.split(".")[0]}.png`, | |
| attributes: [] | |
| } | |
| fs.writeFileSync(`./metadata/${img.split(".")[0]}`, JSON.stringify(metadata)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const hre = require("hardhat"); | |
| async function main() { | |
| try { | |
| const Contract = await hre.ethers.getContractFactory("AvalancheNFTDrop"); | |
| const contract = await Contract.attach( | |
| "YOUR CONTRACT ADDRESS" // The deployed contract address | |
| ); | |
| const uri = await contract.tokenURI(1); |