-
Notifications
You must be signed in to change notification settings - Fork 142
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
o1js API Redesign #2031
Comments
I'm confused. What's the difference between MinaProgram and zkApp? I've usually seen zkApp refer to on-chain apps. Maybe you meant to say "reducers into MinaProgram and ZkProgram"? Otherwise, I love the rename of SmartContract to MinaProgram - makes it clearer that these live on-chain, and that ZkProgram is the other type. |
I think you should consider having a more functional API for interaction with Mina too. I don't mean for circuit generation, that would be very hard, but e.g. sending funds, updating state, etc. It's already functional under the hood, yet the API abstracts this and gives you a mutable API that sets fields and then returns them for you. While this is perhaps easier for beginners, I've come to believe that it's worse in the long run. Perhaps this is already something you've considered. |
I think some of the current approach of o1js to developers is make things difficult especially for beginners. It would be better if |
Now, when Zeko has removed the number of AccountUpdates limit, and I hope Mina will do the same during the hardfork, we will have txs with many AccountUpdates. I have two suggestions in this regard:
|
This issue serves as a central discussion point as we transition into the implementation phase and begin rolling out the new API incrementally. It outlines the core philosophy and design approach behind the changes and will be shared both internally and externally. Feedback and discussion are encouraged - feel free to contribute your thoughts.
Problems with the Current API
The current abstractions, particularly
SmartContract
, provide a smooth onboarding experience but introduce challenges when building complex applications that align with Mina’s zkApps protocol architecture. Many protocol features are hidden behind high-level APIs that don’t always map well to their underlying functionality.This abstraction makes it difficult for developers to fully grasp the system’s inner workings, limiting transparency and control. Additionally, fine-grained settings and transaction structures are often inaccessible, preventing developers from fully leveraging the zkApps protocol’s capabilities. As a result, o1js can become a bottleneck rather than an enabler for advanced zkApp development.
Proposed New API (WIP – Feedback Appreciated)
Note: This section primarily outlines external-facing API changes. Some internal improvements and refactoring of the types and bindings layer will also be made, but these are purely technical updates necessary to support the new API.
The new API introduces the following features, each designed with a specific goal in mind:
Improved Transaction Creation and AccountUpdate Composition
Similar to the existing
Mina.transaction
block, this new API will integrate with the rest of the updated API. It provides developers with explicit tools to construct transactions, send them to the network, and manually create complexAccountUpdate
structures. This ensures greater flexibility and control over transaction logic.Local Transaction Simulation
The core transaction logic will be fully translated in o1js, granting developers more control over their local environment. This will be accompanied by a testing framework that allows developers to fine-tune network state, debug transactions more effectively, and build more robust zkApps as well as better understand how zkApp transactions are applied to the network.
MinaProgram
A new API representing a program running on Mina, replacing
SmartContract
with a more flexible and transparent interface. This change enables developers to express application logic in a more direct manner while maintaining full control over on-chain account structures, transactions,AccountUpdate
composition, permissions, update logic, and assertions - without unnecessary high-level abstractions.ZkStateMachine
(Reducer Interface)A
zkProgram
that defines a state machine and its state transition function. This will replace the existing actions and reducers abstraction, providing a more structured and powerful way to integrate actions and reducers intoMinaProgram
and zkApps.ZkBuffer
(Accumulating Side Effects)Designed to work alongside
ZkStateMachine
, actions & reducers, theZkBuffer
serves as an on-chain buffer that accumulates side effects (e.g., payouts, token transfers, state updates) for later execution. This addresses one of the key limitations of the current API.ZkEnum
A zk-friendly, easy-to-use Enum implementation. This will simplify the implementation of action and reducer logic while also improving the handling of side effects through
ZkStateMachine
andZkBuffer
.Goals of the New API
Explicit Non-Goals
Next Steps
This thread will serve as a space for discussion, where we gather feedback, exchange ideas, and compile information for future improvements.
The text was updated successfully, but these errors were encountered: