Instantiate New Quest

Configure a New Quest.

Instantiate a new Quest with your Quest details, specify the maximum number of players that can join a Quest and configure your Milestone and Token Gated Logic.

Set the factoryId to 0 to create a new Kinora Factory instantiation. This will deploy your custom suite of the KinoraAccessControls, KinoraEscrow, KinoraMetrics, KinoraNFTCreator and KinoraQuestData contracts.

If you already have instantiated contracts from the factory suite, set your factoryId to create more quests within this suite. You can verify, add and remove additional wallet addresses as whitelisted envokers within your suite.

const { postId, factoryId, questId, transactionHash, error, errorMessage, factoryAccessControls, factoryEscrow, factoryQuestData, factoryMetrics, factoryNFTCreator } = await newEnvoker.instantiateNewQuest({
  factoryId: 0,
  questDetails: {
    title: "Chromadin Chronicle",
    description:
      "Engage in a Chromadin video binge session for Season 1 and Season 2 of The Dial Pirate Radio . Interactions, mirrors and comments on episodes accrue bonus points.",
    cover: "ipfs://QmQk9TqFivUqc6ktosoZVVih9o1uiY3r5Z7F3GCC1FpaJS",
  },
  maxPlayerCount: 100,
  milestones, // see Milestones for struct configuration
  joinQuestTokenGatedLogic: tokenGatedLogic // see Token Gated Logic for struct configuration
});

Instantiate Quest Props

/* The Factory Id. Set to 0 for instantiating a new Kinora Factory instance, otherwise specify the Id that you are a verified envoker for.*/
factoryId: number;

/* The Quest details struct. The description and cover will be shown within the Lens Post across Lens interfaces. */
questDetails: { title: string; description: string; cover: `ipfs://${string}` };

/* The max number of unique players that can join the quest */
maxPlayerCount: number;

/* Factory Access Controls Contract. */
factoryAccessControls: `0x${string}`; 
 
/* Factory Escrow Contract. */
factoryEscrow: `0x${string}`; 

/* Factory Quest Data Contract. */
factoryQuestData: `0x${string}`; 

/* Factory Metrics Contract. */
factoryMetrics: `0x${string}`; 

/* Factory NFT Creator Contract. */
factoryNFTCreator: `0x${string}`;

/* All milestones within the Quest. See Milestone struct details for how to configure. */
milestones: Milestone[];

/* Token Gated logic for joining the Quest. See Token Gated Logic for struct configuration. */
joinQuestTokenGatedLogic: GatingLogic;

/* (Optional) Wallet instance for Polygon Network. If you have passed the wallet object to the constructor, it is not necessary here. */
wallet?: ethers.Wallet;

/* (Optional) Set to true to approve ERC20 reward tokens to be transfered to the KinoraEscrow contract through the SDK. If set to false, ensure to approve your token spend with the KinoraOpenAction Contract before calling instantiateNewQuest. */
approveRewardTokens?: ethers.Wallet;

Response Object

Token Gated Logic

Every Quest and its subsequent Milestones may be configured with optional Token-Gated Logic.

This logic verifies if a player possesses the specified configuration of ERC721 and/or ERC20 tokens on Polygon Mainnet in their wallet, determining their eligibility to join a Quest and meet completion requirements for Milestones.

Ensure that the length of your ERC20 Addresses array aligns with that of your ERC20 Thresholds array, with corresponding indices. Likewise, ensure alignment between your ERC721 Addresses and ERC721 Token IDs and/or ERC721 Token URIs, should IDs or URIs be specified. If no Token IDs or Token URIs are specified at a given index (i.e., an empty array is input), then all Token IDs for that contract will be accepted.

Gated Logic Props

Milestones

Configure the reward and eligibility requirements for each Milestone within your Quest. You can specify as many Milestones as you like per Quest.

For a player to be eligible to complete a Milestone, you can specify both Token Gated Logic for the Milestone as well as video metric thresholds.

Milestone Props

Milestone Eligibility

Milestone eligibility specifies the video metric criteria for each video within a milestone.

Milestone Eligibility Props

PlaybackCriteria Props

All numerical playback props signify threshold minimums that a player must achieve for the respective video, if nothing is set the threshold defaults to 0. For boolean values, if it is set as false or not inputted, it is ignored as criteria.

Milestone Reward

To encourage players towards Milestone completion, rewards are allocated in the form of either ERC20 or ERC721 tokens, which players can claim upon completion. Multiple rewards can be set per Milestone.

The specified ERC20 tokens and their amounts must be contained in your wallet, as they are sent to the Kinora Escrow contract at the point of Quest instantiation, ensuring that players will receive their rewards.

The amount sent to the Escrow contract is the amount specified for each Milestone multiplied by the maximum player count. For example if the Quest specifies a Maximum of 20 players and a Milestone ERC20 reward of 10 wei, then 20 x 10 wei will be sent to the Escrow contract to cover all Players.

Players can only withdraw and claim these tokens upon meeting the established milestone eligibility and being verified by the envoker through the setPlayerEligibleToClaimMilestone function. An emergency admin withdraw function is incorporated, which, when triggered, terminates the Quest and precludes players from continuing, as their rewards will no longer reside within the Escrow contract.

In the case of ERC721 rewards, you need to specify the token URI intended for the Milestone reward NFT. Upon valid achievement of a milestone, players will be eligible to mint the NFT from the Kinora NFT Creator contract.

Reward Props

Last updated