<aside> 📜 TABLE OF CONTENTS
1. 📘 Introduction to XRP Ledger
3. 💻 Interacting with XRP Ledger
4. 🏗️ Building dApps on XRPL with React
5. 🔗 EVM Sidechain Integration for XRPL
</aside>
Developing decentralized applications (dApps) on the XRP Ledger requires a thoughtful architectural approach that leverages the strengths of both blockchain technology and traditional web development.
💡 XRPL dApps typically follow a client-server model, with the XRPL serving as a decentralized backend database and transaction processor.
The architecture of an XRPL dApp should be designed to provide a seamless user experience while leveraging the security and efficiency of the XRP Ledger. This often involves creating a responsive frontend that can interact with the XRPL in real-time, backed by a robust server that handles complex operations and maintains application state.
Frontend
Backend
Clone the repository:
git clone <https://github.com/maximedgr/xrpl-quickstart-react-crossma>
Navigate to the project directory:
cd xrpl-crossmark-react-template
Install dependencies:
npm install
The Crossmark SDK is at the heart of this project. It's imported in each component:
import sdk from "@crossmarkio/sdk";
This SDK provides methods for interacting with the Crossmark wallet and the XRPL.
This component displays the user's XRPL address and network details, utilizing the Crossmark SDK for network information.
import React, { useState, useEffect } from 'react';
import { useWallet } from '../context/WalletContext';
import sdk from "@crossmarkio/sdk";
// ... (rest of the code as provided earlier)
sdk.sync?.getNetwork()
: Retrieves current network information
const currentNetwork = await sdk.sync?.getNetwork();
useEffect
hook uses the SDK to check for network updates every 5 secondsThis component handles the Crossmark wallet connection process, heavily relying on the SDK for wallet-related operations.
import React, { useState } from 'react';
import sdk from "@crossmarkio/sdk";
import { useWallet } from '../context/WalletContext';
// ... (rest of the code as provided earlier)
sdk.sync.isInstalled()
: Checks if the Crossmark wallet is installed
const installed = sdk.sync.isInstalled();
sdk.async.signInAndWait()
: Initiates the wallet connection process
let response = await sdk.async.signInAndWait();
This component showcases various XRPL interactions, all powered by the Crossmark SDK.
import React, { useState } from "react";
import sdk from "@crossmarkio/sdk";
import { useWallet } from '../context/WalletContext';
// ... (rest of the code as provided earlier)
sdk.session.user?.id
: Retrieves the current user session
let id = sdk.session.user?.id;
sdk.async.signAndWait()
: Signs a transaction
let resp = await sdk.async.signAndWait({
TransactionType: "Payment",
Account: address,
Destination: "rK8jihXBZCFWZqX95SET3CCi1WdRgZQwex",
Amount: "11000000",
});
sdk.async.submitAndWait()
: Submits a signed transaction
let resp = await sdk.async.submitAndWait(signInResponse, signTransactionTxblob);
sdk.sync.getAccountInfo()
to fetch and display account balances.sdk.sync.getAccountTransactions()
to show user's transaction history.sdk.async.signAndWait()
with different transaction types for various XRPL operations.sdk.sync.setNetwork()
for testing on different XRPL environments.By leveraging the power of the Crossmark SDK, you can create robust, feature-rich applications that interact seamlessly with the XRP Ledger.
Happy coding! 🎉