Skip to main content
AllSwap

Validate addresses and memos locally

multichain-memo-address-validator is AllSwap's open source (MIT) address checker. It tells you whether a mainnet address is well formed for its chain, whether its checksum is right, which common mistake it shows, and whether that kind of address usually needs a memo or destination tag at an exchange. It has no dependencies, makes no network calls and needs no API key. It runs in Node.js 20 or later and in browsers.

It checks the text of an address only. It cannot tell whether an address exists on chain, who controls it, or whether funds sent to it could be recovered, and it does not check memo text.

Install

npm
npm install multichain-memo-address-validator

The package is an ES module with TypeScript types included. Import it with import; there is no CommonJS build.

Check your first address

isValidAddress(chain, address) answers yes or no. inspectAddress(chain, address) returns a small report. Both are async. Save this as check.mjs next to the installed package:

check.mjs
import { inspectAddress, isValidAddress } from "multichain-memo-address-validator";

const address = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";

console.log(await isValidAddress("eth", address));
console.log(await inspectAddress("eth", address));
Run
node check.mjs
Output
true
{
  valid: true,
  family: 'evm',
  checksum: 'verified',
  pitfall: 'none',
  memoSensitive: false
}

The address is mixed case, so the package verified its EIP-55 checksum. The first argument names the chain: a short name such as eth or a CAIP-2 chain ID such as eip155:1 (see Chain names).

Read the result

For a chain it recognizes, inspectAddress returns an object with five fields:

Scroll the table sideways to view more columns.

FieldTypeDescription
validrequiredbooleantrue when the address passes the format and checksum rules of its chain.
familyrequiredstringThe address family the chain name resolved to: evm, btc, ltc, doge, bch, zec, sol, tron, near, ton, xrp or stellar.
checksumrequiredstringWhat the checksum check found; values below.
pitfallrequiredstringThe common mistake detected, or none; values below.
memoSensitiverequiredbooleantrue for families where exchanges and other shared accounts usually need a memo or destination tag besides the address (near, ton, xrp, stellar). It describes the chain, not this address.

For a chain name it does not recognize, inspectAddress returns null and isValidAddress returns false. Treat null as “not checked”, not as “invalid”.

checksum values

Scroll the table sideways to view more columns.

ValueMeaning
verifiedThe address carries a checksum and it matches.
unchecked-caseAn EVM address written all in lowercase or all in uppercase. It is valid, but there is no checksum to catch a typo.
invalid-checksumThe address carries a checksum and it does not match (an EVM address in mixed case, or a Stellar key).
not-applicableThe format has no checksum (Solana, NEAR, raw TON 0:…), or the address was refused before a checksum could be checked.
skippedA Base58Check checksum could not be computed because Web Crypto (crypto.subtle) is unavailable; valid then reflects the format only. Node.js 20 or later and browsers on HTTPS pages provide it.

pitfall values

Scroll the table sideways to view more columns.

ValueMeaning
noneNo problem found.
emptyThe address is empty.
whitespaceThe address has spaces or line breaks, often left by copy and paste.
evm-zero-addressThe EVM zero address 0x000…000, which nobody controls.
evm-bad-checksumAn EVM address in mixed case whose EIP-55 checksum does not match: most likely a typo.
ltc-legacy-3-prefixA Litecoin address starting with 3. Bitcoin uses the same prefix, so the package refuses it; ask for the M… or ltc1… form.
bch-legacy-base58A Bitcoin Cash address in the legacy 1… or 3… form; only CashAddr (bitcoincash:q… or p…) is accepted.
xrp-x-addressAn XRP X-address, which packs the destination tag into the address; ask for the classic r… address and the tag separately.
ton-testnet-or-masterchainA TON testnet address (kQ… or 0Q…) or a masterchain address (-1:…); only basechain mainnet addresses are accepted.
zec-shielded-unsupportedA shielded or unified Zcash address (zs1…, u1…, zc…); only transparent t1… and t3… addresses are accepted.
invalid-formatAnything else that does not match the chain's format or checksum.

Common cases

This script runs the mistakes that come up most often when users paste a recipient address:

cases.mjs
import { inspectAddress } from "multichain-memo-address-validator";

