|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +--- |
| 4 | + |
| 5 | +# 3-Minute Cross-Chain dApp |
| 6 | + |
| 7 | +This QuickStart guide will run through how to start an Omni cross chain dApp in less than three minutes. |
| 8 | + |
| 9 | +In this guide you will: |
| 10 | + |
| 11 | +- Install the Omni CLI, scaffold a new project and run a local devnet |
| 12 | +- Deploy contracts using foundry to the local devnet and test their functionality |
| 13 | + |
| 14 | +## Steps |
| 15 | + |
| 16 | +### Step 1: Install the Omni CLI |
| 17 | + |
| 18 | +First, install the Omni CLI by running the following command: |
| 19 | + |
| 20 | +```bash |
| 21 | +curl -sSfL https://raw.githubusercontent.com/omni-network/omni/main/scripts/install_omni_cli.sh | sh -s |
| 22 | +``` |
| 23 | + |
| 24 | +You may otherwise install from source by following the steps shown in the [Omni CLI Tools section](../../tools/cli/cli.md). |
| 25 | + |
| 26 | +### Step 2: Scaffold a new project |
| 27 | + |
| 28 | +Next, create a new directory for your project and scaffold a new project using the Omni CLI: |
| 29 | + |
| 30 | +```bash |
| 31 | +mkdir my-omni-dapp |
| 32 | +cd my-omni-dapp |
| 33 | +omni developer new |
| 34 | +``` |
| 35 | + |
| 36 | +Note: this requires [foundry](https://github.com/foundry-rs/foundry) to be installed on your machine. |
| 37 | + |
| 38 | +<details> |
| 39 | +<summary>Test the Contracts with Forge</summary> |
| 40 | + |
| 41 | +You can test the contracts with Forge by running the following command: |
| 42 | + |
| 43 | +```bash |
| 44 | +forge test |
| 45 | +``` |
| 46 | + |
| 47 | +</details> |
| 48 | + |
| 49 | +### Step 3: Run a local devnet |
| 50 | + |
| 51 | +Start a local devnet by running the following command: |
| 52 | + |
| 53 | +```bash |
| 54 | +omni devnet start |
| 55 | +``` |
| 56 | + |
| 57 | +Note: this requires [Docker](https://docs.docker.com/get-docker/) to be installed on your machine. |
| 58 | + |
| 59 | +### Step 4: Deploy contracts |
| 60 | + |
| 61 | +Deploy the contracts to the local devnet using foundry: |
| 62 | + |
| 63 | +<details> |
| 64 | +<summary>Obtaining Parameter Values</summary> |
| 65 | + |
| 66 | +You can obtain RPC URL values and portal addresses for the running devnet chains by running the following command: |
| 67 | + |
| 68 | +```bash |
| 69 | +omni devnet info |
| 70 | +``` |
| 71 | + |
| 72 | +And you the private key value is the first anvil private key, found by running: |
| 73 | + |
| 74 | +```bash |
| 75 | +anvil |
| 76 | +``` |
| 77 | + |
| 78 | +These values are kept in `./script/bash/.env.example` and are used to deploy the contracts. You can rename the file to `.env` and fill in the values for other networks. |
| 79 | + |
| 80 | +</details> |
| 81 | + |
| 82 | +```bash |
| 83 | +bash script/bash/deploy.sh |
| 84 | +``` |
| 85 | + |
| 86 | +### Step 5: Perform a Cross-Chain Greet |
| 87 | + |
| 88 | +You can now perform a cross-rollup greet by running the following command: |
| 89 | + |
| 90 | +<details> |
| 91 | +<summary>Obtaining Deployment Addresses</summary> |
| 92 | + |
| 93 | +You can obtain the XGreeter deployment addresses from the output of the previous forge script deployment. |
| 94 | + |
| 95 | +Because the devnet has just been started, the addresses will be the same as the ones shown below: |
| 96 | + |
| 97 | +```bash |
| 98 | +omni_evm: 0x8464135c8F25Da09e49BC8782676a84730C318bC |
| 99 | +mock_op: 0x8464135c8F25Da09e49BC8782676a84730C318bC |
| 100 | +mock_arb: 0x8464135c8F25Da09e49BC8782676a84730C318bC |
| 101 | +``` |
| 102 | + |
| 103 | +</details> |
| 104 | + |
| 105 | +```bash |
| 106 | +cast send 0x8464135c8F25Da09e49BC8782676a84730C318bC 'greet(string)' 'Yay in 3 minutes!' --private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --rpc-url http://localhost:8001 --value 1ether |
| 107 | +``` |
| 108 | + |
| 109 | +### Step 6: Check the Greet |
| 110 | + |
| 111 | +You can check the greet has been saved on the Omni EVM global state by running the following command: |
| 112 | + |
| 113 | +```bash |
| 114 | +cast call 0x8464135c8F25Da09e49BC8782676a84730C318bC "lastGreet():(uint64,uint256,uint256,address,address,string)" --rpc-url http://localhost:8000 |
| 115 | +``` |
| 116 | + |
| 117 | +### 🎉 Done 🎉 |
| 118 | + |
| 119 | +You have successfully deployed and interacted with an Omni cross-chain dApp in less than three minutes! |
0 commit comments