Dash Core

Dash Core Developer Documentation

Welcome to the Dash Core developer documentation. You'll find guides and documentation to help you start working with Dash Core as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Guides

CompactSize Unsigned Integers

The raw transactionraw transaction - Complete transactions in their binary format; often represented using hexadecimal. Sometimes called raw format because of the various Dash Core commands with "raw" in their names. format and several peer-to-peer network messages use a type of variable-length integer to indicate the number of bytes in a following piece of data.

Dash Core code and this document refers to these variable length integers as compactSize. Many other documents refer to them as var_int or varInt, but this risks conflation with other variable-length integer encodings---such as the CVarInt class used in Dash Core for serializing data to disk. Because it's used in the transaction format, the format of compactSize unsigned integers is part of the consensus rulesconsensus rules - The block validation rules that full nodes follow to stay in consensus with other nodes..

For numbers from 0 to 252 (0xfc), compactSize unsigned integers look like regular unsigned integers. For other numbers up to 0xffffffffffffffff, a byte is prefixed to the number to indicate its length---but otherwise the numbers look like regular unsigned integers in little-endian order.

ValueBytes UsedFormat
>= 0 && <= 0xfc (252)1uint8_t
>= 0xfd (253) && <= 0xffff30xfd followed by the number as uint16_t
>= 0x10000 && <= 0xffffffff50xfe followed by the number as uint32_t
>= 0x100000000 && <= 0xffffffffffffffff90xff followed by the number as uint64_t

For example, the number 515 is encoded as 0xfd0302.

Updated about a year ago

What's Next


CompactSize Unsigned Integers

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.