Skip to content

Instantly share code, notes, and snippets.

View polluterofminds's full-sized avatar

Justin Hunter polluterofminds

View GitHub Profile
@polluterofminds
polluterofminds / PFP.sol
Created October 15, 2021 15:58
PFP with reveal
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "hardhat/console.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract PFP is ERC721Enumerable, Ownable {
@polluterofminds
polluterofminds / users.js
Created September 24, 2021 12:13
Exceptionless Blog Post - User Association
import { Exceptionless } from "@exceptionless/node";
import express from "express";
const router = express.Router();
await Exceptionless.startup("YOUR API KEY");
const users = [
{
key: "123",
user: {
@polluterofminds
polluterofminds / user_hook.js
Last active September 22, 2021 14:59
Top Shot user-hook
import * as fcl from "@onflow/fcl"
import { useState, useEffect } from 'react';
export function useCurrentUser() {
const [user, setUser] = useState(null);
useEffect(() => {
fcl.currentUser().subscribe(setUser)
}, []);
return {
currentUser: user,
@polluterofminds
polluterofminds / index.js
Last active September 21, 2021 18:10
Top-Shot-Holders index.js
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'
export default function Home() {
return (
<div className={styles.container}>
<Head>
<title>Top Shot Holders</title>
<meta name="description" content="NBA Top Shot Members-Only Community" />
@polluterofminds
polluterofminds / metadata-generator.js
Created September 15, 2021 17:35
Generate Test NFT Metadata In Bulk
const fs = require("fs");
const faker = require('faker');
const TOTAL = 10_000;
const generateRandomMetadata = () => {
return {
name: faker.name.findName(),
description: faker.lorem.sentences(),
image: faker.image.avatar()
}
@polluterofminds
polluterofminds / index.js
Last active September 23, 2021 20:41
React Code
import Head from "next/head";
import Image from "next/image";
import styles from "../styles/Home.module.css";
import { useEffect, useState } from "react";
import axios from "axios";
export default function Home() {
const [ethereum, setEthereum] = useState(null);
const [isPFPinata, setIsPFPinata] = useState(null);
const [secretUrl, setSecretUrl] = useState(null);
@polluterofminds
polluterofminds / verify.js
Last active March 7, 2022 21:56
Verify Signed Transactions and Access Gated Content
import axios from "axios";
import * as util from "ethereumjs-util";
import {ethers} from "ethers";
import { v4 as uuidv4 } from 'uuid';
import { withIronSession } from 'next-iron-session'
const abi = require("../../PFPinatas.json").abi;
const contractAddress = "Your PFPinata Contract Address"
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
const urlV2API = `https://managed.mypinata.cloud/api/v1`;
const API_KEY = process.env.PINATA_V2_API_KEY
@polluterofminds
polluterofminds / getOwner.js
Last active March 7, 2022 22:06
Get Token Owner
const hre = require("hardhat");
async function main() {
const PFPinata = await hre.ethers.getContractFactory("PFPinatas");
const contract = PFPinata.attach("YOUR CONTRACT ADDRESS");
const owner = await contract.ownerOf(1);
console.log({owner});
}
@polluterofminds
polluterofminds / mint.js
Last active March 7, 2022 22:07
Mint Token To Address
const hre = require("hardhat");
async function main() {
const PFPinata = await hre.ethers.getContractFactory("PFPinatas");
const contract = PFPinata.attach("YOUR DEPLOYED CONTRACT ADDRESS");
const mintedNft = await contract.mintTo("RINKEBY WALLET TO USE");
console.log("token minted", mintedNft);
}
@polluterofminds
polluterofminds / troubleshooting.md
Created August 30, 2021 14:06
Trouble Shooting Hardhat Scripts

Possible Error

insufficient funds for gas * price + value

Double check the network in your hardhat.congif.js file. In my case, I had updated everything to Rinkeby except for my node provider URL.

Next, double check that you are appending --network rinkeby to the end of your scripts. The config file tells hardhat what details to use for a given network, but if you don't tell it what network to use, it will use the default (which is local).