Skip to content

Instantly share code, notes, and snippets.

View emmaglorypraise's full-sized avatar

Glory Praise emmaglorypraise

View GitHub Profile
import React, { useState } from "react";
import { ethers } from "ethers";
import "./App.css";

declare global {
  interface Window {
    ethereum?: ethers.Eip1193Provider;
  }
}

Writing the Smart Contract

1. Create a Project Directory

mkdir attendance-dapp
cd attendance-dapp

2. Install Hardhat:

Integration

1. Setup

declare global {
  interface Window {
    ethereum?: ethers.Eip1193Provider;
  }
} 

Setting Up the Frontend

1. Initialize a React App:

npm create vite@latest my-attendance-dapp -- --template react-ts
cd attendance-frontend
npm install     
npm install -D tailwindcss postcss autoprefixer  
npx tailwindcss init -p  
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract Crowdfunding {
uint public noOfCampaigns;
address public owner;
struct Campaign {
// What is Solidity?
// Contract Structure
// Variables(state variables vs local variables vs constant variables)
// Types
// - bool
// - integars
// - address
// Functions
// Visibility(internal, external, private, public)
// Modifiers(pure and view functions modifiers)
@emmaglorypraise
emmaglorypraise / voting.sol
Last active June 3, 2024 16:58
A voting contract for football clubs
Deployed contract address(polygon mainnet) = 0x4bc4154b03B7fBbE72CBFA33aDe77BB820FbB337
// ABI
"abi": [
{
"inputs": [
{
"internalType": "string[]",
@emmaglorypraise
emmaglorypraise / NFT.sol
Created August 3, 2023 18:19
NFT with EIP 2535
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import {ERC721AppStorage} from "../libraries/AppStorage.sol";
// import "../interfaces/IERC721.sol";
// import "../interfaces/IERC721Receiver.sol";
contract TwikklNFT {
ERC721AppStorage internal s;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
contract Santa1966 is ERC20, Ownable {
using SafeMath for uint256;
@emmaglorypraise
emmaglorypraise / create3.sol
Created October 17, 2022 22:32
A factory contract A deploys a child contract B using create 3. Contract B has a constructor which contains a struct as a parameter. Contract A must send 2 ether to contract B upon deployment. A function is available in contract that cryptographically checks that contract B was deployed by him(Contract A)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import {Create3} from "./lib.sol";
//https://github.com/0xsequence/create3 - imported library
struct Work {
uint8 number;
}
contract Factory {