Last updated
Edit

Test Pre-Release Transaction Types

(Requires cloning and modifying XRPL core repositories and understanding of XRPL transaction serialization).

Pre-release transactions are amendments that represent new features or other changes to transaction processing. Features are typically released to the XRPL Devnet for early testing.

This guide walks through the steps to test transaction types in development using either JavaScript with xrpl.js or Python with xrpl-py. This approach is typically only necessary for pre-release amendments that are available on the XRPL Devnet for early testing.

Note: The code samples below illustrate how to prepare your development environment and modify the XRPL to support custom transaction types, using the respective client library.

Prerequisites

  • Basic understanding of XRPL transactions.
  • Development environment setup for JavaScript or Python.
  • Docker installed and configured.

Steps

1. Set Up Your Development Environment

Ensure the proper dependencies are installed for Node.js or Python.

npm install xrpl

2. Generate Definitions File

Utilize the server_definitions command to retrieve the definitions.json content.

Note
Any parallel test network may be used instead of Devnet.

curl -X POST https://s.devnet.rippletest.net:51234/ -H 'Content-Type: application/json' -d '{"method": "server_definitions"}' > definitions.json

3. Update XRPL Library Definitions

Copy the generated definitions.json to your XRPL library installation.

// Locate your ripple-binary-codec installation in node_modules and replace the definitions.json file.
// <_your project directory_>/node_modules/ripple-binary-codec/dist/definitions.json

4. Create and Submit Custom Transaction

const { Client, Wallet } = require('xrpl');
const { encode } = require('ripple-binary-codec');

async function main() {
  const client = new Client("wss://s.devnet.rippletest.net:51233");
  await client.connect();

  const wallet = Wallet.fromSeed('sYOURSEEDHERE');

  const customTx = {
    TransactionType: 'NewTransactionType',
    Account: wallet.address,
    // additional fields for the new transaction
  };

  // If using Typescript, you will need to encode to allow typechecks to function
  // or just us @ts-expect-error when calling submit
  //   const encodedTransaction = encode(customTx);

  await client.submitAndWait(customTx, { wallet });
  // If using typescript, you should pass the encoded string of the transaction or us @ts-expect-error
  //   await client.submitAndWait(encodedTransaction, { wallet });
  // await client.disconnect();
}

main();
// Or call await main(); if your nodejs versions supports top level await

Considerations

  • Testing: Utilize the XRPL Testnet or Devnet for testing new transaction types.
  • Updates: Regularly update your rippled and XRPL library clones to include the latest features and fixes.
  • Custom Types and Serialization: If your transaction involves new data structures, ensure they are correctly defined and serialized according to XRPL standards.