Function listenForEvent

  • Listens for an event and calls a callback when it is triggered.

    Example

    // Assuming you have a valid ApiPromise instance (api)
    // and a callback function (callback)
    await listenForEvent(api, "ProposalExecution", (data) => {
    console.log("ProposalExecution", data);
    const dataEvent = data as {
    depositNonce: string;
    dataHash: string;
    };
    console.log("ProposalExecution event is emmited. Transfer is finished")
    console.log(dataEvent)
    });

    Returns

    A promise that resolves when the event is triggered.

    Parameters

    • api: ApiPromise

      An ApiPromise instance.

    • eventName: string

      The name of the event to listen for.

    • callback: ((data: AnyJson) => void)

      The function to call when the event is triggered.

        • (data: AnyJson): void
        • Parameters

          • data: AnyJson

          Returns void

    Returns Promise<undefined | (() => void)>

Generated using TypeDoc