Klayr Service Configuration Reference

On the Introduction to Klayr Service page, we have discussed the various microservices that combine to form Klayr Service. On this page, we will thoroughly discuss the configuration options available for each service.

Default configurations

By default, a Klayr Service installation will have an ecosystem.config.js file with all the default configurations that could be used to run and manage the various microservices with pm2.

The actual ecosystem.config.js file for Klayr Service can be found in the klayr-service GitHub repository.

The values of various environment variables are automatically picked by the microservices based on the installation environment. Aside from that, many environment variables can be configured to meet the specific requirements, the details of which have been outlined with each microservice.

Microservice configurations

In this section, we discuss the common and specific configurations of all the microservices of Klayr Service.

Common configurations

The common configurations described in this section apply to all the microservices within Klayr Service.

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker. Must be identical for all the microservices. Make sure that all microservices can connect with the message broker. This could be a NATS or a Redis instance.

redis://klayr:[email protected]:6379/0

SERVICE_BROKER_TIMEOUT

number

Inter-microservice request timeout in seconds.

10

SERVICE_LOG_LEVEL

string

Set the application logging level; Available options are trace, debug, info, warn, error, and fatal.

info

SERVICE_LOG_STDOUT

boolean

Enable posting logs to the standard output stream. Accepted values are true and false.

true

SERVICE_LOG_CONSOLE

boolean

Enable posting logs to the JavaScript console.log() output (blocking). This property should be enabled only for debugging purposes.

false

SERVICE_LOG_FILE

string

File path to capture the logs.

./logs/app.log

SERVICE_LOG_GELF

string

Enable log output in GELF for remote logging. For example, Graylog: 127.0.0.1:12201/udp.

127.0.0.1:12201/udp

DOCKER_HOST

string

Used by the Docker CLI to determine the host to connect to.

local

Sample Configurations
Example of two microservices having the same environment variables
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-gateway',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_LOG_LEVEL: 'info',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_CONSOLE: 'false',
        // SERVICE_LOG_STDOUT: 'true',
        // SERVICE_LOG_GELF: 'false',
        // SERVICE_LOG_FILE: 'false',
        // [...]
      },
    },
    {
      name: 'klayr-service-transaction-statistics',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_LOG_LEVEL: 'info',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_CONSOLE: 'false',
        // SERVICE_LOG_STDOUT: 'true',
        // SERVICE_LOG_GELF: 'false',
        // SERVICE_LOG_FILE: 'false',
        // [...]
      },
    },
    // Configuration for other microservices.
  ],
};

Gateway

Environment variable Datatype Description Sample

PORT

number

Port that provides the possibility to connect with Klayr Service.

9901

HOST

string

URL of the host.

127.0.0.1

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

JSON_RPC_STRICT_MODE

boolean

Ensures that JSON-RPC accepts a valid JSON-RPC 2.0 envelope.

false

ENABLE_HTTP_API

string

Enables particular HTTP API endpoints. Directories (under gateway/apis/) containing the API method definitions. Must be listed as comma-separated values.

http-status,http-version3,http-exports

ENABLE_WS_API

string

Enables specified WebSocket API namespaces. Must be listed as comma-separated values.

blockchain,rpc-v3

SERVICE_GATEWAY_REDIS_VOLATILE

string

URL of the volatile cache storage (Redis). Used to cache RPC requests. Required when ENABLE_REQUEST_CACHING is enabled.

redis://klayr:[email protected]:6379/5

GATEWAY_DEPENDENCIES

string

Describes the microservices on which the gateway service depends. The list can be expressed as a CSV.

indexer,connector

ENABLE_REVERSE_PROXY_TIMEOUT_SETTINGS

boolean

Boolean flag to enforce the headersTimeout and keepAliveTimeout settings on the API server. Enabling this might be helpful when deploying Klayr Service behind a load balancer or a reverse proxy. Check this FAQ for more information.

false

HTTP_KEEP_ALIVE_TIMEOUT

number

Defines the number of microseconds the gateway will wait before closing an idle connection. To enable, ensure ENABLE_REVERSE_PROXY_TIMEOUT_SETTINGS is set to true, or HTTP_RATE_LIMIT_NUM_KNOWN_PROXIES is set to greater than 0. By default, it is set to 65000.

65000

HTTP_HEADERS_TIMEOUT

number

Defines the maximum number of microseconds for the gateway to send HTTP response headers after the client’s request. To enable, ensure ENABLE_REVERSE_PROXY_TIMEOUT_SETTINGS is set to true, or HTTP_RATE_LIMIT_NUM_KNOWN_PROXIES is set to greater than 0. Please ensure that the HTTP_HEADERS_TIMEOUT is set higher than the HTTP_KEEP_ALIVE_TIMEOUT. By default, it is set to 66000.

66000

WS_RATE_LIMIT_ENABLE

