Skip to content

Commit 6a33060

Browse files
Merge pull request #1171 from multiversx/development
Development
2 parents 4cf9f1f + 4f572be commit 6a33060

File tree

3 files changed

+50
-58
lines changed

3 files changed

+50
-58
lines changed

docs/developers/tutorials/your-first-dapp.md

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Build a dApp in 15 minutes
55

66
[comment]: # (mx-abstract)
77

8-
Let's build your first decentralized application(dApp) on the MultiversX Blockchain!
8+
Let's build your first decentralized application (dApp) on the MultiversX Blockchain!
99

1010
## Prerequisites
1111

@@ -15,7 +15,7 @@ Before starting this tutorial, make sure you have the following:
1515
- `stable` Rust version `≥ 1.85.0` (install via [rustup](/docs/developers/toolchain-setup.md#installing-rust-and-sc-meta))
1616
- `multiversx-sc-meta` (cargo install [multiversx-sc-meta](/docs/developers/meta/sc-meta-cli.md))
1717
- `Node.js` with version `≥ 20`(guide [here](https://nodejs.org/en/download/package-manager))
18-
- `yarn` ([npm install --global yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable) )
18+
- `pnpm` ([npm install --global pnpm](https://pnpm.io/installation) )
1919

2020
:::
2121

@@ -34,13 +34,13 @@ The **Ping-Pong app** is a very simple decentralized application that allows use
3434

3535
Endpoints available:
3636

37-
- `ping`: sending funds to the contract.
37+
- `ping`: sending funds to the contract;
3838
- `pong`: claiming the same amount back.
3939

4040
Rules:
4141

42-
- Each user can only `ping` once before they `pong`.
43-
- The `ping` amount must be exactly the specified valueno more, no less.
42+
- Each user can only `ping` once before they `pong`;
43+
- The `ping` amount must be exactly the specified value - no more, no less;
4444
- `pong` becomes available only after a set waiting period following a `ping`.
4545

4646
[comment]: # (mx-exclude-context)
@@ -55,7 +55,7 @@ Rules:
5555

5656
For the web application, we will have two pages:
5757

58-
- **Sign in** - The page where you can authenticate using the **xPortal app**, **Ledger**, **DeFi Wallet**, **xAlias**, **Web Wallet**, **Passkey Proxy** or with **Metamask proxy**;
58+
- **Sign in** - The page where you can authenticate using the **xPortal App**, **Ledger**, **DeFi Wallet**, **xAlias**, **Web Wallet**, **Passkey Proxy** or **Metamask Proxy**;
5959
- **Dashboard** - Here, you can either `ping` or `pong`. If you have already deposited, you will see a countdown timer until the time interval resets.
6060

6161
[comment]: # (mx-context-auto)
@@ -73,14 +73,14 @@ The contract also includes several views, storage mappers and one event:
7373
- `getPongEnableTimestamp`: **view** that provides the timestamp when `pong` will be available for a given address;
7474
- `getTimeToPong`: **view** that shows the remaining time until `pong` is enabled for a specific address;
7575
- `getAcceptedPaymentToken`: **storage mapper** that saves the token type allowed for deposits;
76-
- `getPingAmount`: **storage mapper** that records recording the total amount of tokens deposited;
77-
- `getDurationTimestamp`: **storage mapper** that saves the lock duration (in seconds) before `pong` can be called after a `ping`;
76+
- `getPingAmount`: **storage mapper** that records the total amount of tokens deposited;
77+
- `getDurationTimestamp`: **storage mapper** that saves the lock duration (in milliseconds) before `pong` can be called after a `ping`;
7878
- `getUserPingTimestamp`: **storage mapper** that saves the timestamp of the block where the user `ping`-ed;
7979
- `pongEvent`: **event** that signals a successful `pong` by the user with amount.
8080

8181
Think of this smart contract as the API for our dApp, handling all the core business logic.
8282

83-
To test it out, we will use [MultiversX Blockchain Devnet Explorer](https://devnet-explorer.multiversx.com/)a public test network maintained by our community.
83+
To test it out, we will use [MultiversX Blockchain Devnet Explorer](https://devnet-explorer.multiversx.com/) - a public test network maintained by our community.
8484

8585
[comment]: # (mx-context-auto)
8686

@@ -107,7 +107,7 @@ By the time we are done, our project will have three subfolders: wallet, contrac
107107

108108
### Create wallet
109109

110-
To deploy a smart contract to the blockchain, you will need a wallet-a PEM file is recommended for simplicity and ease of testing.
110+
To deploy a smart contract to the blockchain, you will need a wallet: a **PEM file** is recommended for simplicity and ease of testing.
111111

112112
:::important
113113
Make sure you are in the `ping-pong/` folder before continuing.
@@ -124,7 +124,7 @@ PEM wallets are recommended only for testing and experimenting with non-producti
124124

125125
To initiate transactions on the blockchain, your wallet needs funds to cover transaction fees, commonly referred to as **gas**.
126126

127-
The [MultiversX Devnet](https://devnet-wallet.multiversx.com/dashboard) offers a **faucet** where you can claim **5 EGLD every 24 hours**. Here’s how to fund your wallet:
127+
The [MultiversX Devnet](https://devnet-wallet.multiversx.com/dashboard) offers a **faucet** where you can claim **5 EGLD**. You can recall the faucet every **24 hours** if your balance is **lower than 1 EGLD**. Here’s how to fund your wallet:
128128

129129
1. Go to [Devnet Wallet MultiversX](https://devnet-wallet.multiversx.com/unlock/pem) and log in using your newly generated **PEM** file;
130130
2. Once logged in, open the **Faucet** from the **Tools**;
@@ -136,9 +136,9 @@ The [MultiversX Devnet](https://devnet-wallet.multiversx.com/dashboard) offers a
136136

137137
## The Blockchain Layer
138138

139-
With the wallet setup complete, let's move on to the backendthe blockchain layer.
139+
With the wallet setup complete, let's move on to the backend - the blockchain layer.
140140

141-
Let's start with the smart contract. You will first clone the Ping-Pong sample contract repository from [here](https://github.com/multiversx/mx-ping-pong-sc).
141+
Let's start with the smart contract. You will first clone the Ping-Pong sample contract [repository](https://github.com/multiversx/mx-ping-pong-sc).
142142

143143
:::important
144144
Make sure you are still in the `ping-pong/` folder.
@@ -154,7 +154,7 @@ This will create a **contract** folder within ping-pong, containing all the nece
154154

155155
### Build the Smart Contract
156156

157-
Now that you have the source code for the smart contract, you need to compile it into a **binary** that the **MultiversX Virtual Machine** can execute. Since the VM runs Web Assembly (WASM) code, you need to compile our Rust source code into a WASM file.
157+
Now that you have the source code for the smart contract, you need to compile it into a **binary** that the **MultiversX Virtual Machine** (VM) can execute. Since the VM runs Web Assembly (WASM) code, you need to compile our Rust source code into a WASM file.
158158

159159
At path `ping-pong/`, run the following command to build the smart contract into a WASM file.
160160

@@ -179,32 +179,30 @@ Ensure that `wallet_owner.pem` is in the `wallet/` folder and that the smart con
179179

180180
Before deploying, you will need to modify the wallet from which transactions are made. Currently, they are made from a test wallet. To use the wallet you created [earlier](./your-first-dapp.md#create-wallet), you will need to make the following changes:
181181

182-
In the file `interact.rs` located at the path `ping-pong/contract/ping-pong/interactor/src`, the variable `alice_wallet_address` from `new` function will be modified.
182+
In the file [`interact.rs`](https://github.com/multiversx/mx-ping-pong-sc/blob/e1b3e0e9657e83ad11cc0069c0fc7183f91a2fe1/ping-pong/interactor/src/interact.rs#L84) located at the path `ping-pong/contract/ping-pong/interactor/src`, the variable `wallet_address_1` from `new` function will be modified.
183183

184184
```rust title="Before"
185-
let alice_wallet_address = interactor.register_wallet(test_wallets::alice()).await;
185+
let wallet_address_1 = interactor.register_wallet(test_wallets::alice()).await;
186186
```
187187

188188
```rust title="After"
189-
let alice_wallet_address = interactor
189+
let wallet_address_1 = interactor
190190
.register_wallet(Wallet::from_pem_file("../../../wallet/wallet-owner.pem").unwrap())
191191
.await;
192192
```
193193

194194
:::note
195195
You need to replace with the relative path from the **interactor crate** to the **created wallet**.
196196

197-
The interactor crate is located at `ping-pong/contract/ping-pong/interactor` and the wallet is in a higher-level directory: `ping-pong/wallet`.
197+
The interactor crate is located at `ping-pong/contract/ping-pong/interactor`, and the wallet is in a higher-level directory: `ping-pong/wallet`.
198198

199-
To access `wallet-owner.pem` you must navigate up three folders: `../../../`, then into the **wallet** directory.
199+
Alternatively, you can add the absolute path of `wallet-owner.pem`.
200200
:::
201201

202-
Make sure to add the absolute path at `Wallet::from_pem_file("/ping-pong/wallet/wallet-owner.pem")`, completing the missing directories above "ping-pong".
203-
204202
This next command deploys the Ping-Pong contract with the following settings:
205203

206204
- Ping Amount: **1 EGLD**.
207-
- Lock Duration: **180 seconds** (3 minutes).
205+
- Lock Duration: **180000 milliseconds** (3 minutes).
208206

209207
:::important
210208
Ensure that you run the next command inside the **interactor** crate, located at:
@@ -213,23 +211,23 @@ Ensure that you run the next command inside the **interactor** crate, located at
213211
:::
214212

215213
```bash
216-
cargo run deploy --ping-amount 1000000000000000000 --duration-in-seconds 180
214+
cargo run deploy --amount 1000000000000000000 --duration 180000
217215
```
218216

219217
```sh title=output
220218
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s
221-
Running `/ping-pong/contract/target/debug/ping-pong-interact deploy --ping-amount 1000000000000000000 --duration-in-seconds 180`
222-
sender's recalled nonce: 12422
223-
-- tx nonce: 12422
224-
sc deploy tx hash: b6ca6c8e6ac54ed168bcd6929e762610e2360674f562115107cf3702b8a22467
225-
deploy address: erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6
226-
new address: erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6
219+
Running `/ping-pong/contract/target/debug/ping-pong-interact deploy --amount 1000000000000000000 --duration 180000`
220+
sender's recalled nonce: 0
221+
-- tx nonce: 0
222+
sc deploy tx hash: 93ff495b02eb84f0f427f4f02e2c0ce10e667a3511807db8781e1eaed47f9d16
223+
deploy address: erd1qqqqqqqqqqqqqpgq0dw0cfqeknm43sxzzeg5h5j3ewwu8gyd0vdqq4jutd
224+
new address: erd1qqqqqqqqqqqqqpgq0dw0cfqeknm43sxzzeg5h5j3ewwu8gyd0vdqq4jutd
227225
```
228226
229227
Once the command runs, review the log output carefully. Two key details to note:
230228
231-
- Contract Address: in the example presented below is erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6
232-
- Transaction Hash: in the example presented below is b6ca6c8e6ac54ed168bcd6929e762610e2360674f562115107cf3702b8a22467
229+
- **Contract Address**: in the example presented below, it is erd1qqqqqqqqqqqqqpgq0dw0cfqeknm43sxzzeg5h5j3ewwu8gyd0vdqq4jutd
230+
- **Transaction Hash**: in the example presented below, it is 93ff495b02eb84f0f427f4f02e2c0ce10e667a3511807db8781e1eaed47f9d16
233231
234232
We will take a look at the transaction details. Let's check them in the [Devnet Explorer](https://devnet-explorer.multiversx.com).
235233

@@ -276,23 +274,19 @@ Then edit this instruction and change it to the contract address that you create
276274

277275
![img](/developers/tutorial/config-screenshot.png)
278276

279-
:::important
280-
Make sure you have [**yarn installed**](https://classic.yarnpkg.com/lang/en/docs/install) on your machine.
281-
:::
282-
283277
Navigate to the `ping-pong/dapp` folder and install the required dependencies:
284278

285279
```sh
286-
npm install --global yarn
287-
yarn add vite --dev
280+
npm install --global pnpm
281+
pnpm install
288282
```
289283

290284
### Start the Development Server
291285

292286
To test your dApp locally, start a development server with the following command:
293287

294288
```sh
295-
yarn start:devnet
289+
pnpm start-devnet
296290
```
297291

298292
### Running and Accessing the dApp

docs/sovereign/local-setup.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ cd sovereignBridge
8080
# Owner Configuration
8181
WALLET="~/wallet.pem"
8282

83-
# Main Chain Constants
83+
# Main chain network config
8484
MAIN_CHAIN_ELASTIC=https://testnet-index.multiversx.com
8585
PROXY = https://testnet-gateway.multiversx.com
8686
CHAIN_ID = T
@@ -91,7 +91,7 @@ cd sovereignBridge
9191
```
9292

9393
:::note
94-
- **SOVEREIGN_DIRECTORY, TXS_OUTFILE_DIRECTORY, CONTRACTS_DIRECTORY** - represent the paths to the location where the deployment scripts will generate the outputs.
94+
- **SOVEREIGN_DIRECTORY, OUTFILE_PATH, CONTRACTS_DIRECTORY** - represent the paths to the location where the deployment scripts will generate the outputs.
9595
- **WALLET** - should represent the wallet generated at Step 2.2.
9696
- **MAIN_CHAIN_ELASTIC** - represents the elasticsearch db from the main chain
9797
- **PROXY** - in this case, for the purpose of the test, the used proxy is the testnet one. Of course that the proper proxy should be used when deploying your own set of contracts depending on the development phase of your project.
@@ -109,16 +109,27 @@ cd sovereignBridge
109109
source script.sh
110110
```
111111

112+
6. Create and deploy main chain observer:
113+
```bash
114+
createAndDeployMainChainObserver
115+
```
116+
117+
:::info
118+
After running this command, one should wait until the observer is fully synchronized.
119+
:::
120+
112121
6. Deploy all cross-chain contracts on main chain and deploy Sovereign Chain with all required services:
113122
```bash
114123
deploySovereignWithCrossChainContracts sov
115124
```
116125

117-
:::info
118-
`deploySovereignWithCrossChainContracts` command will:
119-
- deploy all main chain smart contracts and update sovereign configs
120-
- deploy sovereign nodes and the main chain observer
121-
- `sov` is the prefix for ESDT tokens in the sovereign chain - it can be changed to any string consisting of 4 lowercase alphanumeric characters
126+
:::info
127+
`deploySovereignWithCrossChainContracts` command will:
128+
- deploy all smart contracts on the main chain and update the sovereign chain configuration
129+
- set up sovereign nodes and deploy the main chain observer
130+
- use `sov` as the default prefix for ESDT tokens on the sovereign chain
131+
(can be changed to any 1–4 character lowercase alphanumeric string and **must be unique across all deployed sovereign chains**)
132+
- if no prefix is provided, a random one will be generated
122133
:::
123134

124135
### Step 3: Deploy services
@@ -139,16 +150,3 @@ ___
139150
```bash
140151
stopAndCleanSovereign
141152
```
142-
143-
## Upgrade and reset local Sovereign Chain
144-
145-
1. Navigate to `mx-chain-sovereign-go/scripts/testnet/sovereignBridge`.
146-
Source the script:
147-
```bash
148-
source script.sh
149-
```
150-
151-
2. Upgrade and reset the chain, and all sovereign services:
152-
```bash
153-
sovereignUpgradeAndReset
154-
```
-177 KB
Loading

0 commit comments

Comments
 (0)