Skip to content

encodePDPCapabilities

encodePDPCapabilities(pdpOffering, capabilities?): [string[], `0x${string}`[]]

Defined in: packages/synapse-core/src/utils/pdp-capabilities.ts:107

Encode a PDPOffering plus optional user-supplied extras into the (keys[], values[]) tuple consumed by registerProvider / addProduct / updateProduct on ServiceProviderRegistry.

Behavior notes:

  • Reserved PDP keys (see PDP_OFFERING_KEYS_SET) cannot be passed via capabilities; they are written from pdpOffering. A collision would desync the contract’s capability-keys array (duplicates kept) from the capability-value mapping (last-wins).
  • capabilities values are hex-encoded verbatim if they already look like hex (e.g. '0x01' for a flag byte), otherwise UTF-8-encoded. Empty strings are rejected — callers that want a flag byte must pass '0x01' explicitly instead of ''.

Total-count and per-entry byte-length limits are enforced by validateCapabilities at each *Call site, so they are not re-checked here.

ParameterTypeDescription
pdpOfferingPDPOfferingThe PDP offering to encode.
capabilities?Record<string, string>Optional non-reserved extra capabilities.

[string[], `0x${string}`[]]

A [keys, values] tuple ready for the contract call.

Errors ValidationError when capabilities contains a reserved PDP key or an empty value