Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ARVINDH-CT06 committed Oct 19, 2024
1 parent 528f6a6 commit a5bf223
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 21 deletions.
23 changes: 23 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"license": "ISC",
"description": "",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.1"
}
}
15 changes: 13 additions & 2 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ const app = express();
app.use(express.json());
app.use(cors());

// Sample wallet data (you can replace this with actual wallet logic)
let walletData = {
address: '0x1234567890abcdef1234567890abcdef12345678',
balance: 1.5, // Example balance in ETH
};

// Define a route to get wallet data
app.get('/api/wallet', (req, res) => {
res.json(walletData);
});

// Define a basic route for testing
app.get('/', (req, res) => {
res.send('Hello World from the Express server!');
res.send('Hello World from the Express server!');
});

// Start the server on port 3001
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
console.log('Server is running on http://localhost:${PORT}');
console.log('Server is running on http://localhost:${PORT}');
});
19 changes: 0 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,3 @@
}
}

{
"name": "walletassign",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"express": "^4.18.2",
"cors": "^2.8.5"
},
"devDependencies": {
    ...
  }
}
40 changes: 40 additions & 0 deletions src/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { useEffect, useState } from 'react';

const Home = () => {
const [walletData, setWalletData] = useState(null);

useEffect(() => {
// Fetch wallet data from the backend
const fetchWalletData = async () => {
try {
const response = await fetch('http://localhost:3001/api/wallet'); // Adjust the API endpoint as necessary
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
setWalletData(data);
} catch (error) {
console.error('Error fetching wallet data:', error);
}
};

fetchWalletData();
}, []);

return (
<div>
<h1>Welcome to the Web3 Wallet</h1>
{walletData ? (
<div>
<h2>Your Wallet Information</h2>
<p>Address: {walletData.address}</p>
<p>Balance: {walletData.balance} ETH</p>
</div>
) : (
<p>Loading wallet information...</p>
)}
</div>
);
};

export default Home;

0 comments on commit a5bf223

Please sign in to comment.