Configuring a Plugin

The HelloInfoPlugin should sync on-chain events data with the off-chain database after a configured time interval.

On this page, you’ll learn:

  • Defining configuration for a plugin.

  • Overwriting default configuration.

The relevant files discussed in this guide are schemas.ts, types.ts, and custom_config.json.

1. Defining a sync interval configuration

A plugin is capable of having its own set of configurations, and since we aim for our plugin to sync with on-chain data at specific intervals, having a config will be beneficial.

We will use a syncInterval variable in our HelloInfoPlugin class so, let’s define that in the types.ts file.

// [...]

export interface HelloInfoPluginConfig {
    syncInterval: number;

After that, Open the schemas.ts file and define configSchema there. It will have an integer-type property: syncInterval. It’s essential to define a default value to the syncInterval in milliseconds as well.

export const configSchema = {
	$id: '/plugins/helloInfo/config',
	type: 'object',
	properties: {
		syncInterval: {
			type: 'integer',
	required: ['syncInterval'],
	default: {
		syncInterval: 120000, // milliseconds

2. Overwrite default sync interval

The aforementioned type and schema definition are enough for our plugin to function, however, there may be an optional case where a node operator wants to increase or decrease the time of sync interval so, for that, they can add it in the custom_config.json file under the plugins property.

If a value is available in the custom_config.json for the syncInterval, the plugin will automatically consider that value and overwrite the default value for interval synchronization.

// [...]
"plugins": {
    "helloInfo": {
        "syncInterval": 60000

Now that we have added Plugin’s configuration, it’s time to update the HelloInfoPlugin class as described in the next guide.