'Is it possible to have different result for eth tx signing methods? What is the solution in order to sign txs without eth node rpc connection?
I used to run an eth node and sign the txs using web3 library.
//tx = {from, to, data, ...}
const privateKey = 'XXX' (without 0x prefix);
let web3SignedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
I decided to stop running Eth node and to sign txs with a different way, using ethereumjs-tx.
const Eth_Tx = require('ethereumjs-tx').Transaction;
const privateKeyBuffer = Buffer.from(privateKey, 'hex');
let txObj = new Eth_Tx(tx);
txObj.sign(privateKeyBuffer);
let serializedTx = txObj.serialize();
let rawTransaction = '0x' + serializedTx.toString('hex');
The problem is that the above method does not produce the same rawTransaction output as the web3 method. (web3SignedTx.rawTransaction !== rawTransaction)
It cannot be broadcasted as well.
I dont know what i am missing here, can you provide any suggestion/solution for the above problem or for a method that i can sign txs without the need of eth-node or any rpc connection?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
