A simple TypeScript script to send XAH on the Xahau Ledger using the official xahau JavaScript library.
This tool allows users to securely send XAH by prompting for transaction details and confirming before submission. It's designed for developers and users familiar with the Xahau ecosystem.
- Features
- Prerequisites
- Installation
- Usage
- How It Works
- Security Warning
- Dependencies
- Contributing
- License
- Interactive command-line interface for sending XAH
- Prompts for amount, destination address, and seed phrase
- Transaction summary and confirmation before submission
- Uses the official Xahau JavaScript library for reliable integration
- Supports Xahau mainnet transactions
- Node.js (version 18 or higher) - Download here
- npm (comes with Node.js)
- Basic knowledge of XAH and Xahau Ledger - see Xahau Documentation
-
Clone this repository:
git clone https://github.com/Handy4ndy/SendXAH.git cd SendXAH -
Install dependencies:
npm install
Run the script with:
npm start
The script will interactively prompt you for:
- Amount of XAH to send: Enter the amount in XAH (e.g., 10.5)
- Destination address: The Xahau address to send XAH to (must be a valid Xahau Ledger address)
- Your seed phrase: Your wallet's secret seed (keep this secure!)
After entering the details, the script will display a transaction summary including:
- Source address
- Destination address
- Amount
- Estimated fee
Confirm the transaction to submit it to the Xahau mainnet.
Here's a sample run of the script (with sensitive information masked for security):
C:\Users\Handy\Documents\GitHub\SendXAH>npm start
> xah-sender@1.0.0 start
> ts-node sendXAH.ts
Connected to Xahau network.
Enter the amount of XAH to send: 10
Enter the destination address: rGe24P5aZckhpfsXSsSwRa68pgtaio4yZw
Enter your seed phrase: *******************************
--- Transaction Summary ---
From: r9cRbr7HFoPBfRhP7v9sTjSKTRJoydcTyQ
To: rGe24P5aZckhpfsXSsSwRa68pgtaio4yZw
Amount: 10 XAH
Fee: 0.017841 XAH
Sequence: 823118746
---------------------------
Do you want to submit this transaction? (y/n): y
Transaction submitted.
Result: {
api_version: 1,
id: 5,
result: {
accepted: true,
account_sequence_available: 823118747,
account_sequence_next: 823118747,
applied: true,
broadcast: true,
engine_result: 'tesSUCCESS',
engine_result_code: 0,
engine_result_message: 'The transaction was applied. Only final in a validated ledger.',
kept: true,
open_ledger_cost: '17841',
queued: false,
tx_blob: '1200002100005359220000000024310FCB9A201B0137B9C16140000000009896806840000000000045B17321EDD7BA869CD64F500117AFC4423E694D516857371AD0181BEC5DF0E62E3D6F6CC07440ADAC70BF4528736FE850A37DDAA9F52ADAA134C581381D9FEF652B364E00D2505B37762062E78BEB9AF410915B8EC591E0E526DEE69812B0B735A808A67BAB0681145E7416AD47FD07D07D4529091E1152D96247D4988314ABA521D9DCB3602C15AE7CDA813AA9CA790E8B3D',
tx_json: {
Account: 'r9cRbr7HFoPBfRhP7v9sTjSKTRJoydcTyQ',
Amount: '10000000',
Destination: 'rGe24P5aZckhpfsXSsSwRa68pgtaio4yZw',
Fee: '17841',
Flags: 0,
LastLedgerSequence: 20429249,
NetworkID: 21337,
Sequence: 823118746,
SigningPubKey: 'EDD7BA869CD64F500117AFC4423E694D516857371AD0181BEC5DF0E62E3D6F6CC0',
TransactionType: 'Payment',
TxnSignature: 'ADAC70BF4528736FE850A37DDAA9F52ADAA134C581381D9FEF652B364E00D2505B37762062E78BEB9AF410915B8EC591E0E526DEE69812B0B735A808A67BAB06',
hash: '3509E559EC5FF28B8471C42BF8B2BB736EBF3773ABBA75CE14A45B710B00C9BD'
},
validated_ledger_index: 20429230
},
type: 'response'
}
This example shows a successful transaction submission. The engine_result of 'tesSUCCESS' indicates the transaction was applied successfully.
This script uses the xahau JavaScript library to interact with the Xahau Ledger. Here's a high-level overview:
- Wallet Connection: Connects to the Xahau mainnet using a WebSocket connection.
- Transaction Preparation: Creates a Payment transaction with the provided details.
- Signing: Signs the transaction using your seed phrase.
- Submission: Submits the signed transaction to the ledger.
- Confirmation: Waits for transaction validation and provides the result.
For more details on Xahau transactions, see the Transaction Types documentation and Send XAH guide.
This script interacts with real XAH on the mainnet. Use at your own risk!
- Ensure you have sufficient XAH for the transaction amount plus fees (typically around 0.01 XAH).
- Double-check all inputs, especially the destination address and amount.
- Never share your seed phrase with anyone.
- Test with small amounts first.
- For security best practices, refer to the Xahau Security Best Practices.
- xahau: Official Xahau JavaScript library for interacting with the Xahau Ledger
- readline-sync: Synchronous readline for Node.js, used for secure input masking
- @types/node: TypeScript type definitions for Node.js
- ts-node: TypeScript execution and REPL for Node.js
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues or feature requests, please use the GitHub Issues page.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with the Xahau Ledger