0

In contract sol file I have function definition:

function product(uint32 _prdId) public view 
returns (uint32 prdId, string prdName, address prd, uint closeTime, 
         uint promoTime,uint8 bonus, uint256 price, uint8 numberOfOptions, 
         uint256 totalSupply, uint8 status, uint32 next)

I'm calling this using:

$result[] = $schemaContract->product(new EthQ($prdId, ['abi'=>'uint32']));

And as result I'm receiving the error:

InvalidArgumentException: NOT IN RANGE:
33305383022926077062160769047565073723568839191253455377021159521291545790954752953639166213543... (967 digits) ...> (u)int256 in /home/.../public_html/test/ethereum-php-master/src/DataType/EthQ.php:153 Stack trace: 
#0 /home/.../public_html/test/ethereum-php-master/src/DataType/EthQ.php(100): Ethereum\DataType\EthQ->getAbiFromNumber(Object(Math_BigInteger)) 
#1 /home/.../public_html/test/ethereum-php-master/src/DataType/EthDataType.php(112): Ethereum\DataType\EthQ->validate('0x0000000000000...', Array) 
#2 /home/.../public_html/test/ethereum-php-master/src/DataType/EthD.php(138): Ethereum\DataType\EthDataType->setValue('0x0000000000000...', Array) 
#3 /home/.../public_html/test/ethereum-php-master/src/DataType/EthQ.php(45): Ethereum\DataType\EthD->__construct('0x0000000000000...', Array) 
#4 /home/.../public_html/test/ethereum-php-master/src/DataType/EthD.php(199): Ethereum\DataType\EthQ->__construct('0x0000000000000...', Array) 
#5 /home/.../public_html/test/ethereum-php-master/src/SmartContract.php(92): Ethereum\DataType\EthD->convertByAbi('uint32') 
#6 /home/.../public_html/test/ethereum-php-master/testcontract.php(63): Ethereum\SmartContract->__call('product', Array) 
#7 {main}Unable to connect.

I have no idea how to receive outbound parameters. I think I should also use abi (the same as for sending parameters) for decoding this string of numbers but don't know how and if it is good path.

Thanks for any ideas, Best regards, TB

0

The library you are using Ethereum-PHP from digitaldonkey does not support multiple values in return yet (as the developer said https://github.com/digitaldonkey/ethereum-php/issues/22 ).

So the workaround that I found are:

First solution (dirty solution): make several getters in your smart contract, one for each field. This solution can be slow if you have to retrieve a lot of data. For example in your case:

function getProductName(uint32 _prdId) public view returns (string prdName) { ... }

function getProductAddress(uint32 _prdId) public view returns (address prd) { ... }

...

Second solution: make a script with python using Web3 (for python), compile down that script into executable and call it from PHP using exec.

  • Thank you for answer. The author mentioned that library doesn't support uint [] outbound parameter. Not the multiple outbound parameters from function: function getProductById(uint id) public view returns ( uint, string, bytes32, uint, uint, uint[], <-----"this one" bool ) { so maybe it is possible to get values – Tom B Apr 27 '18 at 10:49
  • You are right. After that error I encountered other issues so I went for alternative solutions. – Dan Apr 27 '18 at 11:16
  • 1
    Working on it .... – digitaldonkey Jun 14 '18 at 10:21
  • 1
    Fixed Ethereum-PHP library. – digitaldonkey Aug 9 '18 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.