Skip to content

Instantly share code, notes, and snippets.

View polluterofminds's full-sized avatar

Justin Hunter polluterofminds

View GitHub Profile
@polluterofminds
polluterofminds / id.js
Created January 13, 2021 17:44
Single Post Page
import React, { useState, useEffect } from "react";
import ReactMarkdown from "react-markdown";
import axios from "axios";
import { useRouter } from "next/router";
import Link from "next/link";
import { checkUserSession } from "../actions/auth";
const Post = () => {
const [content, setContent] = useState(null);
const router = useRouter();
@polluterofminds
polluterofminds / PinataPartyContract.cdc
Last active February 26, 2021 16:49
1 - PinataPartyContract
pub contract PinataPartyContract {
pub resource NFT {
pub let id: UInt64
init(initID: UInt64) {
self.id = initID
}
}
}
@polluterofminds
polluterofminds / PinataPartyContract.cdc
Last active March 5, 2021 23:56
2 - PinataPartyContract
pub resource interface NFTReceiver {
pub fun deposit(token: @NFT, metadata: {String : String})
pub fun getIDs(): [UInt64]
pub fun idExists(id: UInt64): Bool
pub fun getMetadata(id: UInt64) : {String : String}
}
@polluterofminds
polluterofminds / PinataPartyContract.cdc
Last active March 16, 2021 20:56
3 - PinataPartyContract
pub resource Collection: NFTReceiver {
pub var ownedNFTs: @{UInt64: NFT}
pub var metadataObjs: {UInt64: { String : String }}
init () {
self.ownedNFTs <- {}
self.metadataObjs = {}
}
pub fun withdraw(withdrawID: UInt64): @NFT {
@polluterofminds
polluterofminds / PinataPartyContract.cdc
Last active February 26, 2021 16:48
4 - PinataPartyContract
pub fun createEmptyCollection(): @Collection {
return <- create Collection()
}
pub resource NFTMinter {
pub var idCount: UInt64
init() {
self.idCount = 1
}
@polluterofminds
polluterofminds / PinataPartyContract.cdc
Last active February 26, 2021 16:48
5 - PinataPartyContract
init() {
self.account.save(<-self.createEmptyCollection(), to: /storage/NFTCollection)
self.account.link<&{NFTReceiver}>(/public/NFTReceiver, target: /storage/NFTCollection)
self.account.save(<-create NFTMinter(), to: /storage/NFTMinter)
}
@polluterofminds
polluterofminds / PinataPartyContract.cdc
Last active November 18, 2022 10:23
Full PinataPartyContract
pub contract PinataPartyContract {
pub resource NFT {
pub let id: UInt64
init(initID: UInt64) {
self.id = initID
}
}
pub resource interface NFTReceiver {
pub fun deposit(token: @NFT, metadata: {String : String})
@polluterofminds
polluterofminds / MintPinataParty.cdc
Created February 26, 2021 18:04
PinataParty Minting Transaction
import PinataPartyContract from 0xf8d6e0586b0a20c7
transaction {
let receiverRef: &{PinataPartyContract.NFTReceiver}
let minterRef: &PinataPartyContract.NFTMinter
prepare(acct: AuthAccount) {
self.receiverRef = acct.getCapability<&{PinataPartyContract.NFTReceiver}>(/public/NFTReceiver)
.borrow()
?? panic("Could not borrow receiver reference")
@polluterofminds
polluterofminds / CheckTokenMetadata.cdc
Last active March 4, 2021 14:18
Check NFT Script
import PinataPartyContract from 0xf8d6e0586b0a20c7
pub fun main() : {String : String} {
let nftOwner = getAccount(0xf8d6e0586b0a20c7)
// log("NFT Owner")
let capability = nftOwner.getCapability<&{PinataPartyContract.NFTReceiver}>(/public/NFTReceiver)
let receiverRef = capability.borrow()
?? panic("Could not borrow the receiver reference")
@polluterofminds
polluterofminds / AuthCluster.js
Last active March 3, 2021 17:01
1 - Flow React
import React, {useState, useEffect} from 'react'
import * as fcl from "@onflow/fcl"
const AuthCluster = () => {
const [user, setUser] = useState({loggedIn: null})
useEffect(() => fcl.currentUser().subscribe(setUser), [])
if (user.loggedIn) {
return (
<div>
<span>{user?.addr ?? "No Address"}</span>