0

I have a Solidity contract using Oraclize. I use it to generate a random number between 0-100.

My problem is that I get a string in the result response and would like to compare with a uint.

As soon as I try to add this line of code to convert the result to a uint, the __callback function never gets executed as it expend too much gas.

playerDieResult[myid] = parseInt(result);

If I remove this line, my __callback function gets executed and I see the result stored in a memory variable as a string correctly.

My problem is that I don't have a way to compare that randomly generated number with another number.

victor
  • 1
  • Hello and welcome :) they're no native way of converting an string to an uint in solidity but with custom code you can do about anything. Maybe this will work for you? https://ethereum.stackexchange.com/questions/10932/how-to-convert-string-to-int – Foxxxey Oct 03 '21 at 14:15
  • Thank you Foxxxey. This is the method I'm following :) Was wondering if there was a more efficient way to do it but haven't been able to find any. – victor Oct 03 '21 at 15:59
  • Are you sure parseInt works correctly? My guess is that it has a bug that causes the failure. – Ismael Oct 03 '21 at 21:08

0 Answers0