
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@siddomains/address-encoder
Advanced tools
Encodes and decodes address formats for various cryptocurrencies
This typescript library encodes and decodes address formats for various cryptocurrencies.
Text-format addresses are decoded into their native binary representations, and vice-versa. In the case of Bitcoin-derived chains, this means their scriptPubKey; for Ethereum-derived chains this is their hash.
This library was written for use with EIP 2304, but may be useful for anyone looking for a general purpose cryptocurrency address codec.
EVM compatible chains are either specified using SLIP44 coinType or 0x800000000 | chainId
where 0x800000000 is msb (most significant bit) reserved at SLIP44 and no coin types exist in that range. This is to avoid number colision with th existing coin types.
For example, cointype of ARB1 is 2147441487(0x80000000 | 42161
).
npm install --save @siddomains/address-encoder
import { formatsByName, formatsByCoinType } from '@siddomains/address-encoder';
const data = formatsByName['BTC'].decoder('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa');
console.log(data.toString('hex')); // 76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
const addr = formatsByCoinType[0].encoder(data);
console.log(addr); // 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
This library currently supports the following cryptocurrencies and address formats (ordered alphabetically):
We welcome PRs to add additional chains and address types.
The hardest part of adding new cointype is to find out the address format of each coin. Many coins derived from and share the same attributes as Bitcoin, Ethereum, and other popular blockchains. In that case, adding these coins can be as easy as a few lines of code. However, if the address format is unique and no js libraries available (or existing library file size too big), then you may have to port the encoding/verification from other languages into js by yourself, which could become time-consuming with lots of effort.
In either case, please follow the following guides and best practices.
When we review your pull request, we conduct the following checks.
Please make sure that you include all the reference information so that we don't have to spend hours googling the relevant info which you must have done already.
If there are reusable components, please reuse the function rather than duplicating the similar code.
This library will be used in many mobile wallets where size bloat impacts the performance of the wallet. If your solution simply imports existing libraries, it may
Some specifications simply use base58 encoding without specific checksum. However, if there are any extra address format (such as address prefix or address length) exists, please also add that check so that we can prevent users from adding wrong coin address.
FAQs
Encodes and decodes address formats for various cryptocurrencies
The npm package @siddomains/address-encoder receives a total of 171 weekly downloads. As such, @siddomains/address-encoder popularity was classified as not popular.
We found that @siddomains/address-encoder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.