Haste Arcade SDK Documentation

website·Indexed 32 days ago

https://docs.hastearcade.com

Developer documentation for the Haste Arcade SDK, a client-side integration for showcasing games and managing blockchain payments. Includes guides on authentication, game registration, SDK installation, and publishing.

Tokens
2K
Snippets
14
Records
18
Agent score
50%

What's inside Haste Arcade

  1. Overview of Haste Arcade SDK features

    The Haste Arcade SDK allows game developers to integrate blockchain technology and monetize their games. Key capabilities include:

    • Easy Integration: A lean set of methods for game clients to interact with the arcade, typically requiring only a few hours for full integration.
    • HST Token Integration: Support for HST, the arcade's native utility token used for accessing games, exclusive features, and as a currency for players and developers.
    • Web3 Privacy: Integration with the open-source Yours Wallet, ensuring player and developer personal information remains private.
    • Monetization: Tools to monetize games by requiring HST payments for access or creating in-game asset stores.
  2. Run the Haste Arcade example game integration

    To quickly test the Haste Arcade integration, you can use the provided example repository. This allows you to see how the SDK interacts with the arcade environment via an iFrame and browser console logs.
    # 1. Clone the example repository
    git clone https://github.com/hastearcade/sdk-game-example
    # 2. Follow the README.md in the repo to run the game locally
  3. Install the Haste Arcade SDK

    The Haste Arcade SDK is a client-side integration that allows games to communicate with the arcade host (which displays the game in a full-width/height iFrame) without requiring server-side components.
    npm i haste-arcade-sdk
  4. Transition from test environment to production

    After successfully verifying your game integration in the demo app, complete the following steps to move to production:

    1. Create an API key for authentication.
    2. Register your game to generate a production gameId (replace the test ID in GameService).
    3. Update your production domain in the game registration settings.
    4. Notify Haste Arcade when the game is ready to publish.
  5. Test a local game in the Haste Arcade dev environment

    You can test your locally served game by loading it into the Haste Arcade developer portal using a specific URL format. The src query parameter must match the local address where your game is being served (e.g., http://localhost:1234).

    Test URL Format: https://dev.hastearcade.com?gameId={gameId}&src={your_local_url}

    https://dev.hastearcade.com?gameId=f8c22e6c-1086-4529-8800-2c72f98b9915&src=http://localhost:1234
  6. Set up a Yours Wallet for Haste Arcade integration

    To connect to the arcade, both players and developers must use a Yours Wallet. The wallet replaces traditional email/password accounts and is used to approve and broadcast blockchain transactions and sign messages. Install the Yours Wallet browser extension to create a wallet and authenticate with the arcade.
  7. Configure GameService for the test environment

    When integrating the SDK into a game for testing in the Haste Arcade dev environment, use the provided test gameId when instantiating the GameService. Note that in this environment, database records are not created and responses from the arcade are static mock data.
    // Use this gameId only for the test environment
    const gameService = new GameService('f8c22e6c-1086-4529-8800-2c72f98b9915');
  8. Register a new game to obtain a gameId

    To generate a gameId, you must register your game using a POST request to the /game/create endpoint. You can register multiple games using a single API key. The request requires a game name, description, cover image URL (1920x1080, 16:9 aspect ratio), and a score display preference.
    curl -X POST https://api.hastearcade.com/game/create \
    -H "Content-Type: application/json" \
    -H "api-key: your-api-key-here" \
    -d '{
        "name": "My New Game",
        "description": "An exciting puzzle game with challenging levels.",
        "coverUrl": "http://example.com/cover.jpg",
        "scoreDisplay": "NORMAL"
    }'
  9. Submit game scores to the arcade

    Use submitScore(playId, score) when a user finishes a game. The user will be prompted to sign a message with their wallet to manually submit the score. You can use the returned promise or listen for the score event.
    // Option 1: Using async/await
    const res = await game.submitScore(playId, score);
    console.log(res.playId);
    
    // Option 2: Using event listener
    game.submitScore();
    game.on("score", (message: ReceiveSubmitScoreMessage) => {
        console.log(message.playId);
    });