Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsa1
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Renzo Mauro Ontivero
tsa1
Commits
2172a25f
Commit
2172a25f
authored
5 years ago
by
Renzo Mauro Ontivero
⚽
Browse files
Options
Downloads
Patches
Plain Diff
Send TX Celo
parent
e9287975
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/controllers/CeloController.js
+39
-0
39 additions, 0 deletions
api/controllers/CeloController.js
config/routes.js
+2
-0
2 additions, 0 deletions
config/routes.js
with
41 additions
and
0 deletions
api/controllers/CeloController.js
+
39
−
0
View file @
2172a25f
...
...
@@ -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
})
}
};
This diff is collapsed.
Click to expand it.
config/routes.js
+
2
−
0
View file @
2172a25f
...
...
@@ -68,6 +68,8 @@ module.exports.routes = {
'
POST /bfa/stamp
'
:
'
BfaController.stamp
'
,
'
POST /bfa/send
'
:
'
BfaController.send
'
,
'
POST /celo/send
'
:
'
CeloController.send
'
,
/***************************************************************************
* *
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment