Skip to content
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

i have a error when i use ethereum-php-eventlistener #63

Open
hardyzp opened this issue Jan 5, 2022 · 2 comments
Open

i have a error when i use ethereum-php-eventlistener #63

hardyzp opened this issue Jan 5, 2022 · 2 comments

Comments

@hardyzp
Copy link

hardyzp commented Jan 5, 2022

PHP Fatal error: Uncaught Exception: Graze\GuzzleHttp\JsonRpc\Exception\ClientException: Client RPC error response [uri] / [method] eth_getBlockByNumber [error code] -32602 [error message] invalid argument 0: hex number with leading zero digits

this is my temporary solution that change the DataType/EthBlockParam.php. Can you fix this problem?
public function hexVal()
{
if ($this->isTag()) {
return $this->value;
} else {
$val = intval($this->value->toString());
$val = ($val === 0) ? $val : $this->value->toHex(false);
$pattern = "/([0]*)([0-9a-f]+)/i";
$replacement = "$2";
$val = preg_replace($pattern,$replacement,$val);
// Unpaded positive Hex value.
return $this->ensureHexPrefix($val);
}
}

@hardyzp hardyzp closed this as completed Jan 5, 2022
@hardyzp hardyzp reopened this Jan 5, 2022
@knight2008
Copy link

knight2008 commented Mar 7, 2022

eth_getBlockByNumber get error.

block number: 65537
PHP Fatal error: Uncaught Graze\GuzzleHttp\JsonRpc\Exception\ClientException: Client RPC error response [uri] / [method] eth_getBlockByNumber [error code] -32602 [error message] invalid argument 0: hex number with leading zero digits in /root/vendor/graze/guzzle-jsonrpc/src/Exception/RequestException.php:52

+++ digitaldonkey/ethereum-php/src/DataType/EthBlockParam.php 2022-03-07 21:34:03.341242711 +0800
@@ -105,6 +105,7 @@
         } else {
             $val = intval($this->value->toString());
-            $val = ($val === 0) ? $val : $this->value->toHex(false);
+            $val = ($val === 0) ? $val : ltrim($this->value->toHex(false), 0);

 
             // Unpaded positive Hex value.
             return $this->ensureHexPrefix($val);

@vanthao03596
Copy link

same error here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants