Indexing Storage Change

The @indexStorageChange decorator can be used to mark an indexer method that will be listening for storage changes on a contract.

When a storage change is detected on an indexed contract, the method will be invoked with detailed information about the change.

Parameters

The following parameters will be passed to the indexing method:

Example

The following code will print the value of the property foo every time the contract has new storage:

interface MyContractChangedStorage {
    foo: string;
}

export class MyContractIndexer {
    @indexStorageChange()
    async indexStorageChange(
        newStorage: MyContractChangedStorage,
        dbContext: DbContext,
        indexingContext: StorageChangeIndexingContext,
    ): Promise<void> {
        console.log(newStorage.foo);
    }
}

Last updated