boolean

To enable the WebSocket rate limit, this environment variable is required to be true.

false

WS_RATE_LIMIT_CONNECTIONS

number

Once the rate limit is enabled, this variable contains the number of connections per second.

5

WS_RATE_LIMIT_DURATION

number

Defines the duration (in seconds) for which the WS rate should be limited.

1

ENABLE_REQUEST_CACHING

boolean

To enable RPC response caching, this environment variable is required to be true. Requires SERVICE_GATEWAY_REDIS_VOLATILE to be set.

true

HTTP_RATE_LIMIT_ENABLE

boolean

To enable the HTTP rate limit, this environment variable is required to be true.

false

HTTP_RATE_LIMIT_CONNECTIONS

number

Defines the maximum number of HTTP requests during a period. Defaults to 200 requests per window.

200

HTTP_RATE_LIMIT_WINDOW

number

Defines the time for which a record of requests should be kept in the memory (in seconds). The default duration of a window is 10 seconds.

10

ENABLE_HTTP_CACHE_CONTROL

boolean

To enable response caching, this environment variable is required to be true. This would include the Cache-Control header within the responses.

true

HTTP_CACHE_CONTROL_DIRECTIVES

string

The Cache-Control HTTP directive can be overridden with this environment variable.

public, max-age=10

CORS_ALLOWED_ORIGIN

string

Allows request from the comma-separated string of origins. By default, it is set to * which allows requests from all origins.

*

HTTP_RATE_LIMIT_ENABLE_X_FORWARDED_FOR

boolean

When set to true, the rate-limiting algorithm considers the X-Forwarded-For header value to determine the client’s IP address for rate-limiting purposes. By default, it is set to false.

false

HTTP_RATE_LIMIT_NUM_KNOWN_PROXIES

number

Defines the number of proxies that exist between the gateway and the external client application, enabling accurate identification of the client’s IP address for rate-limiting. Requires HTTP_RATE_LIMIT_ENABLE_X_FORWARDED_FOR to be enabled. By default, it is set to 0.

0

JOB_INTERVAL_UPDATE_READINESS_STATUS

number

Job run interval to update the readiness status. By default, it is set to 0.

0

JOB_SCHEDULE_UPDATE_READINESS_STATUS

string

Job run cron schedule to update the readiness status. By default, it is set to run every minute.

* * * * *

Sample Configurations
Example environment variables for the Gateway microservice
module.exports = {
  apps: [
  // Configuration for other microservices.
    {
      name: "klayr-service-gateway",
      // [...]
      env: {
        PORT: 9901,
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_GATEWAY_REDIS_VOLATILE: 'redis://klayr:[email protected]:6379/5',
        ENABLE_HTTP_API: 'http-status,http-version3,http-exports',
        ENABLE_WS_API: 'blockchain,rpc-v3',
        GATEWAY_DEPENDENCIES: 'indexer,connector',
        WS_RATE_LIMIT_ENABLE: false,
        WS_RATE_LIMIT_CONNECTIONS: 5,
        WS_RATE_LIMIT_DURATION: 1, // in seconds
        ENABLE_REQUEST_CACHING: true,
        JSON_RPC_STRICT_MODE: false,
        HTTP_RATE_LIMIT_ENABLE: false,
        HTTP_RATE_LIMIT_CONNECTIONS: 200,
        HTTP_RATE_LIMIT_WINDOW: 10, // in seconds
        HTTP_CACHE_CONTROL_DIRECTIVES: 'public, max-age=10',
        ENABLE_HTTP_CACHE_CONTROL: true,
        HTTP_RATE_LIMIT_ENABLE_X_FORWARDED_FOR: false,
        HTTP_RATE_LIMIT_NUM_KNOWN_PROXIES: 0,
        // ENABLE_REVERSE_PROXY_TIMEOUT_SETTINGS: true
        // HTTP_KEEP_ALIVE_TIMEOUT: 65000,
        // HTTP_HEADERS_TIMEOUT: 66000,
        // CORS_ALLOWED_ORIGIN: '*',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
        // JOB_INTERVAL_UPDATE_READINESS_STATUS: 0,
        // JOB_SCHEDULE_UPDATE_READINESS_STATUS: '* * * * *',
    },
  },
  // Configuration for other microservices.
  ],
};

Blockchain Connector

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

KLAYR_APP_WS

string

URL to connect with the Klayr application node over WebSocket. By default, it is set to ws://127.0.0.1:7887.

ws://127.0.0.1:7887

KLAYR_APP_HTTP

string

URL to connect with the Klayr application node over HTTP(s). By default, it is set to http://127.0.0.1:7887.

http://127.0.0.1:7887

USE_KLAYR_HTTP_API

boolean

Boolean flag to enable HTTP-API based connection to the Klayr application node.

true

USE_KLAYR_IPC_CLIENT

