Providing settings for client

Before connecting with Substrate network, you need to provide all required settings. Here is a settings struct declaration:

public struct SubstrateClientSettings {
    public var rpcPath: String?
    public var rpcParams: [String: String?]
    public var webSocketPath: String?
    public var webSocketPort: Int?
    public var webSocketParams: [String: String?]
    public var webSocketSecure: Bool
    public let runtimeMetadataUpdateTimeoutMs: Int64
    public let namingPolicy: SubstrateClientNamingPolicy

All nodes are different, and their configurations are different.

For a regular Kusama node by Parity (, you might provide rpcPath, rpcParams, webSocketPath, webSocketParams, webSocketPort as nil. These will be fully ignored.

But for OnFinality nodes, with your own API key with RPC at<YOUR_KEY> and web socket as wss://<YOUR_KEY> you need to provide settings like that:

let onFinalitySettings = SubstrateClientSettings(
    rpcPath: "rpc",
    rpcParams: ["apikey", "YOUR_KEY"],
    webSocketSecure: true,
    webSocketPath: "ws",
    webSocketParams: ["apikey", "YOUR_KEY"],
    webSocketPort: nil,
    runtimeMetadataUpdateTimeoutMs: yourTimeoutPreference,

Speaking of other parameters, runtimeMetadataUpdateTimeoutMs is delay in milliseconds (1 hour by default) which defines how often runtime metadata should be updated. Applicable only after your receive a runtime metadata at least once.

Naming policy is a enum:

public enum SubstrateClientNamingPolicy {
    case none
    case caseInsensitive

It is used in all services to match your outgoing requests. If you're sure that you can provide pallets, constants, storage, and functions names exactly as they're declared in metadata, feel free to apply NONE policy to avoid extra computation.

Last updated