-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
30 lines (27 loc) · 787 Bytes
/
cli.js
File metadata and controls
30 lines (27 loc) · 787 Bytes
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
const readline = require('readline');
const axios = require('axios');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function promptTransaction() {
rl.question('🧾 From wallet name: ', (from) => {
rl.question('🎯 To public key: ', (to) => {
rl.question('💰 Amount: ', async (amount) => {
try {
await axios.post('http://localhost:3000/transaction', {
from,
to,
amount: parseFloat(amount)
});
console.log('✅ Transaction sent!');
} catch (err) {
console.error('❌ Error:', err.message);
}
promptTransaction(); // Loop lagi
});
});
});
}
console.log('🚀 CLI Transaction Sender');
promptTransaction();