Skip to main content

Crypto Address Validation

Simple crypto address validator. Currently it supports the following crypto addresses:

  • Bitcoin
  • Ethereum
  • Litecoin

Supported Python versions

Only supported in python >= 3.5.

Installation

$ pip install cryptoaddress

API

The BitcoinAddress class

BitcoinAddress(address [, network_type='mainnet'])

Parameters

  • address: the Bitcoin address to validate.
  • network_type: Optional. Use either 'mainnet' or 'testnet'.

Raises ValueError if the provided address is not a valid Bitcoin address

The EthereumAddress class

EthereumAddress(address)

Parameters

  • address: the Ethereum address to validate.

Raises ValueError if the provided address is not a valid Ethereum address

The LitecoinAddress class

LitecoinAddress(address [, network_type='mainnet'])

Parameters

  • address: the Litecoin address to validate.
  • network_type: Optional. Use either 'mainnet' or 'testnet'.

Raises ValueError if the provided address is not a valid Litecoin address

Usage example

You can use directly a subclass of CryptoAddress:

from cryptoaddress import BitcoinAddress

try:
    bitcoin_address = BitcoinAddress('17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem', network_type='mainnet')
    print('The address "%s" is valid.' % str(bitcoin_address))
except ValueError:
    print('The address is invalid.')

# Prints 'The address "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem" is valid.'

Or you can use the get_crypto_address utility function:

from cryptoaddress import get_crypto_address

try:
    bitcoin_address = get_crypto_address('BTC', '17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem', network_type='mainnet')
    print('The address "%s" is valid.' % str(bitcoin_address))
except ValueError:
    print('The address is invalid.')

# Prints 'The address "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem" is valid.'

Upload to pypi

After creating a semantic versioning tag proceed in the following way:

  • Install all required packages:
$ python3 -m pip install --user --upgrade setuptools wheel twine
  • Generate the package:
$ python3 setup.py sdist bdist_wheel

This will create a dist/ folder whose content has to be uploaded.

  • Upload the new package to pypi:
$ python3 -m twine upload dist/*

Metadata

Release files for cryptoaddress 0.2.1

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

Source distribution (sdist)

Source distribution for cryptoaddress 0.2.1
File Size Uploaded
cryptoaddress-0.2.1.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cryptoaddress 0.2.1
File Interpreter ABI Platform
cryptoaddress-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / cryptoaddress-0.2.1.tar.gz

Download URL cryptoaddress-0.2.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2f86feab5e8eb8cf2ebf640bccf70c2758b17449c24c2567674304d7588d0e16
BLAKE2b-256 checksum
How to use checksums
01e402ba4a4227cbdfa8399d35b0dcbc1eefd230b81d95c05fd8ffcd8ebba7c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

Release files / cryptoaddress-0.2.1-py3-none-any.whl

Download URL cryptoaddress-0.2.1-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
444bf7de5c693c2664009f1d96f493d3b27b7e2c208cbf10ba8788711a46d3ca
BLAKE2b-256 checksum
How to use checksums
1ccdd6eff555038a0b39f15e0b722344c6cb3bf19e472f3d1b8dab9aec46cd57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

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