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

issue with returning string[] array - a character automatically will add to index 0 #301

Open xmrrabbitx opened 1 year ago

xmrrabbitx commented 1 year ago

it's very odd actually. my string array is: ["trump","Biden"] . so I tried to call a function to show the candidates names as below:

contract VoteContract{

      string[] public cndlist;

      constructor(string[] memory candidates){

               candidatelist = candidates;

    }

    function cnd() public view returns(string[] memory){

            return candidatelist;

    }

}

and I called it like below:

  $contract->at($address)->call("cnd", [
    'from' => $fromAccount,
    'gas' => '0x200b20'
  ], function($err,$res){

      print_r($res[0]);

  });

and this is the output:

Array ( [0] => � [1] => trump )

as you can see we have an odd character in index 0 instead of trump. I tested this contract on web3.js and works properly. also i tested on truffle console and has no problem.

any idea?