Skip to content

Jb branch #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions contracts/Counter.sol

This file was deleted.

54 changes: 54 additions & 0 deletions contracts/StudentReg.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract StudentRegistry {
struct Student {
string name;
uint256 age;
string course;
string[] interests;
}

mapping(address => Student) private students;
address[] private studentAddresses;
address public owner;

event StudentRegistered(address indexed studentAddress, string name, uint256 age, string course, string[] interests);
event StudentUpdated(address indexed studentAddress, string name, uint256 age, string course, string[] interests);

modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can perform this action");
_;
}

constructor() {
owner = msg.sender;
}

function registerStudent(string memory _name, uint256 _age, string memory _course, string[] memory _interests) public {
require(bytes(_name).length > 0, "Name cannot be empty");
require(_age > 0, "Age must be greater than zero");
require(bytes(_course).length > 0, "Course cannot be empty");

students[msg.sender] = Student(_name, _age, _course, _interests);
studentAddresses.push(msg.sender);
emit StudentRegistered(msg.sender, _name, _age, _course, _interests);
}

function updateStudent(string memory _name, uint256 _age, string memory _course, string[] memory _interests) public {
require(bytes(students[msg.sender].name).length > 0, "Student not registered");

students[msg.sender] = Student(_name, _age, _course, _interests);
emit StudentUpdated(msg.sender, _name, _age, _course, _interests);
}

function getStudent(address _studentAddress) public view returns (string memory, uint256, string memory, string[] memory) {
require(bytes(students[_studentAddress].name).length > 0, "Student not found");
Student memory student = students[_studentAddress];
return (student.name, student.age, student.course, student.interests);
}

function getAllStudents() public view onlyOwner returns (address[] memory) {
return studentAddresses;
}
}
35 changes: 35 additions & 0 deletions contracts/counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Counter {
uint256 private count;
address public owner;

event CounterIncremented(uint256 newCount);
event CounterDecremented(uint256 newCount);

constructor() {
owner = msg.sender;
count = 0;
}

modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can modify the counter");
_;
}

function increment() public onlyOwner {
count++;
emit CounterIncremented(count);
}

function decrement() public onlyOwner {
require(count > 0, "Counter cannot be negative");
count--;
emit CounterDecremented(count);
}

function getCount() public view returns (uint256) {
return count;
}
}
41 changes: 41 additions & 0 deletions contracts/counterapp/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions contracts/counterapp/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file added contracts/counterapp/frontend/app/favicon.ico
Binary file not shown.
24 changes: 24 additions & 0 deletions contracts/counterapp/frontend/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--background: #ffffff;
--foreground: #171717;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

.body {
background-image:
linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
background-size: 100px 100px;

font-family: Arial, Helvetica, sans-serif;
}
34 changes: 34 additions & 0 deletions contracts/counterapp/frontend/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
);
}
55 changes: 55 additions & 0 deletions contracts/counterapp/frontend/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use client";
import { useState } from "react";

export default function Counter() {
const [count, setCount] = useState(0);

const getCount = () => {
alert(`Current Count: ${count}`);
};

return (
<div className="min-h-screen bg-blue -100">
{/* Header */}
<header className="flex justify-between items-center p-4 bg-white shadow-md">
<h1 className="text-2xl font-bold">JB-Counter</h1>
<button className="px-4 py-2 bg-black -500 text-white rounded-lg">
Connect Wallet
</button>
</header>

{/* Counter Section */}
<div className="flex flex-col items-center justify-center mt-20">
<div className="p-6 bg-white shadow-lg rounded-lg text-center">
<h1 className="text-4xl font-bold mb-4">{count}</h1>
<div className="space-x-3">
<button
onClick={() => setCount(count + 1)}
className="px-4 py-2 bg-green-500 text-white rounded-lg"
>
Increase
</button>
<button
onClick={() => setCount(count - 1)}
className="px-4 py-2 bg-red-500 text-white rounded-lg"
>
Decrease
</button>
<button
onClick={() => setCount(0)}
className="px-4 py-2 bg-gray-500 text-white rounded-lg"
>
Reset
</button>
<button
onClick={getCount}
className="px-4 py-2 bg-blue-500 text-white rounded-lg"
>
Get Count
</button>
</div>
</div>
</div>
</div>
);
}
7 changes: 7 additions & 0 deletions contracts/counterapp/frontend/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
Loading