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:
<?
require_once('vendor/autoload.php');
use Web3p\EthereumTx\Transaction;
$transaction = ... <the code above>
$signedTransaction = $transaction->sign($fromPassword);
?>
And the resulting signed transaction is:
0xf8671480825208947665822efbd0fde3a4f3f57eccaecdc99b8a64a488016345785d8a00008023a0b21679034fd6304c1058a5d7505e284630fec38a0f8d3551261e9c45f056859aa041b397f49f566ce12fec2de93934987d119ab7ced2b0916ddb993b0879707d05
Meanwhile same tx signed through myEtherWallet returns:
0xf8671480825208947665822efbd0fde3a4f3f57eccaecdc99b8a64a488016345785d8a0000802aa0f0dd7d6e244b43b2ca138fef989c38f40bac304f50f4c052ef0c4175eaffeac3a038cb792e21016c171355afefc821fe9ec3b7accce9a094e7a6f5a9129c34b5ac
How can I find out why first signed transaction is invalid and how to fix it? Any ideas? Thx!
gasPrice
:'gasPrice' => '0x9184e72a000'
(10 gwei)