Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const web3 = require('web3');
- const EthereumTx = require('ethereumjs-tx');
- const address = 'publicAddress';
- const privateKey = Buffer.from('privateKey', 'hex');
- const txParams = {
- nonce: web3.toHex(web3.eth.getTransactionCount(address)),
- to: destAddress,
- gasPrice: web3.toHex(21000000000),
- gasLimit: web3.toHex(21000),
- value: web3.toHex(web3.toWei(1, 'ether')),
- data: '',
- // EIP 155 chainId - mainnet: 1, ropsten: 3
- // chainId: 3
- };
- const tx = new EthereumTx(txParams);
- tx.sign(privateKey);
- const serializedTx = tx.serialize();
- // const serializedTx = `0x${tx.serialize().toString('hex')}`;
- /*web3.eth.sendRawTransaction(serializedTx, (error, data) => {
- if (!error) {
- return console.log(data);
- }
- return console.log(error);
- });*/
Add Comment
Please, Sign In to add comment