leonsuke

BalanceController

Jan 9th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. 'use strict'
  2.  
  3. var Web3 = require("web3")
  4. var util = require("util")
  5.  
  6. const mainnet = 'http://127.0.0.1:7545'
  7. // const Balance = use('App/Models/etherium/Balance')
  8.  
  9. let web3 = new Web3(new Web3.providers.HttpProvider(mainnet));
  10.  
  11. class BalanceController {
  12. newBalances() {
  13. web3.eth.getBalance(address)
  14. .then(data => callback(data))
  15.  
  16. // Attaches a callback for only the rejection of the Promise
  17. .catch(err => {
  18. console.log("Error: " + err)
  19. })
  20. }
  21.  
  22. async balanceStore({ request, response, auth }) {
  23. const gb = await web3.eth.getBalance(request.input('address'))
  24.  
  25. console.log(util.inspect(gb))
  26. }
  27. }
  28.  
  29. module.exports = BalanceController
Advertisement
Add Comment
Please, Sign In to add comment