XRPL API
Interact with the XRP Ledger for onramp/offramp operations with issued currencies like USDC. Support for fiat-to-crypto conversion via FX rates and XRPL transaction management.
Initialize Onramp
Initialize XRPL Onramp
Convert fiat currency to USDC on XRPL. Supports direct USDC amount or fiat conversion via FX rates. Creates trustline automatically if needed and sends USDC from issuer to BRDZ wallet.
Parameters
currency_codestringTarget currency code (default: USDC)
amountnumberDirect USDC amount (alternative to fiat conversion)
fiat_currencystringSource fiat currency: IDR, SGD, USD, AUD, INR, VND
fiat_amountnumberFiat amount to convert to USDC
Request Body
{
"currency_code": "USDC",
"fiat_currency": "IDR",
"fiat_amount": 1500000
}Response
{
"message": "Onramp initiated",
"data": {
"xrpl_tx": {
"id": 1,
"user_id": 123,
"tx_type": "ONRAMP",
"tx_hash": "F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345",
"source_address": "r9wxh8hwJcaQnC4ypWqZqpoYY4MS9Shmos",
"destination_address": "rUrLo6FbWL4AtnZC1i6buB55VuAXZKVLNh",
"currency_code": "USDC",
"amount": "100.500000",
"status": "tesSUCCESS",
"raw_response": "{\"txResult\":{\"hash\":\"F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345\",\"meta\":{\"TransactionResult\":\"tesSUCCESS\"}},\"fxContext\":{\"route\":\"IDR → USDC → USDC\",\"fiat_currency\":\"IDR\",\"fiat_amount\":1500000,\"usdc_amount\":100.5}}",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
"fx": {
"route": "IDR → USDC → USDC",
"usdcIntermediate": 100.5,
"result": 100.5
}
}
}{
"error": "Provide either amount (USDC) OR fiat_currency + fiat_amount"
}{
"error": "Issuer not found for given currency_code"
}curl -X POST https://api.brdz.link/api/xrpl/onramp/init \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"currency_code": "USDC",
"fiat_currency": "IDR",
"fiat_amount": 1500000
}'Get Onramp Status
Get Onramp Status
Check the status of an XRPL onramp transaction using the transaction ID.
Parameters
txidstringrequiredXRPL transaction hash or onramp ID (path parameter)
Response
{
"txid": "F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345",
"status": "validated"
}{
"error": "txid is required"
}curl -X GET https://api.brdz.link/api/xrpl/onramp/status/F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345 \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "x-api-key: YOUR_API_KEY"Initialize Offramp
Initialize XRPL Offramp
Convert USDC to fiat or send USDC to another XRPL address. Supports both on-chain transfers and fiat payout to BRDZ wallet or bank.
Parameters
currency_codestringSource currency code (default: USDC)
amountnumberUSDC amount (alternative to usdc_amount)
usdc_amountnumberUSDC amount to convert or send
destination_addressstringXRPL address for on-chain transfer
target_fiatstringTarget fiat currency: IDR, SGD, USD, AUD, INR, VND
payout_typestringPayout method: BRDZ_WALLET or BANK (default: BRDZ_WALLET)
destination_bankstringBank details for BANK payout type
receiver_user_idnumberUser ID for BRDZ_WALLET payout
receiver_currencystringCurrency for receiver wallet
wallet_idnumberWallet ID for BRDZ_WALLET payout
Request Body
{
"currency_code": "USDC",
"usdc_amount": 100.5,
"target_fiat": "IDR",
"payout_type": "BRDZ_WALLET",
"wallet_id": 456
}Response
{
"message": "Offramp (fiat payout) initiated",
"data": {
"xrpl_tx": {
"id": 2,
"user_id": 123,
"tx_type": "OFFRAMP_FIAT",
"tx_hash": null,
"source_address": "rUrLo6FbWL4AtnZC1i6buB55VuAXZKVLNh",
"destination_address": "BRDZ_WALLET",
"currency_code": "USDC",
"amount": "100.500000",
"status": "PENDING",
"raw_response": "{\"fx\":{\"route\":\"USDC → USDC → IDR\",\"usdcIntermediate\":100.5,\"result\":1500000},\"payout_type\":\"BRDZ_WALLET\",\"destination_bank\":null}",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
"payout": {
"target_fiat": "IDR",
"fiat_amount": 1500000,
"payout_type": "BRDZ_WALLET",
"destination_bank": null
}
}
}{
"error": "For fiat payout, provide usdc_amount and target_fiat"
}curl -X POST https://api.brdz.link/api/xrpl/offramp/init \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"currency_code": "USDC",
"usdc_amount": 100.5,
"target_fiat": "IDR",
"payout_type": "BRDZ_WALLET",
"wallet_id": 456
}'Get Offramp Status
Get Offramp Status
Check the status of an XRPL offramp transaction using the transaction ID.
Parameters
txidstringrequiredXRPL transaction hash or offramp ID (path parameter)
Response
{
"txid": "F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345",
"status": "validated"
}{
"error": "txid is required"
}curl -X GET https://api.brdz.link/api/xrpl/offramp/status/F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345 \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "x-api-key: YOUR_API_KEY"Get XRPL Transaction History
Get XRPL Transaction History
Retrieve user's XRPL transaction history including onramp and offramp operations.
Response
{
"message": "XRPL transaction history fetched successfully",
"count": 2,
"history": [
{
"id": 2,
"tx_type": "OFFRAMP_FIAT",
"tx_hash": null,
"source_address": "rUrLo6FbWL4AtnZC1i6buB55VuAXZKVLNh",
"destination_address": "BRDZ_WALLET",
"currency_code": "USDC",
"amount": "100.500000",
"status": "PENDING",
"raw_response": "{\"fx\":{\"route\":\"USDC → USDC → IDR\",\"usdcIntermediate\":100.5,\"result\":1500000},\"payout_type\":\"BRDZ_WALLET\",\"destination_bank\":null}",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
{
"id": 1,
"tx_type": "ONRAMP",
"tx_hash": "F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345",
"source_address": "r9wxh8hwJcaQnC4ypWqZqpoYY4MS9Shmos",
"destination_address": "rUrLo6FbWL4AtnZC1i6buB55VuAXZKVLNh",
"currency_code": "USDC",
"amount": "100.500000",
"status": "tesSUCCESS",
"raw_response": "{\"txResult\":{\"hash\":\"F3E6D7C8B9A0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345\",\"meta\":{\"TransactionResult\":\"tesSUCCESS\"}},\"fxContext\":{\"route\":\"IDR → USDC → USDC\",\"fiat_currency\":\"IDR\",\"fiat_amount\":1500000,\"usdc_amount\":100.5}}",
"created_at": "2024-01-15T10:25:00Z",
"updated_at": "2024-01-15T10:25:00Z"
}
]
}curl -X GET https://api.brdz.link/api/xrpl/history \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "x-api-key: YOUR_API_KEY"XRPL Network Configuration
Testnet Settings
| Setting | Value |
|---|---|
| Network | wss://s.altnet.rippletest.net:51233 |
| RPC | https://s.altnet.rippletest.net:51234 |
| Issuer Address | r9wxh8hwJcaQnC4ypWqZqpoYY4MS9Shmos |
| BRDZ Address | rUrLo6FbWL4AtnZC1i6buB55VuAXZKVLNh |
Supported Currencies
Based on fxRateService.js SUPPORTED_CURRENCIES:
| Currency | Code | Country |
|---|---|---|
| Indonesian Rupiah | IDR | Indonesia |
| Singapore Dollar | SGD | Singapore |
| US Dollar | USD | United States |
| Australian Dollar | AUD | Australia |
| Indian Rupee | INR | India |
| USD Coin | USDC | Stablecoin |
| Vietnamese Dong | VND | Vietnam |
Transaction Types
Based on xrplTransactionModel.js:
| Type | Description |
|---|---|
| ONRAMP | Fiat to USDC conversion |
| OFFRAMP | USDC to another XRPL address |
| OFFRAMP_FIAT | USDC to fiat conversion |
Transaction Status Values
| Status | Description |
|---|---|
| PENDING | Transaction initiated |
| tesSUCCESS | XRPL transaction successful |
| SUCCESS_RECEIVED | Mock mode success status |
FX Rate Service
Conversion Process
- Live Rates: Fetched from Coinbase API
- Route: All conversions go through USDC (Fiat → USDC → Fiat)
- Precision: USDC amounts rounded to 6 decimals
- Minimum: 0.000001 USDC minimum amount
Example Conversion
// IDR to USD via USDC
// 1,500,000 IDR → 100.5 USDC → 100.5 USD
{
route: "IDR → USDC → USD",
usdcIntermediate: 100.5,
result: 100.5
}
Database Schema
xrpl_transactions Table
- id (serial primary key)
- user_id (integer)
- tx_type (varchar) - ONRAMP, OFFRAMP, OFFRAMP_FIAT
- tx_hash (varchar) - XRPL transaction hash
- source_address (varchar) - XRPL source address
- destination_address (varchar) - XRPL destination address
- currency_code (varchar) - USDC
- amount (decimal) - Transaction amount
- status (varchar) - PENDING, tesSUCCESS, etc.
- raw_response (text) - JSON response data
- created_at (timestamp)
- updated_at (timestamp)
xrpl_issuers Table
- id (serial primary key)
- issuer_address (varchar) - XRPL issuer address
- currency_code (varchar) - Currency code (USDC)
- created_at (timestamp)
- updated_at (timestamp)
xrpl_trustlines Table
- id (serial primary key)
- user_id (integer)
- xrpl_address (varchar) - User's XRPL address
- currency_code (varchar) - Currency code (USDC)
- issuer_id (integer) - Reference to xrpl_issuers
- trustline_status (varchar) - PENDING, ACTIVE
- created_at (timestamp)
- updated_at (timestamp)
All fiat conversions go through USDC as intermediate currency. Rates are fetched live from Coinbase API.
Current implementation uses XRPL Testnet. All addresses and transactions are for testing purposes only.
When MOCK_MODE=true, transactions show SUCCESS_RECEIVED status for testing.