-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e54a790
commit 446eb0c
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
docs/home/50-smart-contracts/300-precompiles/100-introduction.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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). | ||
|
||
|
||
When using the templates, these can be defined in a `precompiles` directory in | ||
the game by using the `generatePrecompile` function, and then set up with the | ||
esbuild template through the configuration. | ||
|
||
## Definitions | ||
```ts | ||
// precompiles/index.ts | ||
|
||
export const precompiles = { | ||
...generatePrecompile("foo"), | ||
} as const; | ||
``` | ||
|
||
## Esbuild configuration | ||
|
||
```ts | ||
const esbuild = require("esbuild"); | ||
const { | ||
generateConfig, | ||
} = require("@paima/build-utils/standalone-esbuildconfig.template"); | ||
|
||
const { config, outFiles, workspace } = generateConfig( | ||
"api", | ||
"state-transition", | ||
"precompiles" | ||
); | ||
esbuild.build(config); | ||
``` | ||
|
||
This will generate a `precompiles.cjs` package in the `packaged` folder. Paima | ||
Engine will load this file on startup. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"label": "Paima Precompiles" | ||
} |