Send Metrics On-Chain

Log Player Metrics & Automate On-Chain Signing.

Everytime a Player interacts with a configure video in the application, wrapped with the KinoraPlayerWrapper and utilizing the Livepeer React Player, their live metrics are stored and logged, and can be retrieved and displayed on your interface.

Each time a player engages with a configured video within your application, their interactions are captured in real-time. This is made possible through the KinoraPlayerWrapper, and Livepeer React Player. These live metrics can be called in real time and displayed on your interface using the getLiveVideoMetrics helper function specified in Helpers.

Players have the discretion to upload these engagement metrics onto the blockchain for any specific video post. When sent on-chain, their interactions contribute meaningfully towards any ongoing quests. These metrics are also cumulative, where when a player interacts with a video that's linked to a Lens post and is relevant to multiple quests, their activity is concurrently logged across all quests associated with that video.

In scenarios where identical videos are featured in multiple areas of your application, ensure that the correct postId is consistently assigned to the wrapper for each video. This allows for amassing video metrics on an application-wide level.

Note that only players who have previously joined a Quest with Kinora are verified for metric logging, as they would have undergone verification to create their Player profile with the contract. You can query the KinoraQuestData Contract to verify whether a Player has a valid profile or not with Kinora.

import { Kinora } from "kinora-sdk";

const kinora = Kinora.getInstance(apolloClient);

const collectAndSendMetrics = async () => {
      // signer object of the Player
      await (window as any).ethereum.request({ method: "eth_requestAccounts" });
      const provider = new ethers.providers.Web3Provider(
        (window as any).ethereum,
      const signer = provider.getSigner();

      // send metrics on-chain
      const { txHash, error, errorMessage } = await kinora.sendPlayerMetricsOnChain(
        signer as ethers.Wallet,

Send Metrics On-Chain Props:

/* Enter the Video postId related to the metrics to be sent on-chain. */
postId: `0x${string}`;

/* Enter the Player's Lens Profile Id. */
playerProfileId: `0x${string}`;

/* Wallet instance for the Player on Polygon Network. */
wallet: ethers.Wallet;

/* Instantiated Kinora Metrics Contract. */
kinoraMetricsContractAddress: `0x${string}`;

/* Instantiated Kinora Quest Data Contract. */
kinoraQuestDataContractAddress: `0x${string}`;

Result Object:

/* The txHash for sending metrics on-chain. */
txHash?: `0x${string}`;

/* Boolean to indicate whether an error was encountered during sending the metrics. */
error: boolean;

/* Message of the encountered error. */
errorMessage?: string;

Last updated