Advertisement
noler89

Untitled

Oct 7th, 2017
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. var Web3 = require('web3');
  2. var web3 = new Web3(new Web3.providers.HttpProvider(' https://api.myetherapi.com/eth'));
  3. var util = require('ethereumjs-util');
  4. var tx = require('ethereumjs-tx');
  5.  
  6. var privateKey = '0xdd5cf38ed5ba18e6113163bf9c861bed71e5779b5918bec15170ea148163d184';
  7. var publicKey = util.bufferToHex(util.privateToPublic(privateKey));
  8. var address = '0x' + util.bufferToHex(util.sha3(publicKey)).slice(26);
  9.  
  10. var rawTx = {
  11. nonce: web3.toHex(web3.eth.getTransactionCount(address)),
  12. gasPrice: web3.toHex(web3.eth.gasPrice),
  13. gasLimit: web3.toHex(21000),
  14. to: '0xeba714c41e15b95dffb115c287eb6f42d5657f13',
  15. value: web3.toHex(1000000000),
  16. data: ''
  17. };
  18.  
  19. var p = new Buffer('dd5cf38ed5ba18e6113163bf9c861bed71e5779b5918bec15170ea148163d184', 'hex');
  20. var transaction = new tx(rawTx);
  21. transaction.sign(p);
  22. var serializedTx = transaction.serialize().toString('hex');
  23. console.log(util.bufferToHex(transaction.hash(true)));
  24. console.log('0x'+serializedTx);
  25.  
  26. web3.eth.sendRawTransaction('0x'+serializedTx, function(err, hash) {
  27. if (!err)
  28. console.log(hash);
  29. //"0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385"
  30. if (err)
  31. console.log('pidr')
  32. });
  33.  
  34.  
  35. var Web3 = require('web3');
  36. var web3 = new Web3(new Web3.providers.HttpProvider('https://mewapi.epool.io/'));
  37. var util = require('ethereumjs-util');
  38. var tx = require('ethereumjs-tx');
  39.  
  40. var privateKey = '0xd4b6a8f67e1dbd4e2679525e6242971b0ef02645465dd744eece4049b11013e7';
  41. var publicKey = util.bufferToHex(util.privateToPublic(privateKey));
  42. var address = '0x' + util.bufferToHex(util.sha3(publicKey)).slice(26);
  43.  
  44. var rawTx = {
  45. nonce: web3.toHex(web3.eth.getTransactionCount(address)),
  46. gasPrice: web3.toHex(web3.eth.gasPrice),
  47. gasLimit: web3.toHex(21000),
  48. to: '0x8D1Bda8913956FC45bc864F4979C02426f39A0e4',
  49. value: web3.toHex(1000000000),
  50. data: ''
  51. };
  52.  
  53. var p = new Buffer('d4b6a8f67e1dbd4e2679525e6242971b0ef02645465dd744eece4049b11013e7', 'hex');
  54. var transaction = new tx(rawTx);
  55. transaction.sign(p);
  56. var serializedTx = transaction.serialize().toString('hex');
  57. console.log(util.bufferToHex(transaction.hash(true)));
  58. console.log('0x'+serializedTx);
  59.  
  60. web3.eth.sendRawTransaction('0x'+serializedTx, function(err, hash) {
  61. if (!err)
  62. console.log(hash);
  63. if (err)
  64. console.log('pidr')
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement