Skip to main content

coin-addresses

A public key to the address a coin derives from it, and the validation of an address, in typed Python, with nothing above that: no transaction and no signature.

PyPI version GitHub release development status license downloads supported Python versions implementation wheel

What is here

coin_addresses.evm derives and validates the addresses of Ethereum and of the EVM chains, with their EIP-55 checksum; coin_addresses.bitcoin_cash, coin_addresses.bitcoin_sv, coin_addresses.bitcoin_gold, coin_addresses.ecash, coin_addresses.litecoin, coin_addresses.dogecoin and coin_addresses.dash those of the bitcoin clones; coin_addresses.tron those of Tron, coin_addresses.cosmos those of the Cosmos Hub, and coin_addresses.xrp the classic addresses of the XRP Ledger. These are the coins on secp256k1 of the first stage. coin_addresses.solana gives the addresses of Solana, a coin on ed25519 of the second stage. It builds on ecc for the curve and on base58-bech32 for the encodings, and not on btclib. btclib-org/.github#2197 records that decision and tracks the release; the later stages are btclib-org/.github#2199, btclib-org/.github#2200, btclib-org/.github#2201 and btclib-org/.github#2202.

The package is fully annotated and ships py.typed. Its refusals are coin_addresses.exceptions's classes: a ValueError or a TypeError, under one base, CoinAddressesException.

from coin_addresses.exceptions import (
    CoinAddressesException,
    CoinAddressesTypeError,
    CoinAddressesValueError,
)

assert issubclass(CoinAddressesValueError, (CoinAddressesException, ValueError))
assert issubclass(CoinAddressesTypeError, (CoinAddressesException, TypeError))

A public key, as a point or in its SEC encoding, compressed or not, gives its Ethereum address, and an address handed over is checked:

from coin_addresses import evm

# the generator of secp256k1, the public key of the private key 1
pub_key = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
address = evm.address_from_pub_key(pub_key)
assert address == "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"
assert evm.is_valid_address(address)
assert not evm.is_valid_address(address.replace("E", "e", 1))

A bitcoin clone's address is that of the key's compressed SEC encoding, and a key written uncompressed is refused. The Litecoin and Bitcoin Gold modules name the script type, and the Bitcoin Cash and eCash modules give the legacy address beside the CashAddr one:

from coin_addresses import bitcoin_cash, dogecoin, litecoin

pub_key = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
address = litecoin.address_from_pub_key(pub_key, script_type="p2wpkh")
assert address == "ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9"
address = bitcoin_cash.address_from_pub_key(pub_key)
assert address == "bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h"
address = bitcoin_cash.legacy_address_from_pub_key(pub_key)
assert address == "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH"
assert dogecoin.is_valid_address(dogecoin.address_from_pub_key(pub_key))

eCash writes CashAddr with its own prefix, and Bitcoin SV reads Bitcoin's legacy addresses alone:

from coin_addresses import bitcoin_cash, bitcoin_gold, bitcoin_sv, dash, ecash

pub_key = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
address = ecash.address_from_pub_key(pub_key)
assert address == "ecash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq"
assert not ecash.is_valid_address(bitcoin_cash.address_from_pub_key(pub_key))
address = bitcoin_sv.address_from_pub_key(pub_key)
assert address == "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH"
assert not bitcoin_sv.is_valid_address(bitcoin_cash.address_from_pub_key(pub_key))
address = bitcoin_gold.address_from_pub_key(pub_key, script_type="p2wpkh")
assert address == "btg1qw508d6qejxtdg4y5r3zarvary0c5xw7k6w057a"
assert dash.address_from_pub_key(pub_key) == "XmN7PQYWKn5MJFna5fRYgP6mxT2F7xpekE"

A Tron address carries the bytes of the key's Ethereum address, in Base58Check:

from coin_addresses import tron

pub_key = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
address = tron.address_from_pub_key(pub_key)
assert address == "TMVQGm1qAQYVdetCeGRRkTWYYrLXuHK2HC"
assert tron.is_valid_address(address)

A Cosmos Hub address carries a bitcoin clone's hash in bech32, with the HRP cosmos, and an address with another chain's HRP is refused:

from coin_addresses import cosmos
from coin_addresses.exceptions import CoinAddressesValueError

