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

📝 Creating a draft for upcoming cross-contract tutorial #857

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

LuffySama-Dev
Copy link
Contributor

Hi @barriebyron,

I am creating this PR for #776 .
We can keep this in draft.
Today I have tested the code and added the basic layout.
I will keep on committing to this PR until the tutorial is ready.

Thank You 😃

@LuffySama-Dev LuffySama-Dev requested a review from a team as a code owner February 21, 2024 15:51
Copy link

vercel bot commented Feb 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2024 3:36pm

Copy link

vercel bot commented Feb 21, 2024

@LuffySama-Dev is attempting to deploy a commit to the o1labs Team on Vercel.

A member of the Team first needs to authorize it.

@LuffySama-Dev
Copy link
Contributor Author

Hi @barriebyron ,

I have started adding content in 12-cross-contract-calls.mdx file.
The build is successful but when I am trying to run it locally using npm run dev I am can't see this tutorial.

Does it needs to be updated some other place in order for it to be visible ?

Tomorrow I will push the code on top of which tutorial can be updated further.

Thank You 😃

@LuffySama-Dev
Copy link
Contributor Author

Hi @barriebyron ,

The final change to the tutorial is added.
Can you please help to review and let me know if any changes are required ?

  • Also, do we need to have comments in code file and tutorial ?

Thank you 😃

@LuffySama-Dev
Copy link
Contributor Author

Hi @barriebyron ,

The tutorial draft is ready and code is audited with latest version of o1js and zkApp cli.
Can you please help to check and let me know if any changes are required ?

Thank You 😃

@barriebyron
Copy link
Contributor

To add the tutorial to the sidebars, see https://github.com/o1-labs/docs2/wiki/Markdown-Syntax#sidebar and then a preview of the doc will be available at https://docs2-git-fork-luffysama-dev-issue776luffy-minadocs.vercel.app/

I think you know already you can build the docs locally per https://github.com/o1-labs/docs2/blob/main/README.md#how-to-see-your-local-doc-updates-during-development

I am learning more about how to test the code... let me help you get the preview working and then I'll test it! thank you

@LuffySama-Dev
Copy link
Contributor Author

To add the tutorial to the sidebars, see https://github.com/o1-labs/docs2/wiki/Markdown-Syntax#sidebar and then a preview of the doc will be available at https://docs2-git-fork-luffysama-dev-issue776luffy-minadocs.vercel.app/

I think you know already you can build the docs locally per https://github.com/o1-labs/docs2/blob/main/README.md#how-to-see-your-local-doc-updates-during-development

I am learning more about how to test the code... let me help you get the preview working and then I'll test it! thank you

Awesome!! Thank you so much ...
Will commit these changes by EOD.

Great !! Let me know if you need help with testing code 😃.

Thank you so much 🙌🏻

@LuffySama-Dev
Copy link
Contributor Author

Hi @barriebyron ,

I have pushed the changes and added he tutorial in sidebar.
Tested it locally and build is success and can see it.

The links to code in tutorial won't work as of now as this PR is not merged into main branch yet. (Code is also part of this PR)

Can you please help to check if any other changes are required ?

Thank You so much ❤️

Copy link
Contributor

@barriebyron barriebyron left a comment

Choose a reason for hiding this comment

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

looking so good!


In this tutorial, you learn how smart contracts on a blockchain can interact by calling functions in each other's code, enabling building modular and complex decentralized applications.

Cross contract calls allow smart contracts on a blockchain to interact with each other. This enables the building of complex decentralized applications (Dapps) from multiple modular components. In a cross-contract call, a function in one smart contract can call a function in another smart contract to leverage existing code and functionality.
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add an example of a complex stack that will benefit from this pattern (can we describe a use case?) @LuffySama-Dev

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking the same !!
I was thinking of adding a image but an use case example sounds awesome.
Will check and add it in couple of days.

Thank You 🙌🏻


This tutorial demonstrates passing data between contracts, handling events, and returning values when contracts call each other.

The full example code is provided in the [12-cross-contract-calls/src/](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/12-cross-contract-calls/src) example files.
Copy link
Contributor

Choose a reason for hiding this comment

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

where are the example files? are they in this PR?
let's put the example files mentioned in the tutorial in a new folder here https://github.com/o1-labs/docs2/tree/main/examples/zkapps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The example files are added in initial commit in example folder.

7aa4b14#diff-40a308f55dcc34f6c479b6f2954062c4ef5bac47ad2928204dc9951e78eea6bc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once this PR get's merges the link will start working.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't recognize all three smart contracts as being present, since in a single file. Thanks @iregina for testing the code!

docs/zkapps/tutorials/12-cross-contract-calls.mdx Outdated Show resolved Hide resolved
adderZkapp.deploy();
incrementerZkapp.deploy();
});
await tx.sign([feePayerKey, zkappKey, adderKey, incrementerKey]).send();
Copy link
Contributor

Choose a reason for hiding this comment

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

@LuffySama-Dev Can you also leave a comment about what is happening here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @iregina ,
Yes sure. I will add a comment.

Thank You ☺️

Copy link
Contributor

Choose a reason for hiding this comment

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

I like your question about comments @LuffySama-Dev
Helpful comments in the code is the pathway to sharing knowledge

Please add descriptive comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @barriebyron , @iregina ,

I have committed the changes, can you please help to check and let me know if any changes are required ?

  • Also, I am planning on adding a flow diagram of how call is going from one contract to other an so.
    What do you think ?

Thank You 😃

@barriebyron
Copy link
Contributor

barriebyron commented Mar 6, 2024

Hi @barriebyron ,

The final change to the tutorial is added. Can you please help to review and let me know if any changes are required ?

  • Also, do we need to have comments in code file and tutorial ?

Thank you 😃

@LuffySama-Dev Yes, please, let's add code comments in the smart contract and include those comments in the code shown in the doc. Comments are the pathway to sharing knowledge.

@LuffySama-Dev
Copy link
Contributor Author

Hi @barriebyron ,
The final change to the tutorial is added. Can you please help to review and let me know if any changes are required ?

  • Also, do we need to have comments in code file and tutorial ?

Thank you 😃

@LuffySama-Dev Yes, please, let's add code comments in the smart contract and include those comments in the code shown in the doc. Comments are the pathway to sharing knowledge.

on it 🫡

Copy link
Member

@Trivo25 Trivo25 left a comment

Choose a reason for hiding this comment

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

lgtm! Before we merge, we should adjust the tutorial and the code to the latest breaking changes that introduce async circuit. see here https://github.com/o1-labs/o1js/blob/main/CHANGELOG.md#breaking-changes

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.

4 participants