XRPL network

How to integrate with D'CENT wallet for dapps on XRPL network.

D'CENT mobile app's in-app browser injects window.xrpl as providers. If your dapp is based on XRPL network, you can interact with D'CENT wallet through window.xrpl providers.

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) {
    // [IoTrust]
    // 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 Doppler WebApp can recognize the wallet only if the window.xrpl object exists.

  • It must be injected before the DOM is ready for Doppler 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>;  // IoTrust
}

interface WalletInfo {
  name: string; // Wallet name
  icon: string; // Base64 image or URL
  version: string; // Version (e.g., "1.0.0") --> Interface version?
  // address: string;  // Removed by [IoTrust]
  chainId: string; // Currently connected chain information [IoTrust] "xrpl:0" | "xrpl:1" | "xrpl:2"
}
  • Chain ID definition

Chain ID
Network
Endpoint

xrpl:0

Mainnet

wss://xrplcluster.com

xrpl:1

Testnet

wss://s.altnet.rippletest.net

xrpl:2

Devnet

wss://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.
}

Transction 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;
}

Last updated

Was this helpful?