Skip to content

ZkProgram default example starter#725

Merged
ymekuria merged 96 commits intomainfrom
feature/zkprogram-starter
Mar 27, 2025
Merged

ZkProgram default example starter#725
ymekuria merged 96 commits intomainfrom
feature/zkprogram-starter

Conversation

@ymekuria
Copy link
Copy Markdown
Collaborator

@ymekuria ymekuria commented Mar 19, 2025

Summary

This PR adds a new ZkPogram default example that is included with projects generated with the zkApp-CLI. This example was also coupled with a new example template UI that demonstrates an end to end flow of generating proofs with a ZkProgram, and settling the state on Mina.

Impact

The previous default example set up the developer community for failure. While this example highlighted the intuitive nature of writing proofs with o1js, it extended the SmartContract class which abstracted away a lot of the complexity of what was happening.

The new example was created using ZkProgram which has more clear inputs, outputs, and behavior. This coupled with the end to end UI example will allow a developer to make more progress on their learning journey by providing an easy to reason about example that can quickly be iterated and rerun.

Changes

  • AddZkProgram was created that can generate proofs and update the state
  • Add.ts was modified to only verify a proof created by AddZKprogram and settle the state to Mina
  • The example default tests Add.tests.ts were modified to test interactions with the AddZkPogram
  • The interact.ts was modified to generate proofs with the AddZkProgram and interact with a deployed Add.ts contract that settles the state to Mina
  • A new example contract was deployed that is used in the UI https://minascan.io/devnet/account/B62qoptamt2EgyY2UM2WD7UVJRvuuDMxw2cLdENc92iVNm6FwsLX4Fk
  • A new example template UI was added that demonstrates an end to end flow of generating proofs with a ZkProgram, and settling the state on Mina.

Screenshot 2025-03-19 at 12 00 12 AM

ymekuria added 30 commits March 10, 2025 12:17
…lass to improve code readability and maintainability
feat(customNextPage.js): update references from AddZKprogram to AddZkProgram for consistency
feat(Add.test.ts): update import statement for AddZkProgram in Add.test.ts
feat(Add.ts): update import statement for AddZkProgram in Add.ts
feat(index.ts): update export statement for AddZkProgram in index.ts
feat(interact.ts): update import statement for AddZkProgram in interact.ts
Copy link
Copy Markdown
Contributor

@45930 45930 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thank you for also redeploying a new contract and updating the interact script <3

I left some specific comments. As a general comment, does the new UI only work with next/react? If so, I'd be comfortable removing the not-as-supported frameworks from the options so that users can't accidentally opt into a worse experience. I ran the new code with nuxt and everything works fine, but the UI has no zkapp elements by default.

@ymekuria
Copy link
Copy Markdown
Collaborator Author

ymekuria commented Mar 21, 2025

As a general comment, does the new UI only work with next/react? If so, I'd be comfortable removing the not-as-supported frameworks from the options so that users can't accidentally opt into a worse experience. I ran the new code with nuxt and everything works fine, but the UI has no zkapp elements by default.

@45930 We previously did not create UI zkapp interactions with Svelte and Nuxt, so I only added the new ZkProgram interactions to the Next scaffold. Although Svelte and Nuxt are not-as-supported as Next in the CLI and our other examples, we still provide all the necessary configurations for them to work with o1js. I see a few paths forward.

  1. Remove Svelte and Nuxt from the scaffold if we decide just adding the necessary configs for o1js in the UI is not adding enough value. This would make it easier to maintain.

  2. Add the new zkapp UI interactions to Svelte and Nuxt. This could give more options to the community but I'm not sure what the demand is for this. Antidotally, I hear of devs using Svelte in some of their projects.

  3. Leave the Svelte and Nuxt scaffolds without the zkapp UI interactions. Tradeoff of more options, but a worse experience for these two.

I assume you think option 1 is the path forward we should take. Is that correct?

@ymekuria ymekuria changed the title ZKprogram default example starter ZkProgram default example starter Mar 21, 2025
…xpected final state with integration test expecations
@45930
Copy link
Copy Markdown
Contributor

45930 commented Mar 26, 2025

@ymekuria I think all options are reasonable. Let me take a quick poll in discord about who is using the zkapp-cli and what UI they are using.

@ymekuria ymekuria merged commit 6088f99 into main Mar 27, 2025
18 checks passed
@ymekuria ymekuria deleted the feature/zkprogram-starter branch March 27, 2025 20:25
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

Successfully merging this pull request may close these issues.

3 participants