boolean

Boolean flag to enable IPC-based connection to the Klayr application node. Requires KLAYR_APP_DATA_PATH to be set.

true

KLAYR_APP_DATA_PATH

string

Data path to connect with the Klayr application node over IPC.

~/.klayr/klayr-core

GEOIP_JSON

string

URL of the GeoIP server.

GeoIP Server’s URL

GENESIS_BLOCK_URL

string

URL of the Klayr SDK-based application’s genesis block. Only to be used when the genesis block is large enough to be transmitted over API calls within the timeout.

Genesis block URL

ENABLE_BLOCK_CACHING

boolean

Boolean flag to enable block caching. Enabled by default. To disable it, set it to false.

true

EXPIRY_IN_HOURS

number

Expiry time in hours for block cache. By default, it is set to 12 hours.

12

CLIENT_POOL_SIZE

number

Number of active API clients to be maintained in the pool. Only applicable when using the IPC or WS clients to connect with the Klayr node. By default, it is set to 10.

10

WS_SERVER_PING_INTERVAL

number

Interval (in milliseconds) at which the WS server checks for liveliness of all the connected clients. This should not be modified unless explicitly recommended by the development team. By default, it is set to 3000.

3000

WS_SERVER_PING_INTERVAL_BUFFER

number

A conservative assumption of the latency (in milliseconds) for WS server pings to arrive at the client. By default, it is set to 1000.

1000

ENDPOINT_INVOKE_MAX_RETRIES

number

Maximum number of endpoint invocation request retries to the node. By default, it is set to 3.

5

ENDPOINT_INVOKE_RETRY_DELAY

number

Delay (in milliseconds) between each endpoint invocation request retry. By default, it is set to 1000.

1000

CONNECTOR_EXIT_DELAY_IN_HOURS

number

Delay (in hours) after which the blockchain-connector microservice exits. The service should restart automatically if deployed using Docker or PM2. To be removed eventually. To enable it, set it higher than 0. By default, it is set to 0.

0

JOB_INTERVAL_CACHE_CLEANUP

number

Job run interval to clean up block cache. By default, it is set to 0.

0

JOB_SCHEDULE_CACHE_CLEANUP

string

Job run cron schedule to clean up block cache. By default, it is set to run every 12 hours.

0 */12 * * *

JOB_INTERVAL_REFRESH_PEERS

number

Job run interval to refresh the peers' list. By default, it is set to run every 60 seconds.

60

JOB_SCHEDULE_REFRESH_PEERS

string

Job run cron schedule to refresh the peers' list. By default, it is set to an empty string ''.

Sample Configurations
Example environment variables for the Blockchain Connector microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: "klayr-service-blockchain-connector",
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        KLAYR_APP_WS: 'ws://127.0.0.1:7887',
        GEOIP_JSON: 'https://geoip.klayr.xyz/json',
        // ENABLE_BLOCK_CACHING: true,
        // EXPIRY_IN_HOURS: 12,
        // USE_KLAYR_IPC_CLIENT: true,
        // KLAYR_APP_DATA_PATH: '~/.klayr/klayr-core',
        // ENABLE_TESTING_MODE: false,
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
        // GENESIS_BLOCK_URL: 'https://downloads.klayr.xyz/klayr/mainnet/genesis_block.json.tar.gz',
        // JOB_INTERVAL_CACHE_CLEANUP: 0,
        // JOB_SCHEDULE_CACHE_CLEANUP: '0 */12 * * *',
        // JOB_INTERVAL_REFRESH_PEERS: 60,
        // JOB_SCHEDULE_REFRESH_PEERS: '',
      },
    },
    // Configuration for other microservices.
  ],
};

Blockchain Coordinator

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_MESSAGE_QUEUE_REDIS

string

URL of the Redis instance hosting the job queue to schedule the block indexing jobs. Must match the value supplied for the indexer microservice.

redis://klayr:[email protected]:6379/3

JOB_INTERVAL_INDEX_MISSING_BLOCKS

number

Job run interval to index missing blocks. By default, it is set to 0.

0

JOB_SCHEDULE_INDEX_MISSING_BLOCKS

string

Job run cron schedule to index missing blocks. By default, it is set to run every 5 minutes.

*/5 * * * *

Sample Configurations
Example environment variables for the Coordinator microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-blockchain-coordinator',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_MESSAGE_QUEUE_REDIS: 'redis://klayr:[email protected]:6379/3',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
        // JOB_INTERVAL_INDEX_MISSING_BLOCKS: 0,
        // JOB_SCHEDULE_INDEX_MISSING_BLOCKS: '*/5 * * * *',
      },
    },
    // Configuration for other microservices.
  ],
};

Blockchain Indexer

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_INDEXER_MYSQL

string

Connection string for the primary MySQL (read/write) instance that the microservice connects to.

mysql://klayr:[email protected]:3306/klayr

SERVICE_MESSAGE_QUEUE_REDIS

string

URL of the job queue to process the scheduled indexing jobs by the Blockchain Coordinator (Redis). Must match the value supplied for the coordinator microservice.

redis://klayr:[email protected]:6379/3

SERVICE_INDEXER_REDIS_VOLATILE

string

URL of the volatile cache storage (Redis).

redis://klayr:[email protected]:6379/2

ENABLE_DATA_RETRIEVAL_MODE

string

Boolean flag to enable the Data Service mode.

true

ENABLE_INDEXING_MODE

string

Boolean flag to enable the Data Indexing mode.

true

ENABLE_PERSIST_EVENTS

string

Boolean flag to permanently maintain the events in the MySQL database.

false

SERVICE_INDEXER_CACHE_REDIS

string

URL of the cache storage (Redis).

redis://klayr:[email protected]:6379/1

SERVICE_INDEXER_MYSQL_READ_REPLICA

string

Connection string for the replicated MySQL (read-only) instance that the microservice connects to.

mysql://klayr:[email protected]:3306/klayr

KLAYR_STATIC

string

URL of Klayr static assets.

https://static-data.klayr.xyz

JOB_INTERVAL_DELETE_SERIALIZED_EVENTS

number

Job run interval to delete serialized events. By default, it is set to 0.

0

JOB_SCHEDULE_DELETE_SERIALIZED_EVENTS

string

Job run cron schedule to delete serialized events. By default, it is set to run every 5 minutes.

*/5 * * * *

JOB_INTERVAL_REFRESH_VALIDATORS

number

Job run interval to refresh validators cache. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_VALIDATORS

string

Job run cron schedule to refresh validators cache. By default, it is set to run every 5 minutes.

*/5 * * * *

JOB_INTERVAL_VALIDATE_VALIDATORS_RANK

number

Job run interval to validate the rank for all the validators. By default, it is set to 0.

0

JOB_SCHEDULE_VALIDATE_VALIDATORS_RANK

string

Job run cron schedule to validate the rank for all the validators. By default, it is set to run every 15 minutes and starts at 4 minutes past the hour.

4-59/15 * * * *

JOB_INTERVAL_REFRESH_INDEX_STATUS

string

Job run interval to refresh indexing status. By default, it is set to run every 10 seconds.

10

JOB_SCHEDULE_REFRESH_INDEX_STATUS

string

Job run cron schedule to refresh indexing status. By default, it is set to an empty string ''.

JOB_INTERVAL_REFRESH_BLOCKCHAIN_APPS_STATS

number

Job run interval to refresh blockchain application statistics. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_BLOCKCHAIN_APPS_STATS

string

Job run cron schedule to refresh blockchain application statistics. By default, it is set to run every 15 minutes.

*/15 * * * *

JOB_INTERVAL_REFRESH_ACCOUNT_KNOWLEDGE

number

Job run interval to refresh account knowledge. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_ACCOUNT_KNOWLEDGE

string

Job run cron schedule to refresh account knowledge. By default, it is set to run every 15 minutes.

*/15 * * * *

JOB_INTERVAL_DELETE_FINALIZED_CCU_METADATA

number

Job run interval to delete finalized CCU metadata. By default, it is set to 0.

0

JOB_SCHEDULE_DELETE_FINALIZED_CCU_METADATA

string

Job run cron schedule to delete finalized CCU metadata. By default, it is set to run once a day at 02:00 am.

0 2 * * *

JOB_INTERVAL_TRIGGER_ACCOUNT_UPDATES

number

Job run interval to trigger account updates. By default, it is set to 0.

0

JOB_SCHEDULE_TRIGGER_ACCOUNT_UPDATES

string

Job run cron schedule to trigger account updates. By default, it is set to run every 15 minutes.

*/15 * * * *

ESTIMATES_BUFFER_BYTES_LENGTH

number

Transaction buffer bytes to consider when estimating the transaction fees. By default, it is set to 0.

0

ACCOUNT_BALANCE_UPDATE_BATCH_SIZE

number

Number of accounts for which the balance index is updated at a time. By default, it is set to 1000.

1000

INDEX_BLOCKS_QUEUE_SCHEDULED_JOB_MAX_COUNT

number

Maximum number of jobs (in active and waiting state) allowed in the block indexing queue. By default, it is set to 100000.

100000

MAINCHAIN_SERVICE_URL

string

Mainchain service URL for custom deployments.

https://service.klayr.xyz

INVOKE_ALLOWED_METHODS

string

List of allowed methods that can be invoked via the /invoke API endpoint. The list can be expressed as a CSV. To allow invocation of all endpoints, set it to *. To allow invocation of all the registered methods under the specified namespaces, set it similar to legacy,chain. To allow invocation of specific methods, set it similar to chain_getBlocksByIDs,chain_getBlocksByHeight.

