Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Web3 = require('web3');
- var web3 = new Web3(new Web3.providers.HttpProvider(' https://api.myetherapi.com/eth'));
- var util = require('ethereumjs-util');
- var tx = require('ethereumjs-tx');
- var privateKey = '0xdd5cf38ed5ba18e6113163bf9c861bed71e5779b5918bec15170ea148163d184';
- var publicKey = util.bufferToHex(util.privateToPublic(privateKey));
- var address = '0x' + util.bufferToHex(util.sha3(publicKey)).slice(26);
- var rawTx = {
- nonce: web3.toHex(web3.eth.getTransactionCount(address)),
- gasPrice: web3.toHex(web3.eth.gasPrice),
- gasLimit: web3.toHex(21000),
- to: '0xeba714c41e15b95dffb115c287eb6f42d5657f13',
- value: web3.toHex(1000000000),
- data: ''
- };
- var p = new Buffer('dd5cf38ed5ba18e6113163bf9c861bed71e5779b5918bec15170ea148163d184', 'hex');
- var transaction = new tx(rawTx);
- transaction.sign(p);
- var serializedTx = transaction.serialize().toString('hex');
- console.log(util.bufferToHex(transaction.hash(true)));
- console.log('0x'+serializedTx);
- web3.eth.sendRawTransaction('0x'+serializedTx, function(err, hash) {
- if (!err)
- console.log(hash);
- //"0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385"
- if (err)
- console.log('pidr')
- });
- var Web3 = require('web3');
- var web3 = new Web3(new Web3.providers.HttpProvider('https://mewapi.epool.io/'));
- var util = require('ethereumjs-util');
- var tx = require('ethereumjs-tx');
- var privateKey = '0xd4b6a8f67e1dbd4e2679525e6242971b0ef02645465dd744eece4049b11013e7';
- var publicKey = util.bufferToHex(util.privateToPublic(privateKey));
- var address = '0x' + util.bufferToHex(util.sha3(publicKey)).slice(26);
- var rawTx = {
- nonce: web3.toHex(web3.eth.getTransactionCount(address)),
- gasPrice: web3.toHex(web3.eth.gasPrice),
- gasLimit: web3.toHex(21000),
- to: '0x8D1Bda8913956FC45bc864F4979C02426f39A0e4',
- value: web3.toHex(1000000000),
- data: ''
- };
- var p = new Buffer('d4b6a8f67e1dbd4e2679525e6242971b0ef02645465dd744eece4049b11013e7', 'hex');
- var transaction = new tx(rawTx);
- transaction.sign(p);
- var serializedTx = transaction.serialize().toString('hex');
- console.log(util.bufferToHex(transaction.hash(true)));
- console.log('0x'+serializedTx);
- web3.eth.sendRawTransaction('0x'+serializedTx, function(err, hash) {
- if (!err)
- console.log(hash);
- if (err)
- console.log('pidr')
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement