string(9) " /> string(9) " /> string(9) "/>

How convert ByteArray string to NEO address in PHP?

94 Views Asked by At

I analyze transactions with the InvocationTransaction type using the getplicationlog and get a data array in response

array(2) {
    ["type"]=> string(9) "ByteArray"
    ["value"]=> string(40) "0631901fb121f633fa496d3689649a06628f63c8"
}

Help me, how to convert ByteArray to an NEO address in PHP?

1

There are 1 best solutions below

0
Agnius Vasiliauskas On

I'm not fully sure, but you can try to use convBase() function submitted by user in php.net. Usage is like:

echo 
  convBase(
   "0631901fb121f633fa496d3689649a06628f63c8", // hex data 
   "0123456789ABCDEF", // hex alphabet
   "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); // base58 alphabet

Output:

61Gh7hAAzfnmUqVvE5najukwNBq

But I have some doubts that your hex data may be truncated or passed to some additional compression/encryption scheme, because typical NEO address when converted to base16 holds
25 bytes and you have only 20 bytes - so there must be something else going on