API-Endpoints
Application Journey (XRPL)
Transaction Flow

Transaction Flow

There are four main steps in sending transactions.

Obtain the user token

Obtain the user token by logging with integrated social providers. This token can be a JWT token or another type of token, depending on the configuration of the social authentication provider you used. For social providers like Google and Firebase , user token is the ID Token (JWT) which must include the email as a claim. For Discord, the user token is the Discord access token.

Create the transaction

Create a transaction object using the xrpl (opens in a new tab) library.

The xrpl library is a JavaScript library for interacting with the XRP Ledger. It provides access to various functionalities needed to interact with the XRP Ledger, such as creating clients, managing wallets, and performing transactions.

    import * as XRPL from 'xrpl';
 
    const XRPL_SERVER_URL = "wss://xrplcluster.com"
 
    const XRPLClient = new XRPL.Client(XRPL_SERVER_URL);
    await XRPLClient.connect();
 
    const tx = ({
          TransactionType: 'Payment',
          Account: xrplAddress,
          Amount: XRPL.xrpToDrops(xrpAmount),
          Destination: receiverAddress,
        })
 
    const transaction = await XRPLClient.autofill(tx);

Sign the transaction using Kaiju signTransaction API

Signing the transaction using signTransaction API

ℹ️

Each time the signTransaction API is called, a new user token must be generated. This token will have a validation period of 60 seconds and must be called within this timeframe.

    const KAIJU_AUTH_PROVIDER_ID = "65fc4fa3d948cc6313aca1200o9i8" ;
    const KAIJU_ACCESS_KEY = "vj*?pr$1_0fK$7B+p7LbCFQRKUJ=lS1q2w3" ;
    const token = "eyJhbGciOiJSUzI1NiIsImtpZCI6IjY3NGRiYmE4ZmFlZTY5YWNhZTFiYzFiZTE5MDQ1MzY3OGY0NzI4MDMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMDAzNzIwMzQyMDItY2NidmxsdTE2Z2w4NWswMjEyZmdmaHVtcmZhb3Npa3QuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiIzMDAzNzIwMzQyMDItY2NidmxsdTE2Z2w4NWswMjEyZmdmaHVtcmZhb3Npa3QuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMTI3MjU4MTQwMzY4MTAxNjI2MjEiLCJlbWFpbCI6ImFwcGthaWp1QGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoiUEVsOEZoeHpLVGxUZzVTeW9PckluZyIsIm5hbWUiOiJLYWlqdSBBcHAiLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUNnOG9jTGVIX21PWU9rM0dOOVJqZWJYWVd1WlNXMzFOcGZjOEJUQXJJOUJmeW9HcDlQR2t4ND1zOTYtYyIsImdpdmVuX25hbWUiOiJLYWlqdSIsImZhbWlseV9uYW1lIjoiQXBwIiwiaWF0IjoxNzE3NzI5MTYwLCJleHAiOjE3MTc3MzI3NjB9.bw1IH8tlekgFteySjrbO2k4UR-byiC0PywCK6mz-rcdgnQhfQITL_8GyZNJozs1K2-ldaT0SRkhrErG8WG0CD08bltqD-O5OrUrwQYJO8Rj1u5klgUB44TuF1k8MoEUQ6AmOkiDNd8fbTwl-BDtqzSPmBCEPde6nMlqgmvFDjzKgJvF5P9vMQsiCGX9YjI66tW_pAgNqZFYsdTUKxHBpGTVam7VHoGEPhfN-mZtnd55To6kgWSx_46i4dNJU75h0zfzsPVUWfyIBYOdxAaG4yAn6LjXfxWuOqHH0ZDonT2lxmoAEioru6GlMoSK4SAkF4RgYMrUWKWLzGJQgwHFXgw" ;
    const KAIJU_SAAS_WALLET_BASE_URL = "https://api.wallet.kaiju3d.com/v1"
 
    const headers = new Headers();
    headers.append ('authProviderId', KAIJU_AUTH_PROVIDER_ID);
    headers.append('accessKey', KAIJU_ACCESS_KEY);
    headers.append('Content-Type', 'application/json');
    headers.append('token', token);
 
    const body = JSON.stringify({
        email,
        blockchain: 'xrpl',
        transactionType: 'transaction',
        payload: {
          transaction: transaction,
          transactionHash: '',
        },
    });
 
    const response = await fetch(
      `${KAIJU_SAAS_WALLET_BASE_URL}/kms/signTransaction`,
      {
        method: 'POST',
        headers,
        body,
      },
    );
    const result = await response.json();
 
    const signedTransaction = response.data.signedPayload.transaction;

Submit the transaction

Submits the signed transaction to the XRP Ledger and waits for confirmation, then extracts the transaction result and hash. Returns the success status, transaction hash, and result.

    import * as XRPL from 'xrpl';
 
    const XRPL_SERVER_URL = "wss://xrplcluster.com"
 
    const XRPLClient = new XRPL.Client(XRPL_SERVER_URL);
    await XRPLClient.connect();
 
    const transactionResponse = await XRPLClient.submitAndWait(
      signedTransaction,
    );
ℹ️

For more information about this flow, please follow transferXRP (opens in a new tab) function.