I am working with Infinitecoin (another bitcoin fork).
This is my first attempt to make a crypto currency based website.
I use PHP with JSON RPC calls. In this particular case, I want to use

$payment_tx = $ifc->sendtoaddress($account['address'], $to_send);

($ifc is the object returned by the jsonRPcclient() connection)

sendtoaddress() description states :

$amount is a real and is rounded to 8 decimal places.
So I formatted "$to_send" as precised in the description, but i'm still getting :

*Stack trace: #0 /opt/lampp/htdocs/site/process_payment.php(30): jsonRPCClient->__call('sendtoaddress', Array) #1 /opt/lampp/htdocs/site/process_payment.php(30): jsonRPCClient->sendtoaddress('iKCBBVAfacVuabG...', '10920.00000000') #2 {main} thrown in /opt/lampp/htdocs/site/jsonRPCClient.php on line 140*

I really don't understand why, because I intend to send exactly 10920 Infinitecoins to the address starting with iKCBBVAfacVuabG ... and this is formatted the right way, right?
I also want to be able to send IFC amounts up to several millions. How ?

Here's how I do the formatting :

$to_send = sprintf("%.8f", floatval($amount));  

$amount is retrieved from a database.

Please can somebody enlighten me with what am I doing wrong ?

I can offer some IFC as a thank for your help, if someone want some. :-)

1 Answer 1


you are trying to send amount as string. Sprintf returns string. You need to send amount as double (in PHP double == float).
Try this way:

$payment_tx = $ifc->sendtoaddress($account['address'], (double)$to_send);

If it doesn't work, use move at first, because sending can fail under many circumstances, while move always works.

Once you are done with that, please read my question about further problems with precision: Can I force json_encode in PHP to output 8 digits after dot for RPC?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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