-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
27,824 additions
and
10,002 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import React from 'react'; | ||
import { BrowserRouter, Routes, Route } from 'react-router-dom'; | ||
import Layout from './pages/Layout'; | ||
import UserAccountPage from './pages/UserAccountPage'; | ||
import LoginPage from './pages/LoginPage'; | ||
import MyNFTsPage from './pages/MyNFTsPage'; | ||
import MySoldNFTsPage from './pages/MySoldNFTsPage'; | ||
import MarketplacePage from './pages/MarketplacePage'; | ||
import CreateNFTPage from './pages/CreateNFTPage'; | ||
import NoPage from './pages/NoPage'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path="/" element={<Layout />}> | ||
<Route index element={<UserAccountPage />} /> {/* Assuming you want UserAccountPage as the home page */} | ||
<Route path="login" element={<LoginPage />} /> | ||
<Route path="account" element={<UserAccountPage />} /> | ||
<Route path="mynfts" element={<MyNFTsPage />} /> | ||
<Route path="mysoldnfts" element={<MySoldNFTsPage />} /> | ||
<Route path="marketplace" element={<MarketplacePage />} /> | ||
<Route path="createnft" element={<CreateNFTPage />} /> | ||
<Route path="*" element={<NoPage />} /> | ||
</Route> | ||
</Routes> | ||
</BrowserRouter> | ||
); | ||
} | ||
|
||
export default App; | ||
export default App; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import Web3 from 'web3'; | ||
import NFTContract from "../Contracts/NFT.json"; // Import your NFT contract ABI | ||
|
||
function EthereumInteraction() { | ||
const [web3, setWeb3] = useState(null); | ||
const [nftContract, setNFTContract] = useState(null); | ||
const [accounts, setAccounts] = useState([]); | ||
const [nftOwner, setNFTOwner] = useState(''); | ||
|
||
useEffect(() => { | ||
async function connectToMetaMask() { | ||
if (window.ethereum) { | ||
try { | ||
// Initialize Web3 | ||
const web3Instance = new Web3(window.ethereum); | ||
setWeb3(web3Instance); | ||
|
||
// Request account access | ||
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); | ||
setAccounts(accounts); | ||
|
||
// Initialize NFT contract | ||
const networkId = await web3Instance.eth.net.getId(); | ||
const deployedNetwork = NFTContract.networks[networkId]; | ||
const contract = new web3Instance.eth.Contract( | ||
NFTContract.abi, | ||
deployedNetwork && deployedNetwork.address | ||
); | ||
setNFTContract(contract); | ||
|
||
// Get owner of NFT | ||
if (contract) { | ||
const owner = await contract.methods.owner().call(); | ||
setNFTOwner(owner); | ||
} | ||
} catch (error) { | ||
console.error('Error connecting to MetaMask:', error); | ||
} | ||
} else { | ||
console.error('MetaMask is not installed'); | ||
} | ||
} | ||
connectToMetaMask(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h2>Ethereum Interaction</h2> | ||
{web3 ? ( | ||
<p>Connected to Ethereum network</p> | ||
) : ( | ||
<p>Not connected to Ethereum network</p> | ||
)} | ||
|
||
{accounts.length > 0 ? ( | ||
<p>Connected account: {accounts[0]}</p> | ||
) : ( | ||
<p>No accounts connected</p> | ||
)} | ||
|
||
{nftContract && ( | ||
<div> | ||
<p>NFT Contract Address: {nftContract._address}</p> | ||
<p>Owner of NFT Contract: {nftOwner}</p> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default EthereumInteraction; |
Oops, something went wrong.