Guest User

Untitled

a guest
Jan 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. const msgParams = [{
  2. type: 'string', name: 'Message', value: 'Hi, Alice!'
  3. },{ type: 'uint32', name: 'A number', value: '1337'
  4. }];
  5. let from = Merchant.accounts[0];
  6. console.log(window.provider);
  7. let p = window.provider;
  8. console.log(Object.keys(window.web3));
  9.  
  10. window.web3.eth.sign(from, msgParams, function(err, res) {
  11. console.log(err);
  12. console.log(res);
  13. });
  14.  
  15. web3.eth.getAccounts(function(a,b) {
  16. Merchant.accounts = b;
  17. // alert("Saving accounts" + Merchant.accounts);
  18. console.log("Merchant accounts: " + Merchant.accounts);
  19. let x = web3.eth.getBalance;
  20. console.log(x);
  21. });
  22.  
  23.  
  24.  
  25. toChecksumAddress (address) {
  26. address = address.toLowerCase().replace('0x', '')
  27. var hash = createKeccakHash('keccak256').update(address).digest('hex')
  28. var ret = '0x'
  29.  
  30. for (var i = 0; i < address.length; i++) {
  31. if (parseInt(hash[i], 16) >= 8) {
  32. ret += address[i].toUpperCase()
  33. } else {
  34. ret += address[i]
  35. }
  36. }
  37.  
  38. return ret
  39. }
  40.  
  41. reloadKeys() {
  42. const msgParams = [{
  43. type: 'string', name: 'Message', value: 'Hi, Alice!'
  44. },{ type: 'uint32', name: 'A number', value: '1337'
  45. }];
  46. // Merchant.accounts[0]
  47. // let addr = 0x2E290A50d3193753F156e5b0b12e4231Bd568526;
  48. let from = this.toChecksumAddress(Merchant.accounts[0]);
  49.  
  50. // window.web3.utils.toChecksumAddress();
  51. console.log(typeof(from));
  52. console.log(from);
  53.  
  54. console.log(Object.keys(window.web3));
  55.  
  56. window.web3.eth.sign(from, msgParams, function(err, res) {
  57. console.log(err);
  58. console.log(res);
  59. });
  60.  
  61. let from = web3.toChecksumAddress(Merchant.accounts[0]);
Add Comment
Please, Sign In to add comment