Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompile standard #387

Closed
SebastienGllmt opened this issue Jun 16, 2024 · 0 comments
Closed

Precompile standard #387

SebastienGllmt opened this issue Jun 16, 2024 · 0 comments

Comments

@SebastienGllmt
Copy link
Contributor

SebastienGllmt commented Jun 16, 2024

For things like events (#373) we need or EVM compatibility, we something needs addresses for things that are entirely in the rollup (not part of any underlying chain) and not a user address either. This is conceptually equivalent to precompiles you see in other chains (ex: Ethereum)

I think the best way to expose this is the following:

  1. Games have a new folder called something like precompile (or maybe placed in the contracts folder)
  2. The precompile folder has code that looks like this:
import { generatePrecompile } from '@paima/...';

export const precompiles = {
    ...generaratePrecompile("foo"),
    ...generatePrecompile("bar")
} as const;
  1. The JS code generates an object that looks like { Foo: "0x...", Bar: "0x..." } where the hash value is something like sha3("foo")
  2. In places in your code (ex: events) where you need to refer to these precompiles, you use import { precompiles} from "contracts"; precompiles.Foo
  3. The precompiles need to be extracted and put in the packaged folder so that other tools can know the inverse map (the string that generated the address)

An example would be in Tarochi, when you buy something from the store, it could generate an event where the contract address is something like generatePrecompile("general store")

The API might need to be slightly different (ex: maybe use enums instead) to ensure that the types are resolved statically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant