Skip to main content
added 4 characters in body
Source Link
clement
  • 4.4k
  • 2
  • 18
  • 36

The problem likely comes from these two lines :

tx.sign(accountPk);
const serializedTx = tx.serialize();

This was correct in the v2 of ethereumjs-tx but this is not anymore in the v3 release.

What you are doing here is serializing the unsignedunsigned transaction. Indeed we can read in the comments at the top of the sign method (see https://github.com/ethereumjs/ethereumjs-vm/blob/6c0490056cdd1b5c45f6b74f21a0e317e1e5f082/packages/tx/src/transaction.ts#L227) :

Sign a transaction with a given private key. Returns a new Transaction object (the original tx will not be modified).

You need to save the signed transaction in a variable and apply serialization to it :

const signedTx = tx.sign(privateKey)
const serializedTx = signedTx.serialize()

Note : There is an archive folder for the v2 (https://github.com/ethereumjs/ethereumjs-tx), not to be confused with the folder dedicated to the v3 and current releases : https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/tx.

The problem likely comes from these two lines :

tx.sign(accountPk);
const serializedTx = tx.serialize();

This was correct in the v2 of ethereumjs-tx but this is not anymore in the v3 release.

What you are doing here is serializing the unsigned transaction. Indeed we can read in the comments at the top of the sign method (see https://github.com/ethereumjs/ethereumjs-vm/blob/6c0490056cdd1b5c45f6b74f21a0e317e1e5f082/packages/tx/src/transaction.ts#L227) :

Sign a transaction with a given private key. Returns a new Transaction object (the original tx will not be modified).

You need to save the signed transaction in a variable and apply serialization to it :

const signedTx = tx.sign(privateKey)
const serializedTx = signedTx.serialize()

Note : There is an archive folder for the v2 (https://github.com/ethereumjs/ethereumjs-tx), not to be confused with the folder dedicated to the v3 and current releases : https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/tx.

The problem likely comes from these two lines :

tx.sign(accountPk);
const serializedTx = tx.serialize();

This was correct in the v2 of ethereumjs-tx but this is not anymore in the v3 release.

What you are doing here is serializing the unsigned transaction. Indeed we can read in the comments at the top of the sign method (see https://github.com/ethereumjs/ethereumjs-vm/blob/6c0490056cdd1b5c45f6b74f21a0e317e1e5f082/packages/tx/src/transaction.ts#L227) :

Sign a transaction with a given private key. Returns a new Transaction object (the original tx will not be modified).

You need to save the signed transaction in a variable and apply serialization to it :

const signedTx = tx.sign(privateKey)
const serializedTx = signedTx.serialize()

Note : There is an archive folder for the v2 (https://github.com/ethereumjs/ethereumjs-tx), not to be confused with the folder dedicated to the v3 and current releases : https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/tx.

Source Link
clement
  • 4.4k
  • 2
  • 18
  • 36

The problem likely comes from these two lines :

tx.sign(accountPk);
const serializedTx = tx.serialize();

This was correct in the v2 of ethereumjs-tx but this is not anymore in the v3 release.

What you are doing here is serializing the unsigned transaction. Indeed we can read in the comments at the top of the sign method (see https://github.com/ethereumjs/ethereumjs-vm/blob/6c0490056cdd1b5c45f6b74f21a0e317e1e5f082/packages/tx/src/transaction.ts#L227) :

Sign a transaction with a given private key. Returns a new Transaction object (the original tx will not be modified).

You need to save the signed transaction in a variable and apply serialization to it :

const signedTx = tx.sign(privateKey)
const serializedTx = signedTx.serialize()

Note : There is an archive folder for the v2 (https://github.com/ethereumjs/ethereumjs-tx), not to be confused with the folder dedicated to the v3 and current releases : https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/tx.