c32check

Generating and decoding addresses on the Stacks blockchain.

For the c32check open-source repo: https://github.com/stacks-network/c32check

The Stacks blockchain uses c32-encoded public key hashes as addresses. Specifically, a c32check address is a c32check-encoded ripemd160 hash. This library is meant for generating and decoding addresses on the Stacks blockchain.

How it works

Each c32check string encodes a 1-byte version and a 4-byte checksum. When decoded as a hex string, the wire format looks like this:

If version is the version byte (a 1-byte number) and payload is the raw bytes (e.g. as a string), then the checksum is calculated as follows:

In other words, the checksum is the first four bytes of the double-sha256 of the bytestring concatenation of the version and payload. This is similar to base58check encoding, for example.

Examples

Installation

c32encode, c32decode

c32checkEncode, c32checkDecode

c32address, c32addressDecode

Note: These methods only work on ripemd160 hashes

c32ToB58, b58ToC32

Convert a Stacks address to its corresponding Bitcoin address, or vice versa.

Note: Common address versions are converted between c32check and base58check seamlessly, in order to accommodate Stacks addresses.

Last updated

Was this helpful?