# Test Pre-Release Transaction Types

*(Requires cloning and modifying XRPL core repositories and understanding of XRPL [transaction serialization](/docs/references/protocol/binary-format)).*

Pre-release transactions are [amendments](/docs/concepts/networks-and-servers/amendments) that represent new features or other changes to transaction processing. Features are typically released to the [XRPL Devnet](/docs/concepts/networks-and-servers/parallel-networks) 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](/docs/concepts/networks-and-servers/parallel-networks) 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](/docs/references/client-libraries).

## 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.

JavaScript

```javascript
npm install xrpl
```

Python

```bash
pip install xrpl-py
```

### 2. Generate Definitions File

Utilize the [server_definitions](/docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_definitions) command to retrieve the definitions.json content.

Any [parallel test network](/docs/concepts/networks-and-servers/parallel-networks) may be used instead of Devnet.

Linux

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

Mac

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

Windows (Cmd)

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

Windows (PowerShell)

```cmd
curl -Method Post -Uri https://s.devnet.rippletest.net:51234/ -Headers @{"Content-Type"="application/json"} -Body '{"method": "server_definitions"}' | Out-File -FilePath definitions.json
```

### 3. Update XRPL Library Definitions

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

JavaScript

```bash
// 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
```

Python

```bash
// Use `pip show xrpl-py` to find the installation location and navigate to `<_output of pip show_>/xrpl/core/binarycodec/definitions/definitions.json` to replace the `definitions.json` file.
```

### 4. Create and Submit Custom Transaction

JavaScript

```javascript
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
```

Python

```python
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import Transaction
from xrpl.wallet import Wallet
from xrpl.transaction import send_reliable_submission
from xrpl.core.binarycodec import encode

client = JsonRpcClient("wss://s.devnet.rippletest.net:51233")

wallet = Wallet(seed="sYOURSEEDHERE", sequence=0)

custom_tx = Transaction(
    account=wallet.classic_address,
    transaction_type="NewTransactionType",
    # additional fields for the new transaction
)

# If using typechecking, encode the transaction into a string before passing to send_reliable_submission
# because the new transaction type is not natively supported by xrpl-py and therefore will have a type
# error if you pass an unsupported transaction type
# encoded_tx = encode(custom_tx)

send_reliable_submission(custom_tx, client, wallet)
# If using typechecking, encode the transaction into a string before passing to send_reliable_submission
# because the new transaction type is not natively supported by xrpl-py and therefore will have a type
# error if you pass an unsupported transaction type
# send_reliable_submission(encoded_tx, client, wallet)
# Or disable type checking for the line
# send_reliable_submission(custom_tx, client, wallet) # type: ignore
```

### 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](/docs/references/protocol/transactions).