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.xrplobject must be injected before or immediately after the page loads. - The dapp can recognize the wallet only if the
window.xrplobject exists. - It must be injected before the DOM is ready for the dapp to detect it properly.
- Both methods (
getWalletInfoandrequest) 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 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.
}
Transaction Types
-
Payment Transaction
Used for sending XRP or tokens.
interface PaymentTransaction {TransactionType: "Payment";Account: string; // Sender addressDestination: string; // Recipient addressAmount:| string| {currency: string; // Token symbolissuer: string; // Token issuervalue: string; // Amount};DestinationTag?: number;Memos?: Array<{Memo: {MemoData: string; // HEX encoded};}>;Fee?: string; // Auto-filled if autofill=trueSequence?: number; // Auto-filled if autofill=trueLastLedgerSequence?: 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 issuervalue: 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 receiveTakerPays: string | CurrencyAmount; // Amount you will payFlags?: 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;
}