OPNet Testnet β€” BTC L1
WALLET: Not connected β€” connect to save scores on-chain
SCORE 00000
HI-CHAIN 00000
SPEED 6.0
BTC EARNED 0.00000000
BLOCKS 0
β‚ΏπŸ¦•
DINO CHAIN
Run on Bitcoin. Earn BTC. Defeat the chain.
⛏ Blocks Mined
0
Each 100pts = 1 block
β‚Ώ Total BTC Earned
0.00000000
6.25 BTC / block reward
πŸ† Best Run
0
All-time high score
πŸ“‘ Live Contract Events LIVE
DEPLOY DinoChain v1.0.0 contract deployed β€” 0x7f3a...8b2e +0 BTC
πŸ€–
BOB β€” OPNet AI Agent
Smart contract advisor β€’ via ai.opnet.org/mcp
πŸ”— DinoChain MCP connected. I can help you write, audit, and deploy smart contracts for this game on Bitcoin (OPNet). Ask me anything!
πŸ“„ DinoChain Smart Contract β€” AssemblyScript / OPNet
// DinoChain.ts β€” Bitcoin Smart Contract (OPNet / AssemblyScript)
// Deployed on Bitcoin L1 via OP_NET consensus layer

import {
  OP20, Address, u256, Blockchain,
  Calldata, encodeSelector
} from '@btc-vision/btc-runtime/runtime';

@final
export class DinoChain extends OP20 {

  // Storage slots (deterministic on-chain state)
  private readonly _highScores: StoredMapU256;
  private readonly _totalRuns: StoredU256;
  private readonly _btcRewards: StoredMapU256;
  private readonly _blockReward: u256 = 625_000_000n; // 6.25 BTC sats

  constructor() {
    super('DinoChain Token', 'DINO', 18, 21_000_000n);
    this._highScores = new StoredMapU256(Pointer.CUSTOM_1);
    this._totalRuns = new StoredU256(Pointer.CUSTOM_2);
    this._btcRewards = new StoredMapU256(Pointer.CUSTOM_3);
  }

  // Submit verified game score to chain
  public submitScore(score: u256, proof: Uint8Array): void {
    const caller = Blockchain.tx.sender;

    // Verify score proof (prevents cheating)
    assert(
      this._verifyScoreProof(score, proof, caller),
      'Invalid score proof'
    );

    // Update high score if beaten
    const current = this._highScores.get(caller);
    if (score > current) {
      this._highScores.set(caller, score);
      this.emit(new NewHighScore(caller, score));
    }

    // Calculate block reward (100 points = 1 block = 6.25 BTC)
    const blocks = score / 100n;
    const reward = blocks * this._blockReward;
    this._mintReward(caller, reward);
    this._totalRuns.set(this._totalRuns.value + 1n);
  }

  // Get high score for address
  public getHighScore(player: Address): u256 {
    return this._highScores.get(player);
  }

  // Global leaderboard query
  public getLeaderboard(): TopScore[] {
    return this._leaderboard.getTop(10);
  }

  // Internal: mint BTC reward tokens
  private _mintReward(to: Address, amount: u256): void {
    if (this.totalSupply() + amount <= this.maxSupply()) {
      this._mint(to, amount);
      this.emit(new RewardMinted(to, amount));
    }
  }
}