Skip to content

Instantly share code, notes, and snippets.

@kmjones1979
kmjones1979 / page.tsx
Last active July 2, 2024 23:20
A full example of a page for Scaffold-ETH that sends tokens using hooks and components
"use client";
import { useState } from "react";
import type { NextPage } from "next";
import { formatEther, parseEther } from "viem";
import { useAccount } from "wagmi";
import { Address, AddressInput, EtherInput } from "~~/components/scaffold-eth";
import { useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
const Home: NextPage = () => {
@kmjones1979
kmjones1979 / YourContract.sol
Last active July 3, 2024 14:53
Simple ERC20 contract example for the Hackathon Prep Brunch workshop in Brussels
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "hardhat/console.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* A smart contract for a workshop during EthCC
* @author Kevin Jones
*/
@kmjones1979
kmjones1979 / scaffold.config.ts
Created January 27, 2024 19:25 — forked from technophile-04/scaffold.config.ts
SE-2 frontend config for base mainnet
import * as chains from "wagmi/chains";
// Base chain
export const base = {
id: 8453,
network: "base",
name: "Base",
nativeCurrency: { name: "Base", symbol: "ETH", decimals: 18 },
rpcUrls: {
default: {
@kmjones1979
kmjones1979 / index.tsx
Created November 7, 2023 01:29
Example index.ts with table format for Unchain readme
import type { NextPage } from "next";
import { MetaHeader } from "~~/components/MetaHeader";
import { gql } from "@apollo/client";
import { useQuery } from "@apollo/client";
import { Address } from "~~/components/scaffold-eth";
export const GET_MESSAGES = gql`
{
sendMessages(first: 5) {
@kmjones1979
kmjones1979 / nft.ts
Created September 16, 2023 20:07
example ipfs metadata
import { useState } from 'react';
import ipfsHttpClient from 'ipfs-http-client';
const IPFSUploader: React.FC = () => {
const [name, setName] = useState<string>('');
const [description, setDescription] = useState<string>('');
const [budget, setBudget] = useState<number>(0);
const [image, setImage] = useState<File | null>(null);
const [ipfsResponse, setIPFSResponse] = useState<any | null>(null);
@kmjones1979
kmjones1979 / schema.graphql
Created September 6, 2023 00:08
derivedFrom schema
type PostCreated @entity(immutable: true) {
id: Bytes!
ownerId: BigInt!
contentURI: String!
timestamp: BigInt!
}
type PostContent @entity(immutable: true) {
id: Bytes!
hash: String!
@kmjones1979
kmjones1979 / contract.ts
Created September 6, 2023 00:07
handler
import {
Bytes,
dataSource,
DataSourceContext,
DataSourceTemplate,
log,
ipfs,
json,
} from "@graphprotocol/graph-ts";
import {
@kmjones1979
kmjones1979 / index.ts
Last active February 9, 2024 23:55
Example for Full Stack dapp Development Workshop
"use client";
import { useState } from "react";
import { gql } from "@apollo/client";
import { useQuery } from "@apollo/client";
import type { NextPage } from "next";
import { useAccount } from "wagmi";
import { Address, AddressInput, Balance } from "~~/components/scaffold-eth";
import {
useAccountBalance,
@kmjones1979
kmjones1979 / index.tsx
Created August 9, 2023 23:01
Example table showcasing the messages coming from The Graph using GraphQL
import Link from "next/link";
import type { NextPage } from "next";
import { BugAntIcon, MagnifyingGlassIcon, SparklesIcon } from "@heroicons/react/24/outline";
import { MetaHeader } from "~~/components/MetaHeader";
import { gql } from '@apollo/client';
import { useQuery } from '@apollo/client';
export const GET_MESSAGES = gql`
{
messages(first: 10, orderBy: createdAt, orderDirection: asc) {