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

Updated Localnet doc #481

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

Updated Localnet doc #481

wants to merge 3 commits into from

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Oct 1, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced documentation for Localnet, detailing its capabilities for creating and testing universal applications in a multi-chain environment.
    • Clarified setup instructions with two distinct methods for initializing Localnet.
    • Improved output formatting for better readability of contract addresses.
  • Documentation

    • Expanded prerequisites section to include necessary tools and installations such as Node.js, Yarn, and Foundry Anvil.
    • Revised conclusion summarizing Localnet's readiness for application development and testing, emphasizing protocol contracts and Uniswap pools configuration.

@fadeev fadeev requested a review from bbbeeeee as a code owner October 1, 2024 10:42
Copy link

vercel bot commented Oct 1, 2024

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

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 2, 2024 9:03am

@fadeev fadeev requested review from brewmaster012 and a team as code owners October 1, 2024 10:42
Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces comprehensive revisions to the documentation for Localnet, a local development environment for ZetaChain. Key updates include an enhanced introduction outlining Localnet's capabilities, expanded prerequisites for setup, and clarified instructions for initializing Localnet. The documentation now details two methods for setup, updates commands for starting Localnet, and provides a clearer presentation of output, including contract addresses. Additionally, the section on Localnet's functionalities has been elaborated, and the conclusion reinforces the environment's readiness for application development and testing.

Changes

File Path Change Summary
src/pages/developers/tutorials/localnet.mdx Revised introduction to emphasize Localnet's capabilities; expanded prerequisites; clarified setup instructions with two methods; updated commands for starting Localnet; detailed initialization actions; reformatted output section for clarity; revised conclusion summarizing environment readiness.

Possibly related PRs

  • localnet #443: This PR also enhances the documentation for Localnet, focusing on setup instructions and functionalities that relate closely to the changes made in the main PR.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (1)
src/pages/developers/tutorials/localnet.mdx (1)

5-5: Address minor grammatical issues.

  1. Line 5: Consider changing "multi-chain" to "multichain" for consistency with common usage in the blockchain industry.

  2. Line 56: Replace "The examples ships with" with "The example ships with" or "The examples ship with" to correct the subject-verb agreement.

These minor adjustments will improve the overall quality of the document.

Also applies to: 56-56

🧰 Tools
🪛 LanguageTool

[misspelling] ~5-~5: This word is normally spelled as one.
Context: ... and Uniswap pools locally, mimicking a multi-chain environment. By using Localnet, you can...

(EN_COMPOUNDS_MULTI_CHAIN)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c80b227 and 122a85d.

📒 Files selected for processing (1)
  • src/pages/developers/tutorials/localnet.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/tutorials/localnet.mdx

[misspelling] ~5-~5: This word is normally spelled as one.
Context: ... and Uniswap pools locally, mimicking a multi-chain environment. By using Localnet, you can...

(EN_COMPOUNDS_MULTI_CHAIN)


[grammar] ~56-~56: You should probably use “ship”.
Context: ...v @zetachain/localnet ``` The examples ships with the latest version of Localnet. S...

(AGREEMENT_SENT_START)


[uncategorized] ~154-~154: Loose punctuation mark.
Context: ...s the following parameters: - --anvil: Additional arguments to pass to Anvil (...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~155-~155: Loose punctuation mark.
Context: ...vil (default: ""). - --exit-on-error: Exit with an error if a revert is not h...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~156-~156: Loose punctuation mark.
Context: ... revert is not handled. - --force-kill: Force kill any process on the port with...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~157-~157: Loose punctuation mark.
Context: ...n the port without prompting. - --port: Port to run Anvil on (default: 8545)....

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~158-~158: Loose punctuation mark.
Context: ...(default: 8545). - --stop-after-init: Stop the Localnet after successful init...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (2)
src/pages/developers/tutorials/localnet.mdx (2)

1-7: Introduction provides a clear and concise overview.

The introduction effectively communicates the purpose and capabilities of Localnet, emphasizing its ability to simulate a multi-chain environment on a single local EVM chain. This sets the stage well for the rest of the document.

🧰 Tools
🪛 LanguageTool

[misspelling] ~5-~5: This word is normally spelled as one.
Context: ... and Uniswap pools locally, mimicking a multi-chain environment. By using Localnet, you can...

(EN_COMPOUNDS_MULTI_CHAIN)


90-112: Comprehensive explanation of Localnet functionality.

The "What Localnet Does" section provides a clear and detailed explanation of Localnet's actions. The use of bullet points and links to relevant resources enhances readability and understanding. This section effectively communicates the value proposition of Localnet to developers.

src/pages/developers/tutorials/localnet.mdx Outdated Show resolved Hide resolved
src/pages/developers/tutorials/localnet.mdx Show resolved Hide resolved
src/pages/developers/tutorials/localnet.mdx Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 122a85d and b124ce8.

📒 Files selected for processing (1)
  • src/pages/developers/tutorials/localnet.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/tutorials/localnet.mdx

[misspelling] ~5-~5: This word is normally spelled as one.
Context: ... and Uniswap pools locally, mimicking a multi-chain environment. By using Localnet, you can...

(EN_COMPOUNDS_MULTI_CHAIN)


[grammar] ~56-~56: You should probably use “ship”.
Context: ...v @zetachain/localnet ``` The examples ships with the latest version of Localnet. S...

