SDK
The Haste Arcade SDK is a client-side integration that does not require server-side components, simplifying the setup process. The platform displays your registered game in a full-width and full-height iFrame, facilitating seamless communication between the host client (arcade) and your game.
Installation
npm i haste-arcade-sdkInit()
Import and create a new instance of the GameService. Once the DOM is loaded, initialize it.
import { GameService, Origin } from "haste-arcade-sdk";
const game = new GameService(
"f8c22e6c-1086-4529-8800-2c72f98b9915", // your gameId
Origin.DEV, // this is the host (arcade) origin. Use DEV or PROD
);
// Ensure that the DOM is loaded before calling the init method
document.addEventListener("DOMContentLoaded", function () {
game.init();
});
// This may be implemented differently depending on your game's framework.Play()
Your game must include a "Play" or "Start" button to initiate gameplay. Upon clicking this button, a message will be sent to the arcade, prompting it to request that the user lock some HST into a smart-contract to begin playing.
submitScore()
When the user has finished playing the game, call the submitScore() method and pass in the playId and score. The user will will sign a message with their wallet and manually submit their score. No need to listen for messages for score submissions.
getLeaderboard()
If you'd like to display the current leaderboard directly in your game, the SDK makes this simple.
transferHst()
Monetize your game with HST transfers by requesting payment from within your game. Simply pass in the amount of HST to transfer.
Last updated