*, legacy,chain, chain_getBlocksByIDs

Database snapshot configuration

To accelerate the indexing process, the blockchain-indexer microservice also supports automatic download and an application of a snapshot to the MySQL/MariaDB databases. The following environment variables in the table below can be used to configure the same.

Environment variable Datatype Description Sample

ENABLE_APPLY_SNAPSHOT

boolean

Enable or disable auto-apply snapshot feature. By default, the value is false.

false

DURABILITY_VERIFY_FREQUENCY

number

Frequency in milliseconds to verify if a block is indexed or rolled-back successfully. By default, it is set to 1.

1

INDEX_SNAPSHOT_URL

string

Custom snapshot download URL (expected to end with sql.gz).

https://snapshots.klayr.io/mainnet/service.sql.gz

ENABLE_SNAPSHOT_ALLOW_INSECURE_HTTP

boolean

Boolean flag to enable downloading the snapshot from an (unsecured) HTTP URL. By default, this is set to false.

false

Sample Configurations
Example environment variables for the Blockchain Indexer microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-blockchain-indexer',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_INDEXER_CACHE_REDIS: 'redis://klayr:[email protected]:6379/1',
        SERVICE_INDEXER_REDIS_VOLATILE: 'redis://klayr:[email protected]:6379/2',
        SERVICE_MESSAGE_QUEUE_REDIS: 'redis://klayr:[email protected]:6379/3',
        SERVICE_INDEXER_MYSQL: 'mysql://klayr:[email protected]:3306/klayr',
        ENABLE_DATA_RETRIEVAL_MODE: 'true',
        ENABLE_INDEXING_MODE: 'true',
        ENABLE_PERSIST_EVENTS: 'false',
        // ENABLE_APPLY_SNAPSHOT: 'false',
        // DURABILITY_VERIFY_FREQUENCY: 1,
        // INDEX_SNAPSHOT_URL: '',
        // ENABLE_SNAPSHOT_ALLOW_INSECURE_HTTP: 'true',
        // SERVICE_INDEXER_MYSQL_READ_REPLICA: 'mysql://klayr:[email protected]:3306/klayr',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: 'false',
        // SERVICE_LOG_STDOUT: 'true',
        // SERVICE_LOG_GELF: 'false',
        // SERVICE_LOG_FILE: 'false',
        // DOCKER_HOST: 'local',
        // MAINCHAIN_SERVICE_URL: 'https://service.klayr.xyz',
        // KLAYR_STATIC: 'https://static-data.klayr.xyz',
        // DEVNET_MAINCHAIN_URL: 'http://devnet-service.klayrdev.net:9901',
        // ESTIMATES_BUFFER_BYTES_LENGTH: 0,
        // ACCOUNT_BALANCE_UPDATE_BATCH_SIZE: 1000,
        // INDEX_BLOCKS_QUEUE_SCHEDULED_JOB_MAX_COUNT: 100000,
        // JOB_INTERVAL_DELETE_SERIALIZED_EVENTS: 0,
        // JOB_SCHEDULE_DELETE_SERIALIZED_EVENTS: '*/5 * * * *',
        // JOB_INTERVAL_REFRESH_VALIDATORS: 0,
        // JOB_SCHEDULE_REFRESH_VALIDATORS: '*/5 * * * *',
        // JOB_INTERVAL_VALIDATE_VALIDATORS_RANK: 0,
        // JOB_SCHEDULE_VALIDATE_VALIDATORS_RANK: '4-59/15 * * * *',
        // JOB_INTERVAL_REFRESH_INDEX_STATUS: 10,
        // JOB_SCHEDULE_REFRESH_INDEX_STATUS: '',
        // JOB_INTERVAL_REFRESH_BLOCKCHAIN_APPS_STATS: 0,
        // JOB_SCHEDULE_REFRESH_BLOCKCHAIN_APPS_STATS: '*/15 * * * *',
        // JOB_INTERVAL_REFRESH_ACCOUNT_KNOWLEDGE: 0,
        // JOB_SCHEDULE_REFRESH_ACCOUNT_KNOWLEDGE: '*/15 * * * *',
        // JOB_INTERVAL_DELETE_FINALIZED_CCU_METADATA: 0,
        // JOB_SCHEDULE_DELETE_FINALIZED_CCU_METADATA: '0 2 * * *',
        // JOB_INTERVAL_TRIGGER_ACCOUNT_UPDATES: 0,
        // JOB_SCHEDULE_TRIGGER_ACCOUNT_UPDATES: '*/15 * * * *',
      },
    },
    // Configuration for other microservices.
  ],
};

Blockchain application registry

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_APP_REGISTRY_MYSQL

string

Connection string of the MySQL instance that the microservice connects to.

