Mine2XRP is an app to automatically convert rewards obtained from mining XMR to XRP. Many people, including myself, use their spare CPU and/or GPU power to mine the cryptocurrency XMR. XMR is the preferred cryptocurrency to mine for many people because it employs a proof-of-work algorithm called RandomX, which is ASIC-resistant, making it accessible to miners with regular computers (as opposed to only those with huge data centers that have a ton of computing power, or with specialized mining hardware). XMR also has a relatively low difficulty level of mining compared to other cryptocurrencies, which is another reason why many people prefer it to mining BTC or ETH. Unfortunately XRP cannot be mined.
The other thing that has recently occurred is a bull run for XRP, which many people believe is only just getting started due to many factors such 1) the SEC case against Ripple (the company that makes XRP) rapidly coming to an official end, and 2) the new administration's crypto policies, particularly for those made by US-based companies, which Ripple is. This has led to many people becoming interested in "stacking" XRP. Stacking is a process that typically refers to repeatedly purchasing small amounts of crypto on a regular basis to slowly and gradually accumulate it. It is akin to saving coins in a piggybank, except that the value of those coins may fluctuate (of course we hope that their value increases).
I began personally using a script to automatically swap my mined XMR for XRP a couple months ago and since then have had many people ask me for it, so I've decided to release it publicly. You should use a separate XMR wallet for mining. Most mining pools have a default minimum pay out amount of 0.3 or 0.03 XMR, but on some pools such as MoneroOcean, the pay out amount can be set as low at 0.001 XMR. By default, the script will check to make sure your XMR wallet contains at least 0.03 XMR, then will exchange 99% of the balance to XRP (1% is reserved for transfer fee). I run it once a day automatically by putting it in my crontab, but you can use any interval that you choose (more on this later). It requires that you have monero-wallet-rpc running - you can find instructions for that here. It also requires you to have an API key for the CEX swap provider StealthEX. I chose this swap provider because it allows extremely small amounts of XMR to be exchanged for XRP, making it ideal for stacking. Simply sign up for a free account and visit their settings page to find your API key. Additionally, your installation of PHP must have the cURL and bcmath extensions enabled.
<?php
// StealthEX API Configuration
$apiKey = 'YOUR_API_KEY'; // Get from stealthEX.io account
$apiUrl = 'https://api.stealthex.io/api/v2/exchange';
// Exchange parameters
function create_exchange($xmr_amount,$xrp_addr)
{
$params = [
'from' => 'xmr',
'to' => 'xrp',
'amount' => "$xmr_amount", // Amount of XMR to exchange
'address' => $xrp_addr // Destination XRP address
];
// Create cURL request
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $apiUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-KEY: ' . $apiKey
],
CURLOPT_POSTFIELDS => json_encode($params)
]);
// Execute and handle response
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
die("cURL Error: " . $error);
}
$data = json_decode($response, true);
if (isset($data['error'])) {
die("API Error: " . $data['error']);
}
// Output exchange details
echo "Exchange created successfully!\n";
echo "Exchange ID: " . $data['id'] . "\n";
echo "Status: " . $data['status'] . "\n";
echo "Send XMR to: " . $data['deposit_address'] . "\n";
echo "Minimum amount: " . $data['deposit_min'] . " XMR\n";
echo "XRP to receive: " . $data['received_amount'] . " XRP\n";
echo "Valid until: " . date('Y-m-d H:i:s', $data['valid_until']) . "\n";
return $data['deposit_address']; // return the XMR deposit address
}
?>
<?php
require_once("stealthex_create_xmr_to_xrp_exchange.php");
// Monero-Wallet-RPC configuration
$rpcUrl = "http://127.0.0.1:18083/json_rpc";
$rpcUser = "your_rpc_username";
$rpcPassword = "your_rpc_password";
$xrpAddress = "";
// Set the above variables
// Function to send JSON-RPC requests
function sendRpcRequest($url, $user, $password, $method, $params = []) {
$request = json_encode([
'jsonrpc' => '2.0',
'id' => '0',
'method' => $method,
'params' => $params
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_USERPWD => "$user:$password",
CURLOPT_POSTFIELDS => $request
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true, 512, JSON_BIGINT_AS_STRING);
}
try {
// Get wallet balance
$balanceResponse = sendRpcRequest($rpcUrl, $rpcUser, $rpcPassword, 'get_balance');
if (isset($balanceResponse['error'])) {
throw new Exception("RPC Error: " . $balanceResponse['error']['message']);
}
$unlockedBalance = $balanceResponse['result']['unlocked_balance'];
$threshold = bcmul('0.03', '1000000000000', 0); // 0.03 XMR in atomic units
if (bccomp($unlockedBalance, $threshold) >= 0) {
// Calculate 99% of the unlocked balance
$sendAmount = bcdiv(bcmul($unlockedBalance, '99'), '100', 0);
$xmrDestination = create_exchange($sendAmount,$xrpAddress); // create the exchange
// Prepare transfer parameters
$transferParams = [
'destinations' => [[
'amount' => (int)$sendAmount,
'address' => $xmrDestination
]],
'priority' => 1,
'mixin' => 10,
'unlock_time' => 0
];
// Send transaction
$transferResponse = sendRpcRequest($rpcUrl, $rpcUser, $rpcPassword, 'transfer', $transferParams);
if (isset($transferResponse['error'])) {
throw new Exception("Transfer Error: " . $transferResponse['error']['message']);
}
echo "Transaction successful! TXID: " . $transferResponse['result']['tx_hash'];
} else {
echo "Balance (". $unlockedBalance / 1e12 ." XMR) is below 0.03 XMR threshold. No transaction sent.";
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
Exchange created successfully!
Exchange ID: 123456789
Status: waiting
Send XMR to: 8ABCDEF...123456
Minimum amount: 0.03 XMR
XRP to receive: 12.34 XRP
Valid until: 2025-01-31 23:59:59
Transaction successful! TXID: f73359...123456
0 0 * * * php /path/to/check_balance_initiate_exchange.php
cat /var/log/syslog | grep cron