
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
ripple-address-codec
Advanced tools
The ripple-address-codec npm package provides utilities for encoding and decoding Ripple (XRP) addresses. It is useful for developers working with the Ripple network who need to handle address validation, encoding, and decoding.
Encoding a Ripple Address
This feature allows you to encode a Ripple account ID into a standard Ripple address format. The `encodeAccountID` function takes a Buffer containing the account ID and returns the encoded address.
const { encodeAccountID } = require('ripple-address-codec');
const accountID = Buffer.from('rippleAccountID', 'hex');
const encodedAddress = encodeAccountID(accountID);
console.log(encodedAddress);Decoding a Ripple Address
This feature allows you to decode a Ripple address back into its original account ID. The `decodeAccountID` function takes a Ripple address string and returns a Buffer containing the decoded account ID.
const { decodeAccountID } = require('ripple-address-codec');
const rippleAddress = 'rippleAddressString';
const decodedAccountID = decodeAccountID(rippleAddress);
console.log(decodedAccountID.toString('hex'));Validating a Ripple Address
This feature allows you to validate whether a given string is a valid Ripple address. The `isValidClassicAddress` function takes a Ripple address string and returns a boolean indicating its validity.
const { isValidClassicAddress } = require('ripple-address-codec');
const rippleAddress = 'rippleAddressString';
const isValid = isValidClassicAddress(rippleAddress);
console.log(isValid);The ripple-lib package is a comprehensive library for interacting with the Ripple network. It includes functionalities for address encoding/decoding, transaction signing, and network communication. Compared to ripple-address-codec, ripple-lib offers a broader range of features beyond just address handling.
The xrpl package is another library for interacting with the XRP Ledger. It provides tools for address encoding/decoding, transaction management, and ledger querying. Similar to ripple-lib, xrpl offers a more extensive set of functionalities compared to ripple-address-codec.
Functions for encoding and decoding XRP Ledger addresses and seeds.
Also includes support for encoding/decoding rippled validator (node) public keys.
All tools and apps in the XRP Ledger ecosystem are encouraged to adopt support for the X-address format. The X-address format is a single Base58 string that encodes an 'Account ID', a (destination) tag, and whether the address is intended for a test network. This prevents users from unintentionally omitting the destination tag when sending and receiving payments and other transactions.
Convert a classic address and (optional) tag to an X-address. If tag is false, the returned X-address explicitly indicates that the recipient does not want a tag to be used. If test is true, consumers of the address will know that the address is intended for use on test network(s) and the address will start with T.
> const api = require('ripple-address-codec')
> api.classicAddressToXAddress('rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf', 4294967295)
'XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi'
Encode a test address e.g. for use with Testnet or Devnet:
> const api = require('ripple-address-codec')
> api.classicAddressToXAddress('r3SVzk8ApofDJuVBPKdmbbLjWGCCXpBQ2g', 123, true)
'T7oKJ3q7s94kDH6tpkBowhetT1JKfcfdSCmAXbS75iATyLD'
Convert an X-address to a classic address and tag. If the X-address did not have a tag, the returned object's tag will be false. (Since 0 is a valid tag, instead of if (tag), use if (tag !== false) if you want to check for a tag.) If the X-address is intended for use on test network(s), test will be true; if it is intended for use on the main network (mainnet), test will be false.
> const api = require('ripple-address-codec')
> api.xAddressToClassicAddress('XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi')
{
classicAddress: 'rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf',
tag: 4294967295,
test: false
}
Returns true if the provided X-address is valid, or false otherwise.
> const api = require('ripple-address-codec')
> api.isValidXAddress('XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi')
true
Returns false for classic addresses (starting with r). To validate a classic address, use isValidClassicAddress.
Check whether a classic address (starting with r...) is valid.
Returns false for X-addresses (extended addresses). To validate an X-address, use isValidXAddress.
Encode the given entropy as an XRP Ledger seed (secret). The entropy must be exactly 16 bytes (128 bits). The encoding includes which elliptic curve digital signature algorithm (ECDSA) the seed is intended to be used with. The seed is used to produce the private key.
Decode a seed into an object with its version, type, and bytes.
Return object type:
{
version: number[],
bytes: UInt8Array,
type: string | null
}
Encode bytes as a classic address (starting with r...).
Decode a classic address (starting with r...) to its raw bytes.
Encode bytes to the XRP Ledger "node public key" format (base58).
This is useful for rippled validators.
Decode an XRP Ledger "node public key" (in base58 format) into its raw bytes.
Encode a public key, as for payment channels.
Decode a public key, as for payment channels.
Encode account ID, tag, and network ID to X-address.
accountId must be 20 bytes because it is a RIPEMD160 hash, which is 160 bits (160 bits = 20 bytes).
At this time, tag must be <= MAX_32_BIT_UNSIGNED_INT (4294967295) as the XRP Ledger only supports 32-bit tags.
If test is true, this address is intended for use with a test network such as Testnet or Devnet.
Convert an X-address to its classic address, tag, and network ID.
> var api = require('ripple-address-codec');
> api.decodeSeed('sEdTM1uX8pu2do5XvTnutH6HsouMaM2')
{ version: [ 1, 225, 75 ],
bytes: [ 76, 58, 29, 33, 63, 189, 251, 20, 199, 194, 141, 96, 148, 105, 179, 65 ],
type: 'ed25519' }
> api.decodeSeed('sn259rEFXrQrWyx3Q7XneWcwV6dfL')
{ version: 33,
bytes: [ 207, 45, 227, 120, 251, 221, 126, 46, 232, 125, 72, 109, 251, 90, 123, 255 ],
type: 'secp256k1' }
> api.decodeAccountID('rJrRMgiRgrU6hDF4pgu5DXQdWyPbY35ErN')
[ 186,
142,
120,
98,
110,
228,
44,
65,
180,
109,
70,
195,
4,
141,
243,
161,
195,
200,
112,
114 ]
Run unit tests with:
npm test
Use --watch to run in watch mode, so that when you modify the tests, they are automatically re-run:
npm test -- --watch
Use --coverage to generate and display code coverage information:
npm test -- --coverage
This tells jest to output code coverage info in the ./coverage directory, in addition to showing it on the command line.
Use the xrpl.js release process.
This library references and adopts code and standards from the following sources:
FAQs
encodes/decodes base58 encoded XRP Ledger identifiers
The npm package ripple-address-codec receives a total of 397,687 weekly downloads. As such, ripple-address-codec popularity was classified as popular.
We found that ripple-address-codec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.

Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.

Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.