pub_key = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
address = cosmos.address_from_pub_key(pub_key)
assert address == "cosmos1w508d6qejxtdg4y5r3zarvary0c5xw7k6ah60c"
assert cosmos.is_valid_address(address)
# the same bytes with Osmosis's HRP: a valid bech32 string, refused for
# its HRP alone
osmosis = "osmo1w508d6qejxtdg4y5r3zarvary0c5xw7kjxy2e2"
try:
    cosmos.assert_valid_address(osmosis)
except CoinAddressesValueError as e:
    assert str(e) == "not the Cosmos HRP"
else:
    raise AssertionError(osmosis)

An XRP Ledger classic address carries the bytes of a Bitcoin P2PKH address, written with Ripple's Base58 alphabet. An X-address is refused:

from coin_addresses import xrp

pub_key = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
address = xrp.address_from_pub_key(pub_key)
# Bitcoin writes the same bytes as 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
assert address == "rBgGZ9tc4him9KBzD8fKFiQz3fSZpaSwMH"
assert xrp.is_valid_address(address)
# an X-address of another account, from xrpl-py's tests
assert not xrp.is_valid_address("X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ")

A Solana address is the 32 bytes of an ed25519 public key in Base58, with no checksum. Any 32 bytes are an address, so a program derived address, which lies off the curve, is valid too:

from coin_addresses import solana

# a key of bip_utils's tests
pub_key = "e9b6062841bb977ad21de71ec961900633c26f21384e015b014a637a61499547"
address = solana.address_from_pub_key(pub_key)
assert address == "GjJyeC1r2RgkuoCWMyPYkCWSGSGLcz266EaAkLA27AhL"
assert solana.is_valid_address(address)
# the System Program's address, the 32 zero bytes
assert solana.address_from_pub_key(bytes(32)) == "1" * 32
# a program derived address of solana-sdk's tests
assert solana.is_valid_address("BwqrghZA2htAcqq8dzP1WDAhTXYTYWj7CHxF5j7TDBAe")

tests/readme_test.py runs every Python block of this file, so the examples above are the ones the suite checks.

Security

SECURITY.md says how to report a vulnerability, which versions are supported, and how a published file is traced back to the run that built it.

Contributing

Development is LLM-based: humans are welcome, as long as they are comfortable with agentic development ;-). A contribution must have been read and understood by the person who submits it. CONTRIBUTING.md has the rules.

CONTRIBUTING.md has the commands each CI job runs, verbatim. uv sync creates the environment; uv is the only tool that has to be installed. REVIEWING.md is what a pull request is answered against.

How the organization decides, and who holds which role, is its GOVERNANCE.md; what it intends to do, and what it deliberately does not, is its ROADMAP.md.

Status

pre-commit.ci status lint workflow status test workflow status docs workflow status mutation workflow status fuzz workflow status deps-latest workflow status pypi-install workflow status deps-oldest workflow status os-macos workflow status os-ubuntu workflow status os-windows workflow status links workflow status sdist-rebuild workflow status codeql workflow status OpenSSF Scorecard


The btclib organization and its projects are actively supported by DGI and CheckSig.

Metadata

Release files for coin-addresses 2026.11.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coin-addresses 2026.11.14
File Size Uploaded Provenance Actions
coin_addresses-2026.11.14.tar.gz 578.0 kB With provenance Details for coin_addresses-2026.11.14.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for coin-addresses 2026.11.14
File Interpreter ABI Platform Actions
coin_addresses-2026.11.14-py3-none-any.whl Python 3 none any Details for coin_addresses-2026.11.14-py3-none-any.whl

Total release size: 619.4 kB

Release files / coin_addresses-2026.11.14.tar.gz

Download URL coin_addresses-2026.11.14.tar.gz
Size 578.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b5f51731574fc9d7a604f9e934c81456dd35c19fe94503da0882670f28277a64
BLAKE2b-256 checksum
How to use checksums
f2c989e083aa26b6e66c112c3fd26273b8d0cbfb8a00cc3636d08b10f7294a1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / coin_addresses-2026.11.14-py3-none-any.whl

Download URL coin_addresses-2026.11.14-py3-none-any.whl
Size 41.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52142be917ad50c136567a24edac5647b8393857d4ad19e3dc11ae8ddd4accd8
BLAKE2b-256 checksum
How to use checksums
3f81ac29a6ca4c311c1f47642370121706c8a923daebfc64e689ac8dca4d22eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for coin-addresses 2026.11.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for coin_addresses-2026.11.14.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page