web3p / ethereum-tx

Ethereum transaction library in PHP.
https://www.web3p.xyz/ethereumtx.html
MIT License
183 stars 63 forks source link

sign function does not work correctly #27

Closed sarlongda closed 3 years ago

sarlongda commented 4 years ago

I used this library to test sendRawTransaction. But I am getting this error - "transaction could not be decoded: could not recover from address: could not recover secp256k1 key: calculated Rx is larger than curve P" when I send signed transaction

f8ed01850861c46800827d0094d02a1ed82FA5091A5639dc507f2F6130E5Bc61Be80b8886139303539636262303030303030303030303030303030303030303030303030326130383566313530646638333639306165353232653933616136336530363466646166303439303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030343824a0bb8e9387f97cca50d0193bbbc57ebd1071156ed539e89beeeb73e104f8d01df0a07ada6542d9d29dc0c238ce54df923a35995f830f476b2b60167b72a6bbdf793d

This is my signed transaction by using transaction->sign() function In my view, this result is wrong.

$eth->getTransactionCount($fromAccount, 'pending', function($err, $nonce) use ($eth, $fromAccount, $data) { $rawTransaction = new Web3Transaction([ "from" => $fromAccount, "gasPrice" => '0x861c46800', "gasLimit" => '0x7d00', "to" => env('CONTRACT_ADDRESS'), "value" => "0x0", "data" => $data, "chainID" => 1, "nonce" => sprintf('0x%s', dechex(intval($nonce->toString())+1)) ]); $signedTx = $rawTransaction->sign(env('COMPANY_PRIVATE_KEY')); Log::debug($signedTx); $eth->sendRawTransaction(sprintf('0x%s', $signedTx), function ($err, $tx) { if ($err !== null) { Log::debug("Error: " . $err->getMessage()); } Log::debug('TX: ' . $tx); }); });

This is my code to get the result. Anyone can help me with this issue?

sc0Vu commented 4 years ago

@sarlongda

I'm not sure whether the issue is, but it looks like some number was too big so the X is out of limit.

Did you use 32 bytes of private key (do not paste key here)?