mysql://klayr:[email protected]:3306/klayr

ENABLE_REBUILD_INDEX_AT_INIT

boolean

Boolean flag to truncate the index and rebuild at application init.

false

DEFAULT_APPS

string

Default blockchain applications. By default, it is set to klayr_mainchain.

klayr_mainchain

JOB_INTERVAL_DELETE_NON_METADATA_FILES

number

Job run interval to delete non-metadata files. By default, it is set to 0.

0

JOB_SCHEDULE_DELETE_NON_METADATA_FILES

string

Job run cron schedule to delete non-metadata files. By default, it is set to run every day at midnight.

0 0 * * *

JOB_INTERVAL_UPDATE_METADATA

number

Job run interval to update off-chain metadata. By default, it is set to 0.

0

JOB_SCHEDULE_UPDATE_METADATA

string

Job run cron schedule to update off-chain metadata. By default, it is set to run every 10 minutes.

*/10 * * * *

GITHUB_APP_REGISTRY_REPO

string

URL of app-registry GitHub repository.

https://github.com/KlayrHQ/app-registry

GITHUB_APP_REGISTRY_REPO_BRANCH

string

Relevant branch for app-registry GitHub repository.

main

Sample Configurations
Example environment variables for the Blockchain App Registry microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-blockchain-app-registry',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_APP_REGISTRY_MYSQL: 'mysql://klayr:[email protected]:3306/klayr',
        ENABLE_REBUILD_INDEX_AT_INIT: false,
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
        // GITHUB_APP_REGISTRY_REPO: 'https://github.com/KlayrHQ/app-registry',
        // GITHUB_APP_REGISTRY_REPO_BRANCH: 'main',
        // JOB_INTERVAL_DELETE_NON_METADATA_FILES: 0,
        // JOB_SCHEDULE_DELETE_NON_METADATA_FILES: '0 0 * * *',
        // JOB_INTERVAL_UPDATE_METADATA: 0,
        // JOB_SCHEDULE_UPDATE_METADATA: '*/10 * * * *',
      },
    },
    // Configuration for other microservices.
  ],
};

Fee estimator

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_FEE_ESTIMATOR_CACHE

string

URL of the cache storage (Redis).

redis://klayr:[email protected]:6379/1

ENABLE_FEE_ESTIMATOR_QUICK

boolean

Enable quick algorithm for fee estimation.

true

ENABLE_FEE_ESTIMATOR_FULL

boolean

Enable full algorithm for fee estimation.

false

FEE_EST_COLD_START_BATCH_SIZE

number

Defines the number of blocks that are analyzed during cold start.

1

FEE_EST_DEFAULT_START_BLOCK_HEIGHT

number

Defines the block height at which the dynamic fee estimation algorithm starts. By default, it starts at the genesis height in full mode and the current block height at the moment of application initialization in quick mode.

1

FEE_EST_EMA_BATCH_SIZE

number

Estimated moving average algorithm batch size.

20

FEE_EST_EMA_DECAY_RATE

number

Estimated moving average algorithm decay rate.

0.5

FEE_EST_WAVG_DECAY_PERCENTAGE

number

Estimated moving average algorithm weighted average decay percentage.

10

Sample Configurations
Example environment variables for the Fee Estimator microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-fee-estimator',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_FEE_ESTIMATOR_CACHE: 'redis://klayr:[email protected]:6379/1',
        ENABLE_FEE_ESTIMATOR_QUICK: true,
        ENABLE_FEE_ESTIMATOR_FULL: false,
        // FEE_EST_COLD_START_BATCH_SIZE: 1,
        // FEE_EST_DEFAULT_START_BLOCK_HEIGHT: 1,
        // FEE_EST_EMA_BATCH_SIZE: 20,
        // FEE_EST_EMA_DECAY_RATE: 0.5,
        // FEE_EST_WAVG_DECAY_PERCENTAGE: 10,
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
      },
    },
    // Configuration for other microservices.
  ],
};

Transaction statistics

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_STATISTICS_MYSQL

string

Connection string of the MySQL instance that the microservice connects to.

mysql://klayr:[email protected]:3306/klayr

SERVICE_STATISTICS_REDIS

string

URL of the cache storage (Redis).

redis://klayr:[email protected]:6379/1

TRANSACTION_STATS_HISTORY_LENGTH_DAYS

number

The number of days for which the transaction statistics need to be built in retrospect to the application init.

366

SERVICE_STATISTICS_MYSQL_READ_REPLICA

string

Connection string (read-only) of the replicated MySQL instance that the microservice connects to.

mysql://reader:[email protected]:3307/klayr

JOB_INTERVAL_REFRESH_TRANSACTION_STATS

number

Job run interval to refresh transaction statistics. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_TRANSACTION_STATS

string

Job run cron schedule to refresh transaction statistics. By default, it is set to run every 30 minutes.