const cases = [
  // One letter in the wrong case breaks the EIP-55 checksum
  { label: "EVM, one case typo", chain: "eth", address: "0xd8da6BF26964aF9D7eEd9e03E53415D37aA96045" },
  // All lowercase is valid, but there is no checksum to verify
  { label: "EVM, all lowercase", chain: "eth", address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045" },
  // A classic XRP address; an exchange deposit usually also needs a destination tag
  { label: "XRP, classic r...", chain: "xrp", address: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" },
  // An X-address packs the tag into the address; it is refused
  { label: "XRP, X-address", chain: "xrp", address: "X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ" },
  // A user-friendly TON address on the basechain; exchanges usually need a memo
  { label: "TON, EQ...", chain: "ton", address: "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs" },
  // A legacy 3... address collides with Bitcoin P2SH; it is refused
  { label: "Litecoin, legacy 3...", chain: "ltc", address: "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy" },
  // The native SegWit form is accepted
  { label: "Litecoin, ltc1...", chain: "ltc", address: "ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9" },
  // A trailing newline from copy and paste
  { label: "Tron, trailing newline", chain: "tron", address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t\n" },
];

for (const { label, chain, address } of cases) {
  const r = await inspectAddress(chain, address);
  if (!r) continue;
  console.log(
    `${label.padEnd(23)} valid=${String(r.valid).padEnd(5)} checksum=${r.checksum.padEnd(16)} pitfall=${r.pitfall.padEnd(19)} memoSensitive=${r.memoSensitive}`,
  );
}
Run
node cases.mjs
Output
EVM, one case typo      valid=false checksum=invalid-checksum pitfall=evm-bad-checksum    memoSensitive=false
EVM, all lowercase      valid=true  checksum=unchecked-case   pitfall=none                memoSensitive=false
XRP, classic r...       valid=true  checksum=verified         pitfall=none                memoSensitive=true
XRP, X-address          valid=false checksum=not-applicable   pitfall=xrp-x-address       memoSensitive=true
TON, EQ...              valid=true  checksum=verified         pitfall=none                memoSensitive=true
Litecoin, legacy 3...   valid=false checksum=not-applicable   pitfall=ltc-legacy-3-prefix memoSensitive=false
Litecoin, ltc1...       valid=true  checksum=verified         pitfall=none                memoSensitive=false
Tron, trailing newline  valid=false checksum=not-applicable   pitfall=whitespace          memoSensitive=false
  • EVM checksum. One letter in the wrong case makes a mixed-case address fail (evm-bad-checksum). The all-lowercase form of the same address is valid but unchecked-case: a typo in it would go unnoticed, so prefer the checksummed form the wallet shows.
  • XRP and TON. Both addresses are valid and memoSensitive is true. An X-address is refused with xrp-x-address.
  • Litecoin 3…. Refused with ltc-legacy-3-prefix, because a Bitcoin P2SH address looks the same. The native SegWit ltc1… form passes.
  • Whitespace. A trailing newline is reported as whitespace instead of being trimmed silently. Trim the input or ask the user to fix it.

Memo-sensitive chains

On NEAR, TON, XRP and Stellar, an exchange or custodial wallet often gives every customer the same address and tells deposits apart by a memo or destination tag. A valid address with memoSensitive: true is a cue to ask whether a memo is needed. The package does not check the memo itself. AllSwap payouts do not attach a recipient memo or tag, so a swap's recipient on these chains should be a self-custody address.

Chain names

The first argument accepts short names and CAIP-2 chain IDs, so you can pass the chainId of an asset from AllSwap's public asset catalog as it is. resolveAddressFamily shows what a name resolves to:

chains.mjs
import { inspectAddress, isValidAddress, resolveAddressFamily } from "multichain-memo-address-validator";

// Short aliases and CAIP-2 chain IDs both work
console.log(resolveAddressFamily("base"), resolveAddressFamily("eip155:8453"), resolveAddressFamily("tron:mainnet"));

// A chain the package does not cover
console.log(resolveAddressFamily("cardano"));
console.log(await inspectAddress("cardano", "addr1..."));
console.log(await isValidAddress("cardano", "addr1..."));
Run
node chains.mjs
Output
evm evm tron
null
null
false

When this guide was written, every chainId in the asset catalog resolved to a family. Still handle null: the catalog can add chains before the package covers them.

Supported families

Scroll the table sideways to view more columns.

FamilyChain namesAccepted formsMemo-sensitive
evmeth, base, bsc, arb, op, pol, avax, eip155:<id>0x<40 hex>No
btcbtc, bitcoin, bip122:000000000019d6689c085ae165831e931…, 3…, bc1q…, bc1p…No
ltcltc, litecoin, bip122:12a765e31ffd4059bada1e25190f6e98L…, M…, ltc1q…, ltc1p…No
dogedoge, dogecoin, bip122:1a91e3dace36e2be3bf030a65679fe82D…, 9…, A…No
bchbch, bip122:000000000000000000651ef99cb9fcbebitcoincash:q…, bitcoincash:p…No
zeczec, zcash, bip122:0007104ccda289427919efc39dc9e4d4t1…, t3…No
solsol, solana, solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp<base58, 32 bytes>No
trontron, trx, tron:mainnetT…No
nearnear, near:mainnetname.near, <64 hex>, 0x<40 hex>Yes
tonton, ton:mainnetEQ…, UQ…, 0:<64 hex>Yes
xrpxrp, ripple, xrpl, ripple:0r…Yes
stellarstellar, xlm, stellar:publicG…Yes

TypeScript

The package ships src/index.d.ts with the types AddressInspectionResult, AddressFamily, ChecksumStatus and AddressPitfallCode. A typed helper that turns the report into a message:

check-recipient.mts
import { inspectAddress, type AddressInspectionResult } from "multichain-memo-address-validator";

// null: this chain is not covered, so the address was not checked
async function describe(chain: string, address: string): Promise<string | null> {
  const r: AddressInspectionResult | null = await inspectAddress(chain, address);
  if (!r) return null;
  if (!r.valid) return `rejected: ${r.pitfall}`;
  return r.memoSensitive ? "valid; exchanges on this chain usually need a memo or tag" : "valid";
}

console.log(await describe("tron:mainnet", "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"));
console.log(await describe("ton:mainnet", "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"));
console.log(await describe("eip155:1", "0xd8da6BF26964aF9D7eEd9e03E53415D37aA96045"));
console.log(await describe("cardano", "addr1..."));
Run
node check-recipient.mts
Output
valid
valid; exchanges on this chain usually need a memo or tag
rejected: evm-bad-checksum
null

Node.js 22.18 or later runs a .mts file directly; on older versions use npx tsx check-recipient.mts or compile it with tsc.

Limits

  • Mainnet only. Testnet addresses are refused.
  • A valid result says the text is well formed. It does not prove the address belongs to the person you expect; for large amounts, a small test transfer is still the only proof.
  • Some chains have no checksum (Solana, NEAR, raw TON 0:…); a typo there can still produce a valid-looking address.