phala-cloud v0.2.0 models KMS resources by contract. A KMS contract groups equivalent KMS node replicas that share one root key.
Every example works with both PhalaCloud and AsyncPhalaCloud. Add await when you use the async client.
list_kms_contracts
GET /kms
ListKmsContractsResponse, a paginated list of KmsContract objects.
Returns the available KMS contracts. This method always requests API version 2026-06-23.
KmsContract includes the contract id, slug, contract_address, chain_id, node_count, k256_pubkey, and ca_pubkey. For the off-chain Phala KMS, contract_address is "phala" and chain_id is 0.
get_kms_contract
GET /kms/{slug}
slug accepts a contract slug or kc_-prefixed contract ID.
Returns: KmsContract for the resolved contract.
Returns one KMS contract by slug. A kc_-prefixed contract ID also resolves.
list_kms_contract_nodes
GET /kms/{slug}/nodes
slug accepts a contract slug or kc_-prefixed contract ID.
Returns: ListKmsContractNodesResponse with the contract’s node replicas.
Returns the KMS node replicas under a contract, including each node’s RPC URL and version.
Legacy node methods
get_kms_list() accepts optional pagination and is_onchain filters. get_kms_info() requires kms_id. They return the earlier node-centric KMS shapes.
Both methods are deprecated and remain pinned to API version 2026-05-22.
Use list_kms_contracts(), get_kms_contract(), and list_kms_contract_nodes() for new code.
get_app_env_encrypt_pub_key
GET /kms/{kms}/pubkey/{appId}
kms is a KMS node ID or slug, and app_id is a 20-byte app ID with or without the 0x prefix.
Returns: AppEnvPubkeyResponse with public_key and signature.
Returns the public key used to encrypt environment variables for an app.
next_app_ids
GET /kms/phala/next_app_id
counts requests 1 to 20 IDs and defaults to 1.
Returns: NextAppIdsResponse with the reserved app_id and nonce pairs.
Reserves app IDs from the Phala KMS for deterministic provisioning.
get_kms_on_chain_detail
GET /kms/on-chain/{chain}
chain is the chain name, such as "base" or "ethereum".
Returns: GetKmsOnChainDetailResponse with the chain and its KMS contracts.
Returns the contracts, registered devices, OS images, and verification anchors for an on-chain KMS.
Compute and verify mr_config_id
The SDK exports byte-oriented and hex-oriented helpers:key_provider_type="kms", set key_provider_id_hex to the contract’s k256_pubkey, not its ca_pubkey.
get_mr_config_id() for byte inputs and get_mr_config_id_v1() for the V1 compose-hash-only format.

