♠️
RACE Protocol
NFT PresaleDiscord
  • ❤️Official Docs & Links
  • ⏳Progress Overview
  • RACE Protocol
    • 🏗️System Architecture
      • Components
      • On-chain Accounts
      • Synchronization
      • Randomization
      • Payment
    • 🎲Game Development
      • Game Handler
      • Effect
      • Event Handling
      • Race API
        • Arweave Integration
      • Race JS SDK
        • Installation and Setup
        • Key Components
          • AppClient
          • SubClient
          • Events
          • Game Context
          • Decryption Cache
        • Advanced Features
          • Getting Revealed Knowledge
          • Exiting and Detaching
          • Submitting Messages
          • Sub-game Interaction
        • Best Practices
        • API Reference
        • Troubleshooting
    • 🧪Testing
      • Race Test Kit
      • Unit Testing
      • Integration Testing
      • Additional Considerations
    • 🧱Modules & Features
      • Encryption Methods
      • Command-line Tools
      • Configuration Options
      • Blockchain Transport Implementations
    • 📃Smart Contract
      • Solana Program
    • 🔦Examples and Use Cases
      • Draw Card Game
      • Raffle Game
      • Other Examples
  • RACE Games
    • ♠️RACE Poker app
      • 🎮Start playing in minutes
        • 💰Cash and sit-n-go
        • 🏆Tournaments
      • 🎨Workshop
        • 🏆Create cash games
        • 🏨Create tourneys
      • 💡Concept introduction
      • 🏗️System architecture
      • 👾Game Flow
      • 🎲Cards shuffling
      • ☎️Communication
      • 🔐Key sharing/decryption
      • 💱Cash flow structure
    • ⚡Solfast
      • 🎲Game modes
  • RACE RESEARCH
    • 👾No-Code Development
      • Brainstorming
      • Implementation Approach
      • Project Status
    • 0️⃣Zero-Knowledge Proofs
      • Brainstorming
      • Integration steps
        • Verifiable Randomness Generation
        • Private Game State Updates
        • Verifiable Settlements
        • Private Player Actions
      • Project Status
    • 🛡️Security Audit Report
      • Executive summary
        • Introduction to Race Protocol
        • Audit Methodology
      • Findings
        • Smart Contract Security
        • WebAssembly Security
        • Client-side Security (Race SDK)
        • Server-side Security
        • Randomization and Encryption
        • On-chain Account Management
        • Synchronization Mechanisms
        • Payment Handling
      • Recommendations
      • Conclusion
  • RACE DAO
    • 😎About
    • 🫂Community
    • 🖼️NFT Collection [!]
Powered by GitBook
On this page
  • Using the getRevealed Function
  • Code Examples for Utilizing Revealed Information
  1. RACE Protocol
  2. Game Development
  3. Race JS SDK
  4. Advanced Features

Getting Revealed Knowledge

Using the getRevealed Function

In games with hidden information, the game handler may reveal certain elements of the game state to players at specific points in the game. This is typically done by sharing secret keys that allow players to decrypt the hidden information.

The RACE JS SDK provides the getRevealed function in both the AppClient and SubClient classes to access this revealed knowledge. The function takes the randomness ID as an argument. This ID is associated with the randomness generation process used to create the hidden information. The function then returns a map containing the decrypted values associated with that randomness.

Code Examples for Utilizing Revealed Information

Here's an example of using the getRevealed function to access and display revealed information in the game UI:

// Assuming client is an initialized AppClient or SubClient instance

const randomId = 1; // Replace with your randomness ID

const revealed = await client.getRevealed(randomId);

// Iterate over the revealed values and update the UI accordingly
for (const [index, value] of revealed) {
  // Example: Displaying revealed cards in a card game
  if (index === 0) {
    const playerCardElement = document.getElementById('playerCard');
    playerCardElement.innerHTML = value; // Display the card value
  }
}

This code snippet demonstrates how the getRevealed function can be used to retrieve decrypted information and update the game UI to reflect the revealed knowledge. The specific way you utilize the revealed information will depend on the nature of your game and its mechanics.

By using the getRevealed function, developers can ensure that players have access to the complete game state when necessary and can make informed decisions based on the revealed information.

PreviousAdvanced FeaturesNextExiting and Detaching

Last updated 1 year ago

🎲