-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction(EIP1559Transaction) hash doesn't match the real one from server #41
Labels
bug
Something isn't working
Comments
Code appended to previous comment: require "lib.php";
use Web3p\EthereumTx\Transaction;
use Web3p\EthereumTx\EIP1559Transaction;
$res = rpcInvoke("eth_getTransactionCount",["0x1c82bf96916743bce021d60d24095c2b1a888687", 'pending']);
// unset($res['transactions']);
$transaction = new Transaction([
'nonce' => $res ,
'from' => '0x1c82bf96916743bce021d60d24095c2b1a888687',
'to' => '0xcDA0D6adCD0f1CCeA6795F9b1F23a27ae643FE7C',
'gas' => '0x5208',
'gasPrice' => '0x' . dechex(70 * 10**9),
'chainId' => 3,
'value' => '0x' . dechex(0.01 * 10**18),
'data' => ''
]);
$transaction = new EIP1559Transaction([
'nonce' => $res,
'from' => '0x1c82bf96916743bce021d60d24095c2b1a888687',
'to' => '0xcDA0D6adCD0f1CCeA6795F9b1F23a27ae643FE7C',
'maxPriorityFeePerGas' => '0x' . dechex(70 * 10**9),
'maxFeePerGas' => '0x' . dechex(100 * 10**9),
'gas' => '0x5208',
'value' => '0x' . dechex(0.01 * 10**18),
'chainId' => 3,
'accessList' => [],
'data' => ''
]);
echo "before sign: ";
echo '0x' . $transaction->hash() . PHP_EOL;
$signed = $transaction->sign("0x1a56ee986126833163dbc7335b74ec8d1b03c1f9f2ff4acb5d438a012a967d76");
$transaction = new EIP1559Transaction("0x$signed");
echo "after sign: ";
echo '0x' . $transaction->hash() . PHP_EOL;
$res = rpcInvoke("eth_sendRawTransaction",["0x$signed"]);
echo "Server response result: " ;
var_dump($res); Result:
|
@sajadkhosravani1 Thanks, you're right! I didn't hash the signature together. I've push fix in PR. |
sc0Vu
added a commit
that referenced
this issue
Dec 28, 2021
Fix #41: hash() didn't return transaction hash
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello and thanks for developing this library.
I noticed that an EIP1559Transaction unlike legacy Transaction objects has the same hash before and after signing the transaction.
For legacy transactions I recreate the transaction object by parsing the signed raw transaction using the "Transaction(string $raw)" constructor and then I call hash() function so I get the final hash of the transaction.
But for EIP1559Transaction there's no way to get final transaction hash. In this case calling signed and unsigned transactions hash() function have the same response and it's of course not the same as what server computes and returns as response of "eth_sendRawTransaction".
With best regards.
The text was updated successfully, but these errors were encountered: