web3p / web3.php

A php interface for interacting with the Ethereum blockchain and ecosystem. Native ABI parsing and smart contract interactions.
MIT License
1.17k stars 550 forks source link

Call to a member function toHex() #282

Open mdeprezzo opened 2 years ago

mdeprezzo commented 2 years ago

Hi all guys, i notice that if i try to call toHex on float number, example from coordinates from map, toBn return an array like this:

                 return [
                    new BigNumber($whole),
                    new BigNumber($fraction),
                    strlen($comps[1]),
                    isset($negative1) ? $negative1 : false
                ];

so in Utils.php line 93, the next call $bn->toHex() throw an error. So how can handle this?

iwillrickyou commented 2 years ago

I also encountered the same problem. You can take a look at the “toHex” method of the “Utils” file in the “src” directory. The is_numeric function here. If you pass a string but a numeric string, it will still be processed as text. I changed “is_numeric($value)” to “is_numeric($value) and gettype($value) != ’string‘” solved this problem, hope it can help you.