Skip to content
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

contracts added #1

Open
wants to merge 9 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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
"node": ">=18.17.0"
},
"dependencies": {
"axios": "^1.7.2"
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@ethereum-attestation-service/eas-sdk": "^2.3.0",
"apexcharts": "^3.49.2",
"axios": "^1.7.2",
"react-apexcharts": "^1.4.1"
}
}
22 changes: 22 additions & 0 deletions packages/hardhat/contracts/MyToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
//https://sepolia.basescan.org/address/0x059ee9bde2aff94d0e6ad396ec0ec7d27bff6dc8
contract MyToken is ERC20, Ownable, ERC20Permit {
constructor(address initialOwner)
ERC20("USDC", "USDC")
Ownable(initialOwner)
ERC20Permit("MyToken")
{}

function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function trf(address seller, uint256 amount, uint256 qt) public {
uint256 tamount = qt*amount;
_transfer(msg.sender, seller, tamount);
}

}
87 changes: 0 additions & 87 deletions packages/hardhat/contracts/YourContract.sol

This file was deleted.

2 changes: 1 addition & 1 deletion packages/hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const etherscanApiKey = process.env.ETHERSCAN_API_KEY || "DNXJA8RX2Q3VZ4URQIWP7Z

const config: HardhatUserConfig = {
solidity: {
version: "0.8.17",
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"typescript": "^5.1.6"
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.1",
"@openzeppelin/contracts": "^5.0.2",
"@typechain/ethers-v6": "^0.5.1",
"dotenv": "^16.0.3",
"envfile": "^6.18.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/dashboard/[productID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ const Product: NextPage = () => {
);
};

export default Product;
export default Product;
73 changes: 73 additions & 0 deletions packages/nextjs/app/dashboard/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// src/App.js

import React, { useState } from 'react';

const slides = [
{ id: 1, title: 'Slide 1', content: 'This is the first slide' },
{ id: 2, title: 'Slide 2', content: 'This is the second slide' },
{ id: 3, title: 'Slide 3', content: 'This is the third slide' },

];

const App = () => {
const [currentSlide, setCurrentSlide] = useState(0);

const appStyle = {
display: 'flex',
height: '100vh',
};

const sidebarStyle = {
width: '200px',
backgroundColor: '#f5f5f5',
padding: '10px',
boxShadow: '2px 0 5px rgba(0, 0, 0, 0.1)',
overflowY: 'auto',
};

const thumbnailStyle = {
padding: '10px',
marginBottom: '10px',
cursor: 'pointer',
backgroundColor: 'white',
borderRadius: '5px',
transition: 'background-color 0.3s',
};

const thumbnailActiveStyle = {
...thumbnailStyle,
backgroundColor: '#c0c0c0',
};

const mainSlideStyle = {
flexGrow: 1,
padding: '20px',
};

const mainSlideTitleStyle = {
marginTop: 0,
};

return (
<div style={appStyle}>
<div style={sidebarStyle}>
{slides.map((slide, index) => (
<div
key={slide.id}
style={index === currentSlide ? thumbnailActiveStyle : thumbnailStyle}
onClick={() => setCurrentSlide(index)}
>
{slide.title}
</div>
))}
</div>
<div style={mainSlideStyle}>
<h2 style={mainSlideTitleStyle}>{slides[currentSlide].title}</h2>
<p>{slides[currentSlide].content}</p>
</div>
</div>
);
};

export default App;

150 changes: 142 additions & 8 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,146 @@
import type { NextPage } from "next";
import { Banner } from "~~/components/Banner";
"use client"
import { useAccount } from "wagmi";
import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline";
import { Address } from "~~/components/scaffold-eth";
import { ENTRYPOINT_ADDRESS_V06, createSmartAccountClient } from "permissionless";
import { privateKeyToSimpleSmartAccount } from "permissionless/accounts";
import { createPimlicoPaymasterClient } from "permissionless/clients/pimlico";
import { createPublicClient, encodeFunctionData, http } from "viem";
import { baseSepolia } from "viem/chains";
import { ethers } from "ethers";
import Link from "next/link";

