I am using PHP and ethereum-tx library https://github.com/web3p/ethereum-tx to sign transactions but when trying to send them to the node I got an "invalid sender" error. Besides, exactly the same transaction signed by myEtherWallet https://www.myetherwallet.com/#offline-transaction yields a different result. So I guess ethereum-tx library is applying a different standard than myEtherWallet or I am doing something wrong when signing transaction.

The transaction is a very simple one, just sending 0.1 ether from a wallet to a contract:

$fromAddress = '0x0a2E9bBA44b58841174115b4859297D86d6e8eB0'; // My wallet
$fromPassword = '0x...'; // My pkey
$toAddress = '0x7665822efbd0fde3a4f3f57eccaecdc99b8a64a4'; // A contract address

$transaction = new Transaction([
     'nonce' => '0x14',
     'from' => $fromAddress,
     'to' => $toAddress,
     'gas' => '0x5208',
     'gasPrice' => '0x00',
     'value' => '0x016345785d8a0000' // 0.1 eth

This is PHP code for signing the transaction:

use Web3p\EthereumTx\Transaction;

$transaction = ... <the code above>

$signedTransaction = $transaction->sign($fromPassword);

And the resulting signed transaction is:


Meanwhile same tx signed through myEtherWallet returns:


How can I find out why first signed transaction is invalid and how to fix it? Any ideas? Thx!


1 Answer 1


The transaction is invalid in Ropsten because chainId has not been specified. Fix like that:

$transaction = new Transaction([
     'nonce' => $nextNonce,
     'from' => $fromAddress,
     'to' => $toAddress,
     'gas' => $gas,
     'gasPrice' => $gasPrice,
     'value' => $amountWeis,
     'chainId' => 3,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.