Skip to content
Snippets Groups Projects
Commit ea3f5eb6 authored by Hernan Hegykozi's avatar Hernan Hegykozi
Browse files

Se agregan endpoint de balance, block y tx

parent 3b1809c1
No related branches found
No related tags found
No related merge requests found
......@@ -161,9 +161,75 @@ verify : async function (req, res){
});
}
}
}
},
balance : async function (req, res){
const now = new Date();
try{
const account = req.query.account || config.account.address;
console.log("[" + utils.dateFormat(now, "%d/%m/%Y %H:%M:%S", false) + "] : balance : ("+account+")");
var bal = await web3.eth.getBalance(account);
var eth = web3.utils.fromWei(bal, "ether") + " ETH";
return res.json({
account: account,
balanceETH: eth,
balanceWEI: bal
});
}
catch(err){
console.log("[" + utils.dateFormat(now, "%d/%m/%Y %H:%M:%S", false) + "] : ERROR balance : ", err);
return res.status(500).json({
messages: "No se pudo realizar la operacion",
status: "failure"
});
}
},
block : async function (req, res){
const now = new Date();
try{
const block_number = req.query.number;
console.log("[" + utils.dateFormat(now, "%d/%m/%Y %H:%M:%S", false) + "] : block : ("+block_number+")");
const block = await web3.eth.getBlock(block_number);
return res.json(block);
}
catch(err){
console.log("[" + utils.dateFormat(now, "%d/%m/%Y %H:%M:%S", false) + "] : ERROR block : ", err);
return res.status(500).json({
messages: "No se pudo realizar la operacion",
status: "failure"
});
}
} ,
tx : async function (req, res){
const now = new Date();
try{
const tx_hash = req.query.hash;
console.log("[" + utils.dateFormat(now, "%d/%m/%Y %H:%M:%S", false) + "] : tx : ("+tx_hash+")");
var tx = await web3.eth.getTransaction(tx_hash);
return res.json(tx);
}
catch(err){
console.log("[" + utils.dateFormat(now, "%d/%m/%Y %H:%M:%S", false) + "] : ERROR tx : ", err);
return res.status(500).json({
messages: "No se pudo realizar la operacion",
status: "failure"
});
}
}
}
\ No newline at end of file
......@@ -12,6 +12,18 @@ router.get('/address', (req, res) => {
res.send(config.account.address);
})
router.get('/balance', async (req, res) => {
await BfaController.balance(req, res);
})
router.get('/block', async (req, res) => {
await BfaController.block(req, res);
})
router.get('/tx', async (req, res) => {
await BfaController.tx(req, res);
})
router.post('/stamp', async (req, res) => {
await BfaController.stamp(req, res);
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment