I'm working on a mobile wallet app, where I sign a raw transaction and try to broadcast it through https://etherscan.io/pushTx.
The problem is that it sometimes gives me the error "insufficient funds for gas * price + value" as expected(because there are zero ETHs in my account). But sometimes it fails with error "invalid sender".
The following are two transactions signed with identical data(nonce, gas price, value, gas limit, the recipient address, the private key and etc.,) . One is working but the other is failing:
insufficient funds for gas * price + value: f86a80843b9aca0082ea6094380070128936d804f669f588acc54762deb1d8ed872386f26fc100008026a002ea646e10ec345e5412104b5f761b28cfd079a46a8e56aadf70798c1c0d6524a0253968a49677d70948546b68f6ba33ddab85ed37e82a59c86259ee13aa79f207
invalid sender: f86a80843b9aca0082ea6094380070128936d804f669f588acc54762deb1d8ed872386f26fc100008025a00db144bb2b0fb247c0aa31d6a8d7dc73f834c3c3ba32e1cb53180cb900d23ce1a08d2b86e0adb07455e657409a0d676f6ed7cb90b369be3ce5762726cc30c6ea41
I tried decoding the transactions above using ehters-js with the following code and both produced valid from address and chain ID:
function decodeMyTx() { var serializedTx = document.getElementById("inputarea").value.trim(); if (!serializedTx.startsWith('0x')) { serializedTx = '0x' + serializedTx; } try { var tx = ethers.utils.parseTransaction(serializedTx); var rawTx = { nonce: tx.nonce, gasPrice: tx.gasPrice.toHexString() + ' -> ' + tx.gasPrice.toString(), gasLimit: tx.gasLimit.toHexString() + ' -> ' + tx.gasLimit.toString(), from: tx.from, to: tx.to, value: tx.value.toHexString() + ' -> ' + tx.value.toString(), data: tx.data, chain: tx.chainId, v: tx.v, r: tx.r, s: tx.s }; document.getElementById("outputarea").value = JSON.stringify(rawTx, null, " "); } catch (error) { document.getElementById("outputarea").value = error.message; } }
Could anyone shed some light on this? It's driving me nuts.