Skip to main content

system_properties - JSON-RPC Method

Description#

Returns the chain properties including token decimals, token symbol, and SS58 address format. This JSON-RPC method provides essential configuration information needed for properly formatting addresses and token amounts in applications.

Parameters#

This method does not require any parameters.

Returns#

FieldTypeDescription
tokenDecimalsnumber | number[]Primary token decimals (Hydration uses 12)
tokenSymbolstring | string[]Primary token symbol (Hydration uses HDX)
ss58Formatnumber (optional)SS58 address prefix if provided (default to 63 when omitted)

Request Example#

{
"jsonrpc": "2.0",
"method": "system_properties",
"params": [],
"id": 1
}

Response Example#

{
"jsonrpc": "2.0",
"result": {
"tokenDecimals": 12,
"tokenSymbol": "HDX"
},
"id": 1
}

Code Examples#

import requests
import json
from decimal import Decimal

def get_system_properties():
url = "https://api-hydration.n.dwellir.com/YOUR_API_KEY"
headers = {
"Content-Type": "application/json"
}

payload = {
"jsonrpc": "2.0",
"method": "system_properties",
"params": [],
"id": 1
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
return response.json()["result"]

# Get and use chain properties
properties = get_system_properties()
decimals = properties["tokenDecimals"][0]
symbol = properties["tokenSymbol"][0]
ss58_format = properties.get("ss58Format", 63)

print(f"Token: {symbol}")
print(f"Decimals: {decimals}")
print(f"SS58 Format: {ss58_format}")

# Create formatter class
class TokenFormatter:
def __init__(self, decimals, symbol):
self.decimals = decimals
self.symbol = symbol
self.unit = Decimal(10) ** decimals

def format_amount(self, raw_amount):
amount = Decimal(raw_amount) / self.unit
return f"{amount:.4f} {self.symbol}"

def to_raw(self, amount):
return int(Decimal(amount) * self.unit)

# Usage
formatter = TokenFormatter(decimals, symbol)
print(formatter.format_amount(1_000_000_000_000)) # 1.0000 HDX
print(formatter.to_raw(1.5)) # 1500000000000

Common Chain Properties#

ChainSS58 FormatSymbolDecimals
Hydration63HDX12
Basilisk10041BSX12
Generic Substrate42UNIT12

Address Formatting Example#

import { encodeAddress, decodeAddress } from '@polkadot/util-crypto';

async function formatAddressForChain(address) {
const properties = await getChainProperties();
const ss58Format = properties.ss58Format;

// Decode from any format
const decoded = decodeAddress(address);

// Re-encode with chain's format
const formatted = encodeAddress(decoded, ss58Format);

console.log(`Original: ${address}`);
console.log(`Formatted for chain: ${formatted}`);

return formatted;
}

// Example
const genericAddress = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const chainAddress = await formatAddressForChain(genericAddress);

Use Cases#

  1. UI Configuration: Set up correct token display in interfaces
  2. Address Formatting: Format addresses for the specific chain
  3. Balance Display: Show balances with correct decimals
  4. Transaction Creation: Calculate fees and amounts correctly
  5. Multi-chain Support: Handle different chains dynamically

Notes#

  • Properties are chain-specific and may vary
  • Some chains support multiple tokens
  • SS58 format determines address encoding
  • Always use these properties for formatting
  • Properties rarely change but should be fetched on init