Updated 3 days ago

Sphere Quiz

SphereQuiz innovatively combines off-chain and on-chain game

  • Crypto / Web3
  • DeFi
  • GameFi
  • EDU

SphereQuizGame

SphereQuizGame innovatively combines off-chain and on-chain elements, offering a unique gaming experience where characters' strength is influenced by players' EDU Chain activity and ETH holdings. The game features quizzes, sphere-matching for HP recovery, and NFT keys for opening treasure chests. As players progress, enemy strength increases based on collected ETH. SphereQuizGame exemplifies crypto gamification, providing an immersive experience that showcases the allure of cryptocurrency.

Play the demo

[User Flow] Very simple!!

  1. 🎁 New Round(Chest key is decided by randomness)

  2. 😎 User Start Game

  3. 👛 Connect wallet to EDU Chain and Load player character parameters (Hp, Attack)

  4. 🎓 Proceed through stages (Quiz/Sphere)

  5. ⚡️ Beat the boss

  6. 🔑 Mint your NFT key

--- Go back to 1.

  1. 🎉 (if you are lucky), you can open ETH Treasure Chest 🎁 by your keys 🔑
  2. 🏯 (if someone successfully opens the chest), all keys are burned, and a new round starts.

What On-chain/Off-chain?

In the off-chain game, players use three fixed characters to battle enemies while answering quizzes. The strength of the characters varies based on the state of the EDU Chain. Specifically, the attack power is influenced by factors like the gas price of the player's latest transaction, the number of transactions in the last 7 days, and the proximity of the latest transaction's block number to the current block number.

The characters' HP is determined by the amount of ETH held by the player. Players with a larger amount of ETH can have higher HP, giving them an advantage in progressing through the game.

The off-chain game also includes a sphere-matching part where players can recover HP by connecting three or more spheres of the same color. This adds a strategic element to the game.

In the on-chain part, players can acquire an NFT after clearing the game. The NFT serves as a key, and only players with the corresponding key can open a treasure chest containing the ETH collected within the game. The strength of the enemies increases based on the amount of ETH collected, providing a more challenging gaming experience.

Architecture

Data Feed

Retrieve player parameters from EDU Chain data sources:

async getPlayerParameters(address) {
  try {
    const { hp, attack } = await fetchPlayerParametersFromEDUChain(address);
    return { hp, attack };
  } catch (error) {
    console.error('Error fetching player parameters:', error);
    return { hp: 100, attack: 10 };
  }
}

Battle End

Calculate the final score based on ETH collected and HP remaining:

calculateFinalScore(hp, ethCollected) {
  return (hp * 0.1) + (ethCollected * 2);
}

Contract

contract contract address
SphereQuizGameNFT EDU Chain Contract Address

Tech Stack

Covalent

To fetch the latest transaction for a specific address on EDU Chain, we use the getAllTransactionsForAddress method:

let latestTransaction = null;
for await (const resp of client.TransactionService.getAllTransactionsForAddress(
  "edu-chain",
  address,
  { "noLogs": true, "blockSignedAtAsc": false }
)) {
  latestTransaction = resp;
  break;
}

The Graph

Retrieve the top score using The Graph on EDU Chain:

query {
  mintKeyEvents(orderBy: score, orderDirection: desc, first: 1) {
    score
  }
}

ChainLinkDataFeed

Retrieve attack parameters from the Data Feed contract:

async getAttackParameters() {
  try {
    const { baseAttackPower, adjustedVolatility, overallAttackParameter } = await getAttackParametersFromContract();
    return { baseAttackPower, adjustedVolatility, overallAttackParameter };
  } catch (error) {
    console.error('Error getting attack parameters:', error);
    return { baseAttackPower: 20, adjustedVolatility: 25, overallAttackParameter: 0.8 };
  }
}

Acknowledgments

Feature Works

  • QuizData should be private
  • Launch to EDU Chain Mainnet