web3p / web3.php

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

Updated Utils and BigNumberFormatter to handle hex edge cases #306

Open EGreg opened 1 year ago

EGreg commented 1 year ago

The current web3.php was mysteriously returning numbers like this: 70706864786e6862 instead of the full hex from numbers like 70706864786e6862000000000000000000000000000000000000000000000026. It happens only in the edge case where the hex has a single 'e' in it. These changes fix that scenario.

If you're wondering how we found this out, we ran into an edge case with tokenIds in our NFT Smart Contract when we started generating token IDs of the form seriesId + autoIndex. It just so happened that our seriesId had a single e in it. And PHP's is_numeric interprets numbers of the form '123e456' to be decimal representations of large numbers!