*/30 * * * *

JOB_INTERVAL_VERIFY_TRANSACTION_STATS

number

Job run interval to verify if the transaction statistics have been built correctly. By default, it is set to 0.

0

JOB_SCHEDULE_VERIFY_TRANSACTION_STATS

string

Job run cron schedule to verify if the transaction statistics have been built correctly. By default, it is set to run every 3rd hour after the first 15 minutes.

15 */3 * * *

Sample Configurations
Example environment variables for the Transaction Statistics microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-transaction-statistics',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_STATISTICS_REDIS: 'redis://klayr:[email protected]:6379/1',
        SERVICE_STATISTICS_MYSQL: 'mysql://klayr:[email protected]:3306/klayr',
        TRANSACTION_STATS_HISTORY_LENGTH_DAYS: 366,
        // SERVICE_STATISTICS_MYSQL_READ_REPLICA: 'mysql://reader:[email protected]:3307/klayr',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
        // JOB_INTERVAL_REFRESH_TRANSACTION_STATS: 0,
        // JOB_SCHEDULE_REFRESH_TRANSACTION_STATS: '*/30 * * * *',
        // JOB_INTERVAL_VERIFY_TRANSACTION_STATS: 0,
        // JOB_SCHEDULE_VERIFY_TRANSACTION_STATS: '15 */3 * * *',
      },
    },
    // Configuration for other microservices.
  ],
};

Market

Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_MARKET_REDIS

string

URL of the cache storage (Redis).

redis://klayr:[email protected]:6379/2

SERVICE_MARKET_FIAT_CURRENCIES

string

Fiat currencies are used for price calculation. All Fiat currencies used here need to be comma separated.

EUR,USD,CHF,GBP,RUB

SERVICE_MARKET_TARGET_PAIRS

string

Exchange rates exposed to the Gateway. The values listed here must be comma separated.

LSK_BTC,LSK_EUR,BTC_CHF

EXCHANGERATESAPI_IO_API_KEY

string

Optional API key for https://exchangeratesapi.io/. The /market/prices endpoint will respond with additional data, specifically the exchange rates for various cryptocurrencies in other fiat currencies. The free plan would suffice for Klayr Service.

JOB_INTERVAL_REFRESH_PRICES_BINANCE

number

Job run interval to refresh prices from Binance. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_PRICES_BINANCE

string

Job run cron schedule to refresh prices from Binance. By default, it is set to run every minute.

* * * * *

JOB_INTERVAL_REFRESH_PRICES_BITTREX

string

Job run interval to refresh prices from Bittrex. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_PRICES_BITTREX

string

Job run cron schedule to refresh prices from Bittrex. By default, it is set to run every minute.

* * * * *

JOB_INTERVAL_REFRESH_PRICES_EXCHANGERATESAPI

string

Job run interval to refresh prices from exchangeratesapi. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_PRICES_EXCHANGERATESAPI

string

Job run cron schedule to refresh prices from exchangeratesapi. By default, it is set to run every minute.

* * * * *

JOB_INTERVAL_REFRESH_PRICES_KRAKEN

string

Job run interval to refresh prices from Kraken. By default, it is set to 0.

0

JOB_SCHEDULE_REFRESH_PRICES_KRAKEN

string

Job run cron schedule to refresh prices from Kraken. By default, it is set to run every minute.

* * * * *

JOB_INTERVAL_UPDATE_PRICES

string

Job run interval to update market prices. By default, it is set to run every 5 seconds.

5

JOB_SCHEDULE_UPDATE_PRICES

string

Job run cron schedule to update market prices. By default, it is set to an empty string ''.

Sample Configurations
Example environment variables for the Market microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-market',
      // [...]
      env: {
        // --- Remember to set the properties below
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_MARKET_REDIS: 'redis://klayr:[email protected]:6379/2',
        SERVICE_MARKET_FIAT_CURRENCIES: 'EUR,USD,CHF,GBP,RUB,PLN,JPY,AUD,GBP,INR',
        SERVICE_MARKET_TARGET_PAIRS: 'LSK_BTC,LSK_EUR,LSK_USD,LSK_CHF,LSK_PLN,LSK_JPY,LSK_AUD,LSK_GBP,LSK_INR,BTC_EUR,BTC_USD,BTC_CHF',
        // EXCHANGERATESAPI_IO_API_KEY: ''
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: false,
        // SERVICE_LOG_STDOUT: true,
        // SERVICE_LOG_GELF: false,
        // SERVICE_LOG_FILE: false,
        // DOCKER_HOST: 'local',
        // JOB_INTERVAL_REFRESH_PRICES_BINANCE: 0,
        // JOB_SCHEDULE_REFRESH_PRICES_BINANCE: '* * * * *',
        // JOB_INTERVAL_REFRESH_PRICES_BITTREX: 0,
        // JOB_SCHEDULE_REFRESH_PRICES_BITTREX: '* * * * *',
        // JOB_INTERVAL_REFRESH_PRICES_EXCHANGERATESAPI: 0,
        // JOB_SCHEDULE_REFRESH_PRICES_EXCHANGERATESAPI: '* * * * *',
        // JOB_INTERVAL_REFRESH_PRICES_KRAKEN: 0,
        // JOB_SCHEDULE_REFRESH_PRICES_KRAKEN: '* * * * *',
        // JOB_INTERVAL_UPDATE_PRICES: 5,
        // JOB_SCHEDULE_UPDATE_PRICES: '',
      },
    },
    // Configuration for other microservices.
  ],
};

