-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (33 loc) · 1.13 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const express = require('express');
const path = require('path');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
// Get contract information from deployment-info.json
const deploymentInfoPath = path.join(__dirname, 'deployment-info.json');
let contractData = {};
try {
const deploymentInfo = fs.readFileSync(deploymentInfoPath, 'utf8');
contractData = JSON.parse(deploymentInfo);
console.log(`Contract address: ${contractData.address}`);
} catch (error) {
console.error('Failed to read deployment-info.json:', error.message);
}
// Use public folder to serve static files
app.use(express.static(path.join(__dirname, 'public')));
// API endpoint to serve contract information
app.get('/api/contract-info', (req, res) => {
res.json({
address: contractData.address,
abi: contractData.abi
});
});
// Serve main page
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Start server
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
console.log(`Open this address in your browser to access the NFT Mint UI`);
});