Skip to content
Snippets Groups Projects
Commit 2172a25f authored by Renzo Mauro Ontivero's avatar Renzo Mauro Ontivero
Browse files

Send TX Celo

parent e9287975
No related branches found
No related tags found
No related merge requests found
......@@ -28,5 +28,44 @@ module.exports = {
return res.json(balance);
},
send : async function (req, res){
sails.log('Send()');
sails.log(req.body)
// 10. Get your account
let from = req.body.from
// 11. Add your account to ContractKit to sign transactions
kit.addAccount(req.body.private_key)
// 12. Specify recipient Address
let to = req.body.to
// 13. Specify an amount to send
let amount = req.body.value
// 14. Get the Gold Token contract wrapper
let goldtoken = await kit.contracts.getGoldToken()
// 15. Transfer gold from your account to anAddress
let tx = await goldtoken.transfer(to, amount).send({from: from})
// 16. Wait for the transaction to be processed
let receipt = await tx.waitReceipt()
// 17. Print receipt
console.log('Transaction receipt: %o', receipt)
// 18. Get your new balance
let balance = await goldtoken.balanceOf(from)
// 19. Print new balance
console.log(`Your new account balance: ${balance.toString()}`)
return res.json({
status: 'ok',
tx: receipt
})
}
};
......@@ -68,6 +68,8 @@ module.exports.routes = {
'POST /bfa/stamp' : 'BfaController.stamp',
'POST /bfa/send' : 'BfaController.send',
'POST /celo/send' : 'CeloController.send',
/***************************************************************************
* *
......
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