Skip to content

Commit fdc49c4

Browse files
authored
feat(cli/docs): introduce devnet quickstart guide (#1080)
Introduces scaffolding `hello-world-template` to CLI as default (and using `--template` flag) and the quickstart page to the docs task: https://app.asana.com/0/1206208509925075/1207372351528365/f
1 parent 1d535e1 commit fdc49c4

File tree

4 files changed

+156
-8
lines changed

4 files changed

+156
-8
lines changed

cli/cmd/develop.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"bytes"
5+
"context"
56
"os"
67
"os/exec"
78

@@ -25,22 +26,29 @@ func newDeveloperCmds() *cobra.Command {
2526
}
2627

2728
func newForgeProjectCmd() *cobra.Command {
29+
var cfg developerForgeProjectConfig
30+
2831
cmd := &cobra.Command{
2932
Use: "new",
3033
Short: "Scaffold a Forge project",
31-
Long: `Scaffold a new Forge project with a XGreeter contract
32-
accompanied by simple mocked testing and a multi-chain deployment script.`,
33-
Args: cobra.NoArgs,
34+
Long: `Scaffold a new Forge project accompanied by simple mocked testing and a multi-chain deployment script.`,
35+
Args: cobra.NoArgs,
3436
RunE: func(cmd *cobra.Command, args []string) error {
35-
return newForgeProjectTemplate()
37+
return newForgeProjectTemplate(cmd.Context(), cfg)
3638
},
3739
}
3840

41+
bindDeveloperForgeProjectConfig(cmd, &cfg)
42+
3943
return cmd
4044
}
4145

46+
type developerForgeProjectConfig struct {
47+
templateName string
48+
}
49+
4250
// newForgeProjectTemplate creates a new project using the forge template.
43-
func newForgeProjectTemplate() error {
51+
func newForgeProjectTemplate(_ context.Context, cfg developerForgeProjectConfig) error {
4452
// Check if forge is installed
4553
if !checkForgeInstalled() {
4654
// Forge is not installed, return an error with a suggestion.
@@ -51,7 +59,8 @@ func newForgeProjectTemplate() error {
5159
}
5260

5361
// Execute the `forge init` command.
54-
cmd := exec.Command("forge", "init", "--template", "https://github.com/omni-network/omni-forge-template.git")
62+
// #nosec G204
63+
cmd := exec.Command("forge", "init", "--template", "https://github.com/omni-network/"+cfg.templateName+".git")
5564
cmd.Stdout = os.Stdout
5665
cmd.Stderr = os.Stderr
5766
if err := cmd.Run(); err != nil {

cli/cmd/flags.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func bindAVSAddress(cmd *cobra.Command, addr *string) {
2424
cmd.Flags().StringVar(addr, "avs-address", *addr, "Optional address of the Omni AVS contract")
2525
}
2626

27+
func bindDeveloperForgeProjectConfig(cmd *cobra.Command, cfg *developerForgeProjectConfig) {
28+
cmd.Flags().StringVar(&cfg.templateName, "template", "hello-world-template", "Name of the forge template repo to use found in the omni-network github organization")
29+
}
30+
2731
func bindDevnetAVSAllowConfig(cmd *cobra.Command, cfg *devnetAllowConfig) {
2832
bindRPCURL(cmd, &cfg.RPCURL)
2933
bindAVSAddress(cmd, &cfg.AVSAddr)
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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!

docs/site/sidebars.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ const sidebars: SidebarsConfig = {
202202
},
203203
{
204204
type: "category",
205-
label: "Testnet",
205+
label: "Quickstart",
206206
className: "sidebar-title",
207207
collapsible: false,
208208
items: [
209209
{
210210
type: "autogenerated",
211-
dirName: "develop/testnet",
211+
dirName: "develop/quickstart",
212212
}
213213
]
214214
},
@@ -232,6 +232,22 @@ const sidebars: SidebarsConfig = {
232232
type: "html",
233233
value: "<div class='sidebar-separator'></div>",
234234
},
235+
{
236+
type: "category",
237+
label: "Testnet",
238+
className: "sidebar-title",
239+
collapsible: false,
240+
items: [
241+
{
242+
type: "autogenerated",
243+
dirName: "develop/testnet",
244+
}
245+
]
246+
},
247+
{
248+
type: "html",
249+
value: "<div class='sidebar-separator'></div>",
250+
},
235251
"develop/contracts",
236252
],
237253
operateSidebar: [

0 commit comments

Comments
 (0)