(AGREEMENT_SENT_START)


[uncategorized] ~154-~154: Loose punctuation mark.
Context: ...s the following parameters: - --anvil: Additional arguments to pass to Anvil (...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~155-~155: Loose punctuation mark.
Context: ...vil (default: ""). - --exit-on-error: Exit with an error if a revert is not h...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~156-~156: Loose punctuation mark.
Context: ... revert is not handled. - --force-kill: Force kill any process on the port with...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~157-~157: Loose punctuation mark.
Context: ...n the port without prompting. - --port: Port to run Anvil on (default: 8545)....

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~158-~158: Loose punctuation mark.
Context: ...(default: 8545). - --stop-after-init: Stop the Localnet after successful init...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (4)
src/pages/developers/tutorials/localnet.mdx (4)

1-7: Introduction section is well-crafted and informative.

The introduction effectively communicates the purpose and functionality of Localnet, emphasizing its ability to simulate a multi-chain environment on a single local EVM chain. This provides developers with a clear understanding of Localnet's capabilities and benefits.

🧰 Tools
🪛 LanguageTool

[misspelling] ~5-~5: This word is normally spelled as one.
Context: ... and Uniswap pools locally, mimicking a multi-chain environment. By using Localnet, you can...

(EN_COMPOUNDS_MULTI_CHAIN)


21-36: Prerequisites section is comprehensive and well-structured.

The prerequisites are clearly listed with appropriate installation links, providing users with the necessary information to set up their development environment. The two setup options are succinctly described, allowing users to choose the most suitable approach for their needs.


90-112: "What Localnet Does" section is comprehensive and well-structured.

This section effectively outlines the actions performed by Localnet, providing users with a clear understanding of its functionality. Each action is succinctly explained with relevant links, enhancing the overall clarity and usefulness of the documentation.


113-148: Output section effectively presents contract addresses.

The Output section clearly displays the contract addresses in a well-formatted tabular structure, making it easy for developers to reference. The accompanying context provides users with a clear understanding of the displayed information and its relevance to their local blockchain setup.

Comment on lines +9 to +19
<div className="mt-8" style={{ width: "100%", height: "auto", "aspect-ratio": "16 / 8" }}>
<iframe
width="100%"
height="100%"
src="https://www.youtube.com/embed/b4EWTQ3VCZk?si=kiKncEWFZolVAo0F"
filename="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance video embedding for accessibility and standards compliance.

While the video is a valuable addition, consider the following improvements:

  1. Replace the deprecated frameborder attribute with CSS:

    style={{ border: 'none' }}
  2. Update allowfullscreen to allowFullScreen for JSX compatibility.

  3. Replace the non-standard filename attribute with title for better accessibility:

    title="YouTube video player"
  4. Add loading="lazy" attribute to improve page load performance.

Implementing these changes will enhance accessibility, standards compliance, and performance of the embedded video.

Comment on lines +150 to +178
# Available Parameters

Execute the `callFromZetaChain` function of the universal app:
Localnet supports the following parameters:

```
yarn hardhat call-from-zetachain --message bob --network localhost --revert-address 0x9A676e781A523b5d0C0e43731313A708CB607508 --revert-message "my revert message" --call-on-revert --contract 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 --receiver 0x9A676e781A523b5d0C0e43731313A708CB607508
```
- `--anvil`: Additional arguments to pass to Anvil (default: `""`).
- `--exit-on-error`: Exit with an error if a revert is not handled.
- `--force-kill`: Force kill any process on the port without prompting.
- `--port`: Port to run Anvil on (default: `8545`).
- `--stop-after-init`: Stop the Localnet after successful initialization.

The function calls the ZetaChain gateway contract. The ZetaChain gateway emits a
"Called" event acknowledging that the call has been successful.
For an up-to-date list of arguments, run:

```
[ZetaChain]: Gateway: 'Called' event emitted
npx hardhat localnet --help
```

Localnet picks up the "Called" event and calls the EVM gateway `execute`
function, which calls the Receiver contract:
**Example:**

```
[EVM]: Calling 0x9a676e781a523b5d0c0e43731313a708cb607508 with message 0xa777d0dc00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003626f620000000000000000000000000000000000000000000000000000000000
npx hardhat localnet --anvil "--block-time 1" --port 2000
```

The Receiver contract then emits an event:

```
[EVM]: Event from contract: {"_type":"log","address":"0x9A676e781A523b5d0C0e43731313A708CB607508","blockHash":"0x0deb4a3e22b73320ffad3d916c5e2b2db450dddc162feaafa84546612cebd238","blockNumber":22,"data":"0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003626f620000000000000000000000000000000000000000000000000000000000","index":0,"removed":false,"topics":["0xfa051318aca3e493e16e6cf4bccc017c7e061924a42ef27b3bb373c4707b636a"],"transactionHash":"0x94c4d53aed68c97f18e467207ff6cdc1e855c65bcddab399f100fe2786ee33a8","transactionIndex":0}
```
# Conclusion

Interacting between real networks like ZetaChain and Ethereum follows the same
steps as Localnet. Developers or users can seamlessly engage with the EVM
gateway on live networks such as Ethereum, BSC, or Base to call contracts on
ZetaChain or vice versa. This allows for a consistent development experience,
whether on a local testnet or across real-world blockchain networks, ensuring
that the transition from development to production environments is seamless.
With Localnet set up, you're ready to develop and test your universal
applications locally with ZetaChain's protocol contracts, tokens, and Uniswap
pools fully configured. This environment enables rapid development and
debugging, ensuring that your applications are robust and ready for deployment
on the testnet or mainnet.
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance Conclusion with next steps and resources.

The Available Parameters section effectively lists the supported parameters with clear descriptions. To further improve the Conclusion, consider adding next steps or links to additional resources. For example:

# Conclusion

With Localnet set up, you're ready to develop and test your universal applications locally. To start building on ZetaChain:

1. Explore our [Smart Contract Development Guide](/developers/smart-contracts/overview)
2. Check out our [Example Applications](/developers/examples/overview)
3. Join our [Developer Community](https://discord.gg/zetachain) for support and discussions

These resources will help you leverage the full potential of ZetaChain in your applications.

This addition will guide developers on their next steps after setting up Localnet, providing a more comprehensive conclusion to the documentation.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~154-~154: Loose punctuation mark.
Context: ...s the following parameters: - --anvil: Additional arguments to pass to Anvil (...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~155-~155: Loose punctuation mark.
Context: ...vil (default: ""). - --exit-on-error: Exit with an error if a revert is not h...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~156-~156: Loose punctuation mark.
Context: ... revert is not handled. - --force-kill: Force kill any process on the port with...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~157-~157: Loose punctuation mark.
Context: ...n the port without prompting. - --port: Port to run Anvil on (default: 8545)....

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~158-~158: Loose punctuation mark.
Context: ...(default: 8545). - --stop-after-init: Stop the Localnet after successful init...

(UNLIKELY_OPENING_PUNCTUATION)

Comment on lines +38 to 87
Once the localnet is started you will see the standard Anvil output with a list
of accounts, private keys as well as the output from protocol contracts being
deployed. After the localnet is set up you will see a list of protocol contract
addresses:
To get started with the example contracts, clone the repository and install the
dependencies:

```
EVM Contract Addresses
======================

Gateway EVM: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
ZETA: 0x5FbDB2315678afecb367f032d93F642f64180aa3

ZetaChain Contract Addresses
============================

Gateway ZetaChain: 0x610178dA211FEF7D417bC0e6FeD39F05609AD788
ZETA: 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853
ZRC-20 ETH: 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c
git clone https://github.com/zeta-chain/example-contracts
cd example-contracts/universal/hello
yarn
```

Keep the terminal window with localnet running open and open a new terminal.

Compile the contracts and deploy both a Hello universal app contract and a
Receiver contract.
Localnet is installed from the `@zetachain/localnet` package. If you need to
update Localnet, run:

```
yarn deploy
yarn add --dev @zetachain/localnet
```

Universal app contract address:

```
🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82
```
The examples ships with the latest version of Localnet.

Receiver contract:
Start the Localnet by running:

```
🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x9A676e781A523b5d0C0e43731313A708CB607508
npx hardhat localnet
```

Even though both contracts are deployed on the same local testnet we will think
of Hello as running on ZetaChain and Receiver as running on a generic EVM chain.
These two contracts are connected with each other through the
[gateway](/developers/evm/gateway).
This command initializes the local development environment with all necessary
contracts and configurations.

## Call a Universal App from EVM
# Option 2: Using the Localnet Repository

Call the `depositAndCall` function on the EVM gateway to call a universal app
contract:
If you prefer to set up Localnet independently, clone the Localnet repository:

```
yarn hardhat deposit-and-call --contract 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 --amount 2 --message bob --network localhost --revert-address 0x9A676e781A523b5d0C0e43731313A708CB607508 --revert-message 0x --call-on-revert
git clone https://github.com/zeta-chain/localnet
cd localnet
```

The command calls the `depositAndCall` function on the EVM gateway.

The EVM gateway emits a "Deposited" event acknowledging that the function call
has been successful:
Install the necessary packages:

```
[EVM]: Gateway: 'Deposited' event emitted
```

Localnet picks up the "Deposited" event and calls the ZetaChain's gateway
`execute` function, which calls the universal app:

```
[ZetaChain]: Universal contract 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 executing onCrossChainCall (context: {"origin":"0x610178dA211FEF7D417bC0e6FeD39F05609AD788","sender":"0x735b14BB79463307AAcBED86DAf3322B1e6226aB","chainID":1}), zrc20: 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c, amount: 2000000000000000000, message: 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003626f620000000000000000000000000000000000000000000000000000000000)
yarn
```

The `onCrossChainCall` is executed and emits an event:
Start the Localnet by running:

```
[ZetaChain]: Event from onCrossChainCall: {"_type":"log","address":"0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82","blockHash":"0xc8a8ebc484c5330f118a9e838587b918657ca2b347b7b76846236c00e44006bd","blockNumber":23,"data":"0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001a48656c6c6f2066726f6d206120756e6976657273616c206170700000000000000000000000000000000000000000000000000000000000000000000000000003626f620000000000000000000000000000000000000000000000000000000000","index":2,"removed":false,"topics":["0x39f8c79736fed93bca390bb3d6ff7da07482edb61cd7dafcfba496821d6ab7a3"],"transactionHash":"0x3a6612c174d980a13e3ee6b17a21c4708f0f31b823c1fba1037fc6c4124a7b68","transactionIndex":0}
npx hardhat localnet
```

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Setup options are well-explained, with a minor grammatical correction needed.

The setup instructions for both options are clear, concise, and easy to follow. However, there's a minor grammatical error that should be addressed:

- The examples ships with the latest version of Localnet.
+ The examples ship with the latest version of Localnet.

This correction ensures grammatical accuracy while maintaining the informative nature of the setup instructions.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Option 1: Using the Example Contracts Repository
Once the localnet is started you will see the standard Anvil output with a list
of accounts, private keys as well as the output from protocol contracts being
deployed. After the localnet is set up you will see a list of protocol contract
addresses:
To get started with the example contracts, clone the repository and install the
dependencies:
```
EVM Contract Addresses
======================
Gateway EVM: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
ZETA: 0x5FbDB2315678afecb367f032d93F642f64180aa3
ZetaChain Contract Addresses
============================
Gateway ZetaChain: 0x610178dA211FEF7D417bC0e6FeD39F05609AD788
ZETA: 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853
ZRC-20 ETH: 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c
git clone https://github.com/zeta-chain/example-contracts
cd example-contracts/universal/hello
yarn
```
Keep the terminal window with localnet running open and open a new terminal.
Compile the contracts and deploy both a Hello universal app contract and a
Receiver contract.
Localnet is installed from the `@zetachain/localnet` package. If you need to
update Localnet, run:
```
yarn deploy
yarn add --dev @zetachain/localnet
```
Universal app contract address:
```
🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82
```
The examples ships with the latest version of Localnet.
Receiver contract:
Start the Localnet by running:
```
🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x9A676e781A523b5d0C0e43731313A708CB607508
npx hardhat localnet
```
Even though both contracts are deployed on the same local testnet we will think
of Hello as running on ZetaChain and Receiver as running on a generic EVM chain.
These two contracts are connected with each other through the
[gateway](/developers/evm/gateway).
This command initializes the local development environment with all necessary
contracts and configurations.
## Call a Universal App from EVM
# Option 2: Using the Localnet Repository
Call the `depositAndCall` function on the EVM gateway to call a universal app
contract:
If you prefer to set up Localnet independently, clone the Localnet repository:
```
yarn hardhat deposit-and-call --contract 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 --amount 2 --message bob --network localhost --revert-address 0x9A676e781A523b5d0C0e43731313A708CB607508 --revert-message 0x --call-on-revert
git clone https://github.com/zeta-chain/localnet
cd localnet
```
The command calls the `depositAndCall` function on the EVM gateway.
The EVM gateway emits a "Deposited" event acknowledging that the function call
has been successful:
Install the necessary packages:
```
[EVM]: Gateway: 'Deposited' event emitted
```
Localnet picks up the "Deposited" event and calls the ZetaChain's gateway
`execute` function, which calls the universal app:
```
[ZetaChain]: Universal contract 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82 executing onCrossChainCall (context: {"origin":"0x610178dA211FEF7D417bC0e6FeD39F05609AD788","sender":"0x735b14BB79463307AAcBED86DAf3322B1e6226aB","chainID":1}), zrc20: 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c, amount: 2000000000000000000, message: 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003626f620000000000000000000000000000000000000000000000000000000000)
yarn
```
The `onCrossChainCall` is executed and emits an event:
Start the Localnet by running:
```
[ZetaChain]: Event from onCrossChainCall: {"_type":"log","address":"0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82","blockHash":"0xc8a8ebc484c5330f118a9e838587b918657ca2b347b7b76846236c00e44006bd","blockNumber":23,"data":"0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001a48656c6c6f2066726f6d206120756e6976657273616c206170700000000000000000000000000000000000000000000000000000000000000000000000000003626f620000000000000000000000000000000000000000000000000000000000","index":2,"removed":false,"topics":["0x39f8c79736fed93bca390bb3d6ff7da07482edb61cd7dafcfba496821d6ab7a3"],"transactionHash":"0x3a6612c174d980a13e3ee6b17a21c4708f0f31b823c1fba1037fc6c4124a7b68","transactionIndex":0}
npx hardhat localnet
```
# Option 1: Using the Example Contracts Repository
To get started with the example contracts, clone the repository and install the
dependencies:
```
git clone https://github.com/zeta-chain/example-contracts
cd example-contracts/universal/hello
yarn
```
Localnet is installed from the `@zetachain/localnet` package. If you need to
update Localnet, run:
```
yarn add --dev @zetachain/localnet
```
The examples ship with the latest version of Localnet.
Start the Localnet by running:
```
npx hardhat localnet
```
This command initializes the local development environment with all necessary
contracts and configurations.
# Option 2: Using the Localnet Repository
If you prefer to set up Localnet independently, clone the Localnet repository:
```
git clone https://github.com/zeta-chain/localnet
cd localnet
```
Install the necessary packages:
```
yarn
```
Start the Localnet by running:
```
npx hardhat localnet
```
🧰 Tools
🪛 LanguageTool

[grammar] ~56-~56: You should probably use “ship”.
Context: ...v @zetachain/localnet ``` The examples ships with the latest version of Localnet. S...

(AGREEMENT_SENT_START)

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.

1 participant