The task is trivial for someone who is knowledgeable about how Ripple works (or, more time consuming but easy to learn for someone who doesn't), but would take a long time for me to figure out. For this task, the developer will hardcode values like the private key at the top of the file. Once I have the working code for the Ripple client, then I can add the database calls to replace those constants by myself.
The code should be able to call a reference Ripple client. Ripple hosts a public node at s1.ripple.com that you can use for testing. This client uses simple HTTP REST calls and, therefore, should not require the inclusion of complex dependencies like php-ripple-rest (which doesn't work).
Here is the PHP template:
Code: Select all
<?php
//require_once(.....); //Database stuff
class RippleDaemon
{
//other variables we will add
private $CONST_PRIVATE_KEY = "xxx";
private $CONST_PUBLIC_KEY = "xxx";
private $HOST = "xxx";
private $PORT = "xxx";
//Other constants go here...
public function __construct($abbreviation)
{
//We will add other code here below whatever initialization code you require, if any
}
public function getBalance() {
//Returns the balance in XRP of this wallet that can be spent right now; use bc_math instead of floats for all intermediate calculations
}
public function send($toaddress,$qty)
{
//Send XRP to one address. qty is the number of XRP, provided as a String. Use bc_math instead of floats for all calculations
//Returns the transaction fee incurred by the transaction, using bc_math instead of floats for any intermediate calculations
//Throws an exception with the reason for the failure if the transfer did not succeed
}
public function sendmany($sendArray) {
//Atomically sends XRP to many addresses:
//$sendArray = Array($toaddress => $qty, $toaddress2 => $qty2, .....);
//Returns an array with the following data: Array('fee' => [the transaction fee], 'txid' => [the transaction id])
//Throws an exception with the reason for the failure if the transfer did not succeed
}
}
?>