const Home: NextPage = () => {
import { useState } from "react";

const Home = () => {
const { address: connectedAddress } = useAccount();
const [data, setData] = useState("")

async function lfg() {
const rpcUrl = "https://api.developer.coinbase.com/rpc/v1/base-sepolia/vgD307g2ysf5BvXO57OAi1bfmAwUBgNn";

const publicClient = createPublicClient({
transport: http(rpcUrl),
});

const simpleAccount = await privateKeyToSimpleSmartAccount(publicClient, {
// Set this to your private key
privateKey: "0xc04f2876f3691d44fdba3592bf800c05516d419f10ac269a7a565c21dfda57fa",
factoryAddress: "0x9406Cc6185a346906296840746125a0E44976454",
entryPoint: ENTRYPOINT_ADDRESS_V06,
});

const cloudPaymaster = createPimlicoPaymasterClient({
chain: baseSepolia,
transport: http(rpcUrl),
entryPoint: ENTRYPOINT_ADDRESS_V06,

});

const smartAccountClient = createSmartAccountClient({
account: simpleAccount,
chain: baseSepolia,
bundlerTransport: http(rpcUrl),
// IMPORTANT: Set up Cloud Paymaster to sponsor your transaction
middleware: {
sponsorUserOperation: cloudPaymaster.sponsorUserOperation,
},
});

const sellerAddress = "0x027fe3f132403C1B59DDAbA14B576D15865F69C0";

let num = BigInt('5000000000000000000');
let num2 = BigInt('1');
console.log(num)
console.log({ simpleAccount, smartAccountClient, rpcUrl, cloudPaymaster, publicClient })
const abi = [
{
inputs: [
{ internalType: "address", name: "recipient", type: "address" },
{ internalType: "uint16", name: "item", type: "uint16" },
],
name: "mintTo",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "payable",
type: "function",
},
];

const callData = encodeFunctionData({
abi: abi,
functionName: "mintTo",
args: [smartAccountClient.account.address, 0],
});

const txHash = await smartAccountClient.sendTransaction({
account: smartAccountClient.account,
to: "0x66519FCAee1Ed65bc9e0aCc25cCD900668D3eD49",
data: callData,
value: 0n,
});
console.log("✅ Transaction successfully sponsored!");
console.log(`🔍 View on Etherscan: https://sepolia.basescan.org/tx/${txHash}`);
}
return (
<div className="flex items-center flex-col flex-grow pt-10 page">
<Banner />
</div>
<>
<div className="flex items-center flex-col flex-grow pt-10">
<div className="px-5">
<h1 className="text-center">
<span className="block text-2xl mb-2">Welcome to</span>
<span className="block text-4xl font-bold">Scaffold-ETH 2</span>
</h1>
<div className="flex justify-center items-center space-x-2">
<p className="my-2 font-medium">Connected Address:</p>

</div>
<p className="text-center text-lg">
Get started by editing{" "}
<code className="italic bg-base-300 text-base font-bold max-w-full break-words break-all inline-block">
packages/nextjs/app/page.tsx
</code>
</p>
<p className="text-center text-lg">
Edit your smart contract{" "}
<code className="italic bg-base-300 text-base font-bold max-w-full break-words break-all inline-block">
YourContract.sol
</code>{" "}
in{" "}
<code className="italic bg-base-300 text-base font-bold max-w-full break-words break-all inline-block">
packages/hardhat/contracts
</code>
</p>
</div>

<div className="flex-grow bg-base-300 w-full mt-16 px-8 py-12">
<div className="flex justify-center items-center gap-12 flex-col sm:flex-row">
<div className="flex flex-col bg-base-100 px-10 py-10 text-center items-center max-w-xs rounded-3xl">
<BugAntIcon className="h-8 w-8 fill-secondary" />
<p>
Tinker with your smart contract using the{" "}
<Link href="/debug" passHref className="link">
Debug Contracts
</Link>{" "}
tab.
</p>
</div>
<div className="flex flex-col bg-base-100 px-10 py-10 text-center items-center max-w-xs rounded-3xl">
<MagnifyingGlassIcon className="h-8 w-8 fill-secondary" />
<>
<button onClick={lfg}> Send txn </button>
</>
<p>
Explore your local transactions with the{" "}
<Link href="/blockexplorer" passHref className="link">
Block Explorer
</Link>{" "}
tab.
</p>
</div>
</div>
</div>
</div>
</>

);
};

export default Home;
export default Home;
Loading