Overview of @xrplf/isomorphic
main@noble/hashes, while Node.js implementations use the native crypto module.repository·main·Indexed 23 days ago
https://github.com/xrplf/xrpl.jsThe recommended JavaScript/TypeScript library for interacting with the XRP Ledger. It allows developers to manage keys, submit transactions, observe ledger state, and subscribe to real-time updates. The library includes specialized packages for isomorphic cryptographic functions (@xrplf/isomorphic), address encoding and decoding (ripple-address-codec), and binary serialization for transactions and ledger data (ripple-binary-codec).
@noble/hashes, while Node.js implementations use the native crypto module.ripple-binary-codec library provides tools to serialize and deserialize transactions according to the XRP Ledger (XRPL) protocol. Use this library when you need to convert transaction objects into the specific binary format required by the network or decode binary data back into usable transaction objects.The xrpl.js library provides several key capabilities for interacting with the XRP Ledger:
Wallet and Client.fundWallet().Client.submit().Client.request() and public API methods.xrpToDrops and rippleTimeToISOTime.The library is compatible with Node.js (v20+ recommended) and web browsers (tested in Chrome).
xrpl.js library is used across a wide variety of XRP Ledger (XRPL) ecosystem applications, including exchanges, explorers, wallets, and development tools. This list serves as a reference for real-world implementations and potential integration patterns.All hash functions in this package (such as sha256, sha512, and ripemd160) follow a consistent pattern. They can be used in two ways:
Uint8Array or a string directly to the function. If a string is provided, it is converted to a Uint8Array via UTF-8 encoding (not hex). The function returns a Uint8Array..create(): Use the .create() method to get a Hash subclass instance. This allows you to incrementally add data using .update() and finalize the hash using .digest(). Once .digest() is called, the instance can no longer be used.Supported hash modules include:
@xrplf/isomorphic/ripemd160@xrplf/isomorphic/sha256@xrplf/isomorphic/sha512// Direct call
const hashA = sha256('abc');
// Incremental usage
const hashB = sha256
.create()
.update(Uint8Array.from([1, 2, 3]))
.digest();The ripple-binary-codec uses definitions to manage how fields are serialized. Key properties for a field include:
"LedgerEntry", "Transaction").STI_VL/Blob, STI_ACCOUNT/AccountID, and STI_VECTOR256/Vector256.SField::notSigning.Buffer has been replaced with Uint8Array because Buffer is not native to browsers. Since Buffer is a subclass of Uint8Array, you can often replace Buffer instances with Uint8Array directly. However, you must be aware that Uint8Array does not possess the additional helper functions that Buffer provides. You may need to update your code where you rely on specific Buffer methods.The library follows specific rules for XRPL currency codes:
rippled server may enforce stricter rules./^[A-Z0-9]{3}$/ (three uppercase letters or numbers), it is decoded as a standard ISO 4217 or pseudo-ISO currency string.aBC), it is treated as a non-ISO currency and returned as a 160-bit hex-string (40 hex characters).In version 3.0, Buffer has been replaced by Uint8Array. While Buffer is a subclass of Uint8Array and can often be used as a parameter, many methods that previously returned Buffer now return Uint8Array. You must update your code to handle Uint8Array and use its specific syntax for conversions.
Affected packages and methods:
ripple-address-codec
decodeAccountID, encodeAccountID, decodeAccountPublic, encodeAccountPublic, decodeNodePublic, encodeNodePublic, encodeSeed, decodeXAddress, encodeXAddressripple-binary-codec
SerializedType constructor and .toBytes() (including subclasses like AccountID, Amount, Blob, Currency, Hash, Hash128, Hash160, Hash256, Issue, PathSet, STArray, STObject, UInt, UInt8, UInt16, UInt32, UInt64, Vector256, XChainBridge)ShaMapNode.hashPrefixBinarySerializer.putBytesList.put and BytesList.toBytesBinaryParser.read and BinaryParser.readVariableLengthQuality.encode and Quality.decodeSha512Half.put and Sha512Half.finish256transactionID, sha512Half, signingClaimData, serializeObject, makeParserFieldInstance.header, Bytes.bytes, and HashPrefix entriessecret-numbers
entropyToSecret, randomEntropy, and the Account constructorxrpl
rfc1751MnemonicToKeyIf you are building decentralized applications (dApps) on the XRP Ledger, you can integrate with existing self-custody wallets and gateways that support XRPL interactions:
To single-sign a transaction, you must follow these steps:
txJSON) into the XRP Ledger's binary format.0x53545800. For multi-signing, the prefix is 0x534D5400.TxnSignature field in the final serialized transaction.The hashTx method automates step 2 by automatically applying the 0x53545800 prefix required for single-signing.
ripple-keypairs package provides an implementation of XRP Ledger keypairs and wallet generation. It uses noble and supports rfc6979 and eddsa deterministic signatures.