-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 1016 Bytes
/
index.js
File metadata and controls
33 lines (29 loc) · 1016 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
31
32
33
const neon = require('@cityofzion/neon-js');
const Neon = neon.default;
const node = require('./backend/blockchain')
const config = require('./backend/config')
const account = Neon.create.account(config.wif)
const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('API Alpha 1'));
app.get('/invokeContract/:task/:input', function(request, result) {
input = request.params.input.split(",");
node.invokeContract(request.params.task, input, account, (res) => {
if (res.result === true) {
result.send('Transaction processed!');
} else {
result.send('Transaction Failed!');
}
})
});
app.get('/getStorage/:key', function(request, result) {
key = request.params.key;
node.getStorage(key).then((res) => {
if (typeof res === "string") {
result.send(res);
} else{
result.send("Error",res.result);
}
})
});
app.listen(3000, () => console.log('API Server on Port 3000'));