Skip to main content

XRPL network

DCENT mobile app's in-app browser injects window.xrpl as a provider. If your dapp is based on XRPL network, you can interact with DCENT wallet through the window.xrpl provider.

Injection Method

When the in-app browser loads a webpage, it must inject the following provider object

// Injected into window on page load
window.xrpl = {
getWalletInfo: function () {
// Return wallet information
},
request: function (args) {
// 1. Return XRPL account information
// 2. Switch XRPL networks
// 3. Handle transaction signing/submission
},
};

⚠️ Important Notes

  • The window.xrpl object must be injected before or immediately after the page loads.
  • The dapp can recognize the wallet only if the window.xrpl object exists.
  • It must be injected before the DOM is ready for the dapp to detect it properly.
  • Both methods (getWalletInfo and request) are required.

Interface Definition

Required Implementation Methods

interface InjectedXRPL {
getWalletInfo(): WalletInfo | Promise<WalletInfo> | string | Promise<string>;
request(args: {
method: string;
params?: unknown[] | object;
}): Promise<T>;
}

interface WalletInfo {
name: string; // Wallet name
icon: string; // Base64 image or URL
version: string; // Version (e.g., "1.0.0")
chainId: string; // Currently connected chain information: "xrpl:0" | "xrpl:1" | "xrpl:2"
}

  • Chain ID definition
Chain IDNetworkEndpoint
xrpl:0Mainnetwss://xrplcluster.com
xrpl:1Testnetwss://s.altnet.rippletest.net
xrpl:2Devnetwss://s.devnet.rippletest.net

Method Details

Request Method

  • xrpl_accounts

Returns the addresses of the currently connected wallet as an array.

request({ method: 'xrpl_accounts' })
.then((accounts) => console.log(accounts))
.catch((error) => console.error(error));
  • xrpl_switchChain

Changes the active XRPL chain by specifying a chain ID.

request({
method: 'xrpl_switchChain',
params: [{ chainId: "xrpl:1" }]
})
  • xrpl_signTransaction

Requests the wallet to sign (and optionally submit) an XRPL transaction.

request({
method: 'xrpl_signTransaction',
params: [{
// ...
}]
})
.then((xrplTxResponse) => console.log(xrplTxResponse))
.catch((error) => console.error(error));

Request Parameters for xrpl_signTransaction

interface XRPLRequestParams {
tx_json: TransactionJSON;
submit?: boolean; // Default: true
chainId: string; // "xrpl:0" | "xrpl:1" | "xrpl:2"
autofill?: boolean; // Automatically fills Fee, Sequence, etc.
}

Transaction Types

  • Payment Transaction

    Used for sending XRP or tokens.

    interface PaymentTransaction {
    TransactionType: "Payment";
    Account: string; // Sender address
    Destination: string; // Recipient address
    Amount:
    | string
    | {
    currency: string; // Token symbol
    issuer: string; // Token issuer
    value: string; // Amount
    };
    DestinationTag?: number;
    Memos?: Array<{
    Memo: {
    MemoData: string; // HEX encoded
    };
    }>;
    Fee?: string; // Auto-filled if autofill=true
    Sequence?: number; // Auto-filled if autofill=true
    LastLedgerSequence?: number;
    }
  • TrustSet Transaction

    Used for setting a trustline.

    interface TrustSetTransaction {
    TransactionType: "TrustSet";
    Account: string;
    LimitAmount: {
    currency: string; // 3-letter code (e.g., "USD")
    issuer: string; // Token issuer
    value: string; // Limit
    };
    Flags?: number; // 262144 = NoRipple
    }
  • **OfferCreate Transaction (DEX Order)

    Used for creating an order on the XRPL decentralized exchange.

    interface OfferCreateTransaction {
    TransactionType: "OfferCreate";
    Account: string;
    TakerGets: string | CurrencyAmount; // Amount you will receive
    TakerPays: string | CurrencyAmount; // Amount you will pay
    Flags?: number;
    }

Response Format

interface XRPLResponse {
tx_json: SignedTransaction;
hash?: string; // Present only when submit=true
}

interface SignedTransaction extends TransactionJSON {
SigningPubKey: string;
TxnSignature: string;
hash?: string;
date?: number;
ledger_index?: number;
}