メインコンテンツまでスキップ

Setup

Paima precompiles allow games to define specific addresses that are only part of the rollup, instead of belonging to any of the underlying chains (or users). You can think of these as namespaces for rollup-emitted events.

Notably, makes it much easier to query rollup information in the following two cases:

  1. ticks that trigger through the passage of time
  2. event logging for external

When using the templates, these can be defined in a precompiles/ directory

Definitions

All the precompiles for your application should be put into precompiles/src/index.ts

import { generatePrecompiles } from '@paima/sdk/precompiles';

export enum PrecompileNames {
GameTick = 'game-tick',
}

export const precompiles = generatePrecompiles(PrecompileNames);

Then, when registering timers or events under to trigger under this precompile, simply reference the precompile by name

createScheduledData(
`tick|${input.n + 1}`,
{ blockHeight: someBlockHeight },
{ precompile: precompiles[PrecompileNames.GameTick] }
)

When you compile your state machine, Paima will create a precompiles.cjs file that contains all your precompile definitions necessary to create your rollup.