Export

The EXPORT_S3_* variables should only be configured when using AWS S3 instead of a local file system. For the local file system, use SERVICE_EXPORT_PARTIALS and SERVICE_EXPORT_STATIC variables.
Environment variable Datatype Description Sample

SERVICE_BROKER

string

URL of the microservice message broker (NATS or Redis).

redis://klayr:[email protected]:6379/0

SERVICE_EXPORT_REDIS

string

URL of the permanent cache storage (Redis).

redis://klayr:[email protected]:6379/3

SERVICE_EXPORT_REDIS_VOLATILE

string

URL of the volatile cache storage (Redis).

redis://klayr:[email protected]:6379/4

SERVICE_EXPORT_PARTIALS

string

Local filepath where the partial (per day) transaction history files for a specified account are temporarily cached.

./data/partials

SERVICE_EXPORT_STATIC

string

Local filepath where the aggregated transaction history files, as requested by the user are stored.

./data/static

EXPORT_S3_ENDPOINT

string

Amazon S3 bucket endpoint.

s3.amazonaws.com

EXPORT_S3_ACCESS_KEY

string

Amazon S3 bucket access key for the specified endpoint.

EXPORT_S3_SECRET_KEY

string

Amazon S3 bucket secret key.

EXPORT_S3_SESSION_TOKEN

string

Amazon S3 bucket session token.

EXPORT_S3_REGION

string

The region where Amazon S3 bucket is hosted. Optional.

eu-central-1

EXPORT_S3_BUCKET_NAME

string

Amazon S3 bucket name. Optional.

export

EXPORT_S3_BUCKET_NAME_PARTIALS

string

Amazon S3 bucket where the partial (per day) transaction history files for a specified account are temporarily cached.

partials

EXPORT_S3_BUCKET_NAME_STATIC

string

Amazon S3 bucket where the aggregated transaction history files, as requested by the user are stored.

exports

EXPORT_S3_BUCKET_NAME_EXPORTS

string

Amazon S3 bucket where the aggregated transaction history files, as requested by the user are stored.

exports

JOB_INTERVAL_CACHE_PURGE

number

Job run interval to clean up cache. By default, it is set to 0.

0

JOB_SCHEDULE_CACHE_PURGE

string

Job run cron schedule to clean up the cache. By default, it is set to run daily at 04:45 am.

45 4 * * *

Sample Configurations
Example environment variables for the Export microservice
module.exports = {
  apps: [
    // Configuration for other microservices.
    {
      name: 'klayr-service-export',
      // [...]
      env: {
        SERVICE_BROKER: 'redis://klayr:[email protected]:6379/0',
        SERVICE_EXPORT_REDIS: 'redis://klayr:[email protected]:6379/3',
        SERVICE_EXPORT_REDIS_VOLATILE: 'redis://klayr:[email protected]:6379/4',
        // SERVICE_EXPORT_PARTIALS: './data/partials',
        // EXPORT_S3_BUCKET_NAME_PARTIALS: 'partials',
        // SERVICE_EXPORT_STATIC: './data/static',
        // EXPORT_S3_BUCKET_NAME_EXPORTS: 'exports',
        // SERVICE_BROKER_TIMEOUT: 10,
        // SERVICE_LOG_LEVEL: 'info',
        // SERVICE_LOG_CONSOLE: 'false',
        // SERVICE_LOG_STDOUT: 'true',
        // SERVICE_LOG_GELF: 'false',
        // SERVICE_LOG_FILE: 'false',
        // DOCKER_HOST: 'local',
        // EXPORT_S3_ENDPOINT: 's3.amazonaws.com',
        // EXPORT_S3_ACCESS_KEY: '',
        // EXPORT_S3_SECRET_KEY: '',
        // EXPORT_S3_SESSION_TOKEN: '',
        // EXPORT_S3_REGION: 'eu-central-1',
        // EXPORT_S3_BUCKET_NAME: 'export',
        // JOB_INTERVAL_CACHE_PURGE: 0,
        // JOB_SCHEDULE_CACHE_PURGE: '45 4 * * *',
      },
    },
  ],
};