Encode and Decode an XRPL account address and destination tag to/from X-formatted (tagged) address

1.0.0 2020-02-01 22:14 UTC

This package is auto-updated.

Last update: 2020-06-30 23:08:45 UTC


Encode and Decode an XRPL account address and destination tag to/from X-formatted (tagged) address.

Destination tags provide a way for exchanges, payment processors, corporates or entities which accept incoming payments, escrows, checks and similar transcations to use a single receiving wallet while being able to disambiguate incoming transactions by instructing the senders to include a destination tag.

This package allows encoding and decoding from an XRPL address and destination tag to / from 'Tagged Addresses', containing both the destination account address and tag in one string. This way users can simply copy-paste the string, eliminating possible user error when copying / entering a numeric destination tag.

Hopefully all exchanges, wallets & other software using destination tags will implement this address codec. A migration period will be required to allow users to enter both address formats.

The website is available for users, exchanges and developers to provide some context and best practices.


Install with composer: crypto2/php-xrpl-tagged-address-codec




$x = new Crypto2\XAddress();
//Main Net - No Tag
$address = $x->Encode('rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', null, false);
//Main Net - With Tag
$address = $x->Encode('rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', 12345, false);
//Test Net - With Tag
$address = $x->Encode('rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', 12345, true);



$x = new Crypto2\XAddress();
$tmp = $x->Decode('XVLhHMPHU98es4dbozjVtdWzVrDjtV8xvjGQTYPiAx6gwDC');

Return is an array with keys: address, dest_tag, testnet
address: The Ripple address
dest_tag: The Destination Tag or null if one wasn't set in the tag
testnet: true if it is a testnet address, false otherwise


This readme based on the one for the Java/NPM package at

This concept is based on the concept from @nbougalis

Big thanks to @sublimator for his fiddles, ideas and fixes and @intelliot for the idea of adding an X / T prefix for (new) address recognizability.