Skip to main content

Overview

The KDP API uses specific data types and formats to ensure consistency and precision when handling blockchain data. This guide explains the key data types you’ll encounter.

Basic Types

Amounts (SOMPI)

All monetary amounts in the Kaspa blockchain are represented in SOMPI, the smallest unit of Kaspa.
  • 1 KAS = 100,000,000 SOMPI
  • Amounts are returned as strings to preserve precision
  • Always use appropriate libraries for big number arithmetic

Hashes

All hashes (transaction IDs, block hashes) are 64-character hexadecimal strings:

Addresses

Kaspa addresses use the Bech32 format with the kaspa: prefix:

Timestamps

Timestamps are Unix timestamps in milliseconds:

Complex Types

Script Public Keys

Script public keys are represented in hexadecimal format:

Blue Score / DAA Score

Blue score and DAA score represent the position of a block in the blockchain:

Type Conversion Examples

JavaScript/TypeScript

Python

Special Values

Null Values

Some fields may be null when data is not available:

Empty Arrays

Arrays are never null, but may be empty:

Best Practices

  1. Use string arithmetic: Always use appropriate libraries for handling large numbers
  2. Validate addresses: Check address format before making requests
  3. Handle null values: Always check for null before using optional fields
  4. Preserve precision: Don’t convert amounts to floating point numbers
  5. Use constants: Define constants for conversions (e.g., SOMPI_PER_KAS)