Skip to content

Instantly share code, notes, and snippets.

View polluterofminds's full-sized avatar

Justin Hunter polluterofminds

View GitHub Profile
@polluterofminds
polluterofminds / accessToken.js
Created July 13, 2022 14:57
Generating an Access Token With Submarine SDK
import { getSession } from "next-auth/react";
import { Submarine } from "pinata-submarine";
const submarine = new Submarine(process.env.SUBMARINE_KEY, process.env.GATEWAY_URL);
export default async function handler(req, res) {
try {
const session = await getSession({ req });
if (!session) {
return res.status(401).send("Not signed in");
}
@polluterofminds
polluterofminds / media.js
Last active July 12, 2022 17:59
Token Gated Media Upload
import { getSession } from "next-auth/react";
import formidable from "formidable";
import fs from "fs";
import { Submarine } from "pinata-submarine";
const submarine = new Submarine(process.env.SUBMARINE_KEY, process.env.GATEWAY_URL);
const IDENTIFIER = "YOUR UNIQUE ID";
export const config = {
api: {
@polluterofminds
polluterofminds / [...nextauth].js
Created July 12, 2022 11:57
Next.js SIWE Auth w/NFT Token Validation
import NextAuth from "next-auth"
import CredentialsProvider from "next-auth/providers/credentials"
import { getCsrfToken } from "next-auth/react"
import { SiweMessage } from "siwe"
import { ethers } from "ethers"
const validateNFTOwnership = async (address) => {
try {
const { abi } = require("../../../helpers/erc721");
const contractAddress = process.env.CONTRACT_ADDRESS;
@polluterofminds
polluterofminds / uploadSubmarinedFolder.js
Created June 2, 2022 14:04
Large Folder Upload Submarine
const fs = require("fs");
const FormData = require("form-data");
const rfs = require("recursive-fs");
const basePathConverter = require("base-path-converter");
const got = require('got');
const submarineDirectory = async () => {
const url = `https://managed.mypinata.cloud/api/v1/content`;
const src = "RELATIVE PATH TO DIRECTORY TO UPLOAD";
var status = 0;
@polluterofminds
polluterofminds / abi.js
Last active July 12, 2022 12:16
ERC721 Basic ABI
export const abi = [
{
"inputs": [
{
"internalType": "string",
"name": "baseURI",
"type": "string"
},
{
"internalType": "uint256",
@polluterofminds
polluterofminds / media.js
Created April 8, 2022 19:23
Members Only Step 13
import { getSession } from "next-auth/react";
import formidable from "formidable";
import fs from "fs";
import FormData from "form-data"
const API_ENDPOINT = "https://managed.mypinata.cloud/api/v1";
const IDENTIFIER = "YOUR APP UUID";
export const config = {
api: {
bodyParser: false,
@polluterofminds
polluterofminds / gallery.js
Last active April 8, 2022 19:46
Members Only Step 12
@polluterofminds
polluterofminds / accessToken.js
Last active April 8, 2022 19:07
Members Only Step 11
import { getSession } from "next-auth/react";
const API_ENDPOINT = "https://managed.mypinata.cloud/api/v1";
export default async function handler(req, res) {
try {
const session = await getSession({ req });
if (!session) {
return res.status(401).send("Not signed in");
}
const { id, cid } = req.query;
@polluterofminds
polluterofminds / gallery.js
Last active April 8, 2022 19:06
Members Only Step 10
@polluterofminds
polluterofminds / gallery.js
Last active April 7, 2022 13:15
Members Only Step 9