Guest User

Untitled

a guest
Apr 25th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <script>
  2. var zippieprovider = require('vault-web3-provider')
  3. var vault = require('vault-api')
  4. var vaultSecp256k1 = require('vault-api/src/secp256k1.js')
  5. var Web3 = require('web3');
  6.  
  7. export default {
  8. name: 'dashboard',
  9. data() {
  10. return {
  11.  
  12. }
  13. },
  14. beforeCreate: function() {
  15. var opts = {}
  16.  
  17. if (location.hash.startsWith('#zippie-vault=')) {
  18. opts = {
  19. 'vaultURL': location.hash.slice('#zippie-vault='.length)
  20. }
  21. }
  22. vault.init(opts).then((result) => {
  23. console.log('got inited:')
  24. console.log(result)
  25. var provider = zippieprovider.init(vault, vaultSecp256k1, {
  26. network: 'kovan'
  27. })
  28. zippieprovider.addAccount('m/0').then((addy) => {
  29. console.log(addy)
  30. var web3 = new Web3(provider)
  31. web3.eth.getAccounts().then((accounts) => {
  32. console.log('accounts:')
  33. console.log(accounts)
  34. web3.eth.sendTransaction({
  35. from: accounts[0],
  36. gasPrice: "2000000000",
  37. gas: "21000",
  38. to: '0x21ef24ffb2116f44e7918a80cea4f52a2ea72b17',
  39. value: "1",
  40. data: ""
  41. }).once('transactionHash', function(hash) {
  42. console.log('transaction ' + hash)
  43. })
  44. .once('receipt', function(receipt) {
  45. console.log('receipt ' + receipt)
  46. })
  47. .on('confirmation', function(confirmationNumber, receipt) {
  48. console.log('confirmation ' + confirmationNumber + " " + receipt)
  49. })
  50. .on('error', console.error)
  51. })
  52. })
  53.  
  54. }, (error) => {
  55. console.log('encountered error: ')
  56. if (error.error === 'launch') {
  57. vault.launch(error.launch)
  58. }
  59. console.log(error)
  60. })
  61. },
  62. methods: {
  63.  
  64. }
  65. }
  66. </script>
Add Comment
Please, Sign In to add comment