Skip to content

Commit

Permalink
Create transactions.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 16, 2024
1 parent 5e2ff01 commit 1255b3f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/api/routes/transactions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const express = require('express');
const router = express.Router();
const blockchainService = require('../services/blockchain');

router.post('/transfer', async (req, res) => {
const { sender, recipient, amount } = req.body;
try {
const transaction = await blockchainService.transfer(sender, recipient, amount);
res.json(transaction);
} catch (error) {
res.status(500).json({ error: 'Transaction failed' });
}
});

module.exports = router;

0 comments on commit 1255b3f

Please sign in to comment.