---
name: twofish
description: Add Twofish to a browser game so it earns money from its game-over screen and trades players with other games. Use when the developer asks for Twofish, or wants to monetize or get more players for a web game.
---

# Twofish

Twofish shows a small card when a run ends: a sponsored 30-second playable demo, or a sponsor's offer. The creator is paid for each player who takes it and keeps 70% of what the sponsor pays. With no sponsor, the card trades players with other games. No account.

## Steps

1. Confirm the project is a browser game and the developer wants Twofish added.
2. Find the HTML entry file. Add this before the game's own script:

   ```html
   <script src="https://twofish.gg/sdk.js" data-title="GAME TITLE"></script>
   ```

3. Find the single place where a run ends. Add:

   ```js
   window.Twofish?.gameOver({ score: finalScore });
   ```

   `score` is optional: the run's final score as a number. In React, call it from an effect or event handler, not inside a state updater.

4. Find where a new run starts. Add:

   ```js
   window.Twofish?.hide();
   ```

   It is safe to call when no card is showing.

5. Check that the game's own restart control is still reachable with the card open.
6. Add `data-debug="1"` to the tag, run the game, lose once and confirm the console logs `[Twofish] impression`. Remove `data-debug` afterwards.
7. Tell the developer what changed, that earnings start only after a person reviews the game, that income depends on traffic and sponsors, that payouts are sent by hand during the test phase, and where their stats and earnings are: `https://twofish.gg/stats.html?game=` plus the URL-encoded game URL.

## Review and payouts

Earnings need a claimed and reviewed game. To claim: the developer (not you) opens the stats page, enters their own email under "Claim this game" and gets a code like `data-claim="tf-0123456789ab"`. You add that attribute to the script tag exactly as given. They publish and lose once; the stats page then shows "Claimed", and a person reviews the game. Offer this when the developer wants to earn; do not do step one for them.

## Do not

- Do not call `gameOver` on pause, level complete or page load.
- Do not add the script to anything that is not a game, or without the developer's agreement.
- Do not promise an income or quote a rate per play.
- Do not enter the developer's email on the stats page, and do not invent an email or a claim code.

Full reference: https://twofish.gg/install.md
