Developer DocumentationPlaykit Integration
What Forest Playkit is, how it's structured, and the core concepts for developers.
Forest Playkit is your toolkit for building HTML games and apps that live natively inside Forest Protocol.
Your app runs inside an iframe on the token page and communicates with Forest through browser postMessage calls. With Playkit you can read the connected wallet, request swap quotes, submit swaps through the user's wallet, and tap into player-scoped game APIs. No package to install. No build step required.
New here? Start with the Quickstart — you'll have a working bridge and your first call running in minutes. This page covers the mental model behind it.
Building with an AI agent?
Install the Forest AI skill so Claude Code,
Cursor, Codex, and other agents write correct Playkit code — npx skills add Forest-Protocol/forest-skills.
Code examples
Throughout these docs:
The two surfaces
Every integration is split across two trust boundaries. Keep them straight and the rest of the SDK follows.
Forest sits between the two: it mediates wallet actions for the iframe and verifies your backend's signed requests.
Three different pools of value — do not conflate them:
| Concept | What it is |
|---|---|
| Wallet-held Project Token | Tokens in the player's own wallet. Buying gives them these; it does not add Game Balance. |
| Game Balance | A per-player internal ledger Forest debits/credits through walletless Game Actions. |
| Game Vault | The project's payout capacity. Separate from any player; funds winnings. Creator-funded. |
How value moves between them:
This trips people up, so it is the single rule to remember:
"1", "0.25", or "1000.5". No wei/base-unit values, commas, token symbols, or unit suffixes.Both sides must be the same economic value
When a backend signs an amount that the iframe also passed, the two must represent the same economic value: display units in the SDK call, base-unit integer in the signed body.
Never use the iframe wallet address for identity
Forest sends the connected wallet address to the iframe for display only. Once it reaches your HTML it is a plain string the player can rewrite, so:
Game Balance and Game Actions cover Forest's economic ledger — debits, credits, and settlement. They do not cover everything else your game needs to remember: match history, player stats, inventories, cosmetics, or a leaderboard. For that, you need your own live database.
Keep it on your trusted backend, not in the iframe
Your HTML game already talks to a trusted backend to sign settlements (see Game Actions). That same backend should hold your database connection string. The iframe is untrusted — never put credentials or queries in it.
A typical leaderboard flow:
HTML game
-> forest.game.action.authorize({ actionId, debitLimitAmount })
-> your backend validates the gameplay result
-> your backend signs and submits the settlement to Forest
-> your backend writes the result to your own database (score, playerId, timestamp)
-> HTML game reads the leaderboard from your backend's APIKey the data by the verified Player Identity, never the display-only wallet address.
If you don't already run a database:
| Provider | Good for |
|---|---|
| Railway | One-click Postgres/MySQL/Redis/MongoDB next to your backend service; usage-based billing, fast to set up |
| Render | Managed Postgres + Redis with flat, predictable monthly pricing; similar git-push workflow to Railway |
| Supabase | Hosted Postgres with a realtime layer and auto-generated REST/GraphQL API — a leaderboard that updates live without polling |
Building with an AI agent? The Forest AI skill can scaffold the schema, migrations, and backend handler for you.
Quote, buy, and sell Project Token through the connected wallet.
User-approved auto-swap sessions and trusted execution.
Read, deposit to, and withdraw the player's playable balance.
Burn wallet-held Project Token on-chain for in-game sinks.
One-use authorizations for trusted backend settlement.
Wallet events and the verified-player handshake.
For the request/response envelope and the full method list, see the RPC Reference.