Development

What is the XRPL testnet faucet and how to get test XRP?

Last updated:

The XRPL testnet faucet is a free service that provides test XRP for development and testing purposes. Test XRP has no real-world value but functions identically to mainnet XRP, allowing developers to safely test applications without financial risk. Understanding how to use the faucet is essential for XRPL development. **What is the Testnet Faucet?** The testnet faucet is an automated service that creates and funds new XRPL testnet accounts. When you request test XRP, the faucet generates a new wallet with a funded account containing approximately 1,000 test XRP. This amount is sufficient for extensive testing including transaction fees, DEX trading, token issuance, NFT creation, and reserve requirements for objects like trust lines and offers. **Official Faucet Endpoints** The primary faucet is operated by Ripple at: https://faucet.altnet.rippletest.net/accounts This web interface allows you to generate test wallets through a simple browser interface. Alternative methods include programmatic access through SDK libraries and API endpoints for automated testing. **Using the Faucet via Web Interface** Visit the faucet website and click the "Generate credentials" button. The faucet will instantly create a new account and display the address (public), secret (private key), and balance (usually 1,000 test XRP). Save these credentials securely as they won't be shown again. Never use testnet credentials on mainnet or store real secrets the same way. **Using the Faucet Programmatically (JavaScript)** The xrpl.js library includes built-in faucet integration: ```javascript const xrpl = require('xrpl'); async function getTestWallet() { // Connect to testnet const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233'); await client.connect(); console.log('Requesting test wallet from faucet...'); // Request wallet from faucet (this may take 10-30 seconds) const fundResult = await client.fundWallet(); const wallet = fundResult.wallet; const balance = fundResult.balance; console.log('Test wallet created and funded!'); console.log('Address:', wallet.address); console.log('Secret:', wallet.seed); console.log('Balance:', balance, 'XRP'); // Verify account exists const accountInfo = await client.request({ command: 'account_info', account: wallet.address, ledger_index: 'validated' }); const drops = accountInfo.result.account_data.Balance; const xrp = xrpl.dropsToXrp(drops); console.log('Verified balance:', xrp, 'XRP'); await client.disconnect(); return wallet; } getTestWallet(); ``` Funding an existing wallet: ```javascript const xrpl = require('xrpl'); async function fundExistingWallet() { const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233'); await client.connect(); // Generate a wallet (not yet funded) const wallet = xrpl.Wallet.generate(); console.log('Generated address:', wallet.address); // Fund the specific wallet const fundResult = await client.fundWallet(wallet); console.log('Funded with:', fundResult.balance, 'XRP'); await client.disconnect(); return wallet; } fundExistingWallet(); ``` **Using the Faucet with Python (xrpl-py)** ```python from xrpl.clients import JsonRpcClient from xrpl.wallet import generate_faucet_wallet # Connect to testnet client = JsonRpcClient("https://s.altnet.rippletest.net:51234") print("Requesting test wallet from faucet...") # Generate and fund wallet from faucet test_wallet = generate_faucet_wallet(client, debug=True) print(f"Test wallet created!") print(f"Address: {test_wallet.address}") print(f"Seed: {test_wallet.seed}") # Verify balance from xrpl.models.requests import AccountInfo from xrpl.utils import drops_to_xrp account_info = client.request(AccountInfo( account=test_wallet.address, ledger_index="validated" )) balance = drops_to_xrp(account_info.result["account_data"]["Balance"]) print(f"Balance: {balance} XRP") ``` **Direct API Access** You can also call the faucet API directly: ```javascript const axios = require('axios'); async function getFaucetXRP() { try { const response = await axios.post('https://faucet.altnet.rippletest.net/accounts', { // Optional: specify destination address // If not provided, faucet creates new account }); const account = response.data.account; console.log('Address:', account.address); console.log('Secret:', account.secret); console.log('Balance:', account.balance); return account; } catch (error) { console.error('Faucet error:', error.message); } } getFaucetXRP(); ``` **Faucet Limitations and Best Practices** The faucet has rate limiting to prevent abuse. You may encounter delays or temporary blocks if requesting too frequently. Typical limits are approximately 1 request per IP per minute and maximum 10 requests per IP per hour. If rate limited, wait a few minutes before trying again or use a different network connection. Test XRP has no real value and cannot be exchanged for mainnet XRP. The testnet is periodically reset, which erases all accounts and history. Don't rely on testnet data for production systems or long-term storage. **Creating Multiple Test Accounts** For testing multi-account scenarios: ```javascript const xrpl = require('xrpl'); async function createMultipleTestAccounts(count) { const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233'); await client.connect(); const wallets = []; for (let i = 0; i < count; i++) { console.log(`Creating test account ${i + 1}/${count}...`); try { const result = await client.fundWallet(); wallets.push(result.wallet); console.log(`Created: ${result.wallet.address}`); // Wait between requests to avoid rate limiting await new Promise(resolve => setTimeout(resolve, 2000)); } catch (error) { console.error(`Failed to create account ${i + 1}:`, error.message); } } await client.disconnect(); return wallets; } // Create 3 test accounts createMultipleTestAccounts(3); ``` **Handling Faucet Failures** Implement retry logic for robust testing: ```javascript async function getFaucetWithRetry(maxAttempts = 3) { const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233'); await client.connect(); for (let attempt = 1; attempt <= maxAttempts; attempt++) { try { console.log(`Attempt ${attempt}/${maxAttempts}...`); const result = await client.fundWallet(); console.log('Success!'); await client.disconnect(); return result.wallet; } catch (error) { console.error(`Attempt ${attempt} failed:`, error.message); if (attempt < maxAttempts) { const delay = attempt * 5000; // Exponential backoff console.log(`Waiting ${delay/1000}s before retry...`); await new Promise(resolve => setTimeout(resolve, delay)); } } } await client.disconnect(); throw new Error('Failed to get faucet wallet after all attempts'); } getFaucetWithRetry(); ``` **Alternative Faucets** Community-run faucets may exist but use official Ripple faucets for reliability. Some wallets like XUMM have built-in testnet faucet integration. **Testnet vs Devnet Faucets** Devnet also has a faucet for experimental features. Connect to wss://s.devnet.rippletest.net:51233 and use the same fundWallet() method. **Best Practices for Test XRP Management** Store testnet credentials separately from mainnet. Clearly label test wallets in your code and documentation. Use environment variables to distinguish networks. Never send real XRP to testnet addresses. Regularly request fresh test accounts for clean testing environments. **Common Errors** Timeout errors: The faucet may be slow during high usage. Rate limit exceeded: Wait before requesting again. Network connection issues: Verify testnet endpoint connectivity. Invalid response: Check if testnet is undergoing maintenance. The testnet faucet is an essential tool for XRPL development, providing free test XRP for unlimited experimentation without financial risk.
Was this helpful?

Related Questions

Go Deeper

Expand your knowledge with these related lessons

Testnet and Devnet Operations

50 minadvanced

XRPL Accounts - Theory and Practice

50 minintermediate

Testing XRPL Applications

50 minintermediate

Have more questions?

Browse our complete FAQ or contact support.