You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To ensure the correct functioning of the bridge, as a MultiversX token owner please ensure the following points are met:
69
+
* if you make use of the transfer-role on your token, remember to grant the role also on the **Safe**, **MultiTransfer**, **BridgedTokensWrapper**, and **BridgeProxy** contracts;
70
+
* do not freeze the above-mentioned contracts;
71
+
* do not wipe tokens on the above-mentioned contracts.
72
+
73
+
Failure to comply with these rules will force the bridge owner to blacklist the token in order to restore the correct functioning of the bridge.
1.**Create a wallet** to handle your transactions.
21
-
2.**Build** and **deploy** a contract.
25
+
2.**Build** and **deploy** a contract.
22
26
23
27
[comment]: #(mx-context-auto)
24
28
@@ -28,11 +32,13 @@ You are going to use `sc-meta` to:
28
32
29
33
The **Ping-Pong app** is a very simple decentralized application that allows users to deposit a specific number of tokens to a smart contract address and to lock them for a specific amount of time. After this time interval passes, users can claim back the same amount of tokens.
30
34
31
-
Endpoints available:
35
+
Endpoints available:
36
+
32
37
-`ping`: sending funds to the contract.
33
38
-`pong`: claiming the same amount back.
34
39
35
40
Rules:
41
+
36
42
- Each user can only `ping` once before they `pong`.
37
43
- The `ping` amount must be exactly the specified value—no more, no less.
38
44
-`pong` becomes available only after a set waiting period following a `ping`.
@@ -57,10 +63,12 @@ For the web application, we will have two pages:
57
63
### Blockchain Layer - Backend
58
64
59
65
You will interact with a smart contract that provides the following features:
66
+
60
67
-`ping`: users send tokens to the contract, locking them for a specific period;
61
68
-`pong`: users retrieve their funds, but only after the lock period expires.
62
69
63
70
The contract also includes several views, storage mappers and one event:
71
+
64
72
-`didUserPing`: **view** that tells if a specific user has already `ping`-ed (_true_) or not (_false_);
65
73
-`getPongEnableTimestamp`: **view** that provides the timestamp when `pong` will be available for a given address;
66
74
-`getTimeToPong`: **view** that shows the remaining time until `pong` is enabled for a specific address;
@@ -86,9 +94,9 @@ Let's set up the environment for getting your first dApp up and running.
86
94
87
95
Start by creating a new folder for your project. Let's call it `ping-pong`.
88
96
89
-
```sh
97
+
```bash
90
98
mkdir -p ping-pong
91
-
cd ping-pong
99
+
cd ping-pong/
92
100
```
93
101
94
102
By the time we are done, our project will have three subfolders: wallet, contract, and dapp.
@@ -101,20 +109,23 @@ By the time we are done, our project will have three subfolders: wallet, contrac
101
109
102
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.
103
111
104
-
Make sure you are in the `ping-pong` folder.
112
+
:::important
113
+
Make sure you are in the `ping-pong/` folder before continuing.
114
+
:::
105
115
106
-
```sh
116
+
```bash
107
117
mkdir -p wallet
108
118
sc-meta wallet new --format pem --outfile ./wallet/wallet-owner.pem
109
119
```
110
120
111
-
:::info
121
+
:::tip
112
122
PEM wallets are recommended only for testing and experimenting with non-production code. For real applications, always follow best practices and use secure wallets that can be generated [here](https://wallet.multiversx.com).
113
123
:::
114
124
115
125
To initiate transactions on the blockchain, your wallet needs funds to cover transaction fees, commonly referred to as **gas**.
116
126
117
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:
128
+
118
129
1. Go to [Devnet Wallet MultiversX](https://devnet-wallet.multiversx.com/unlock/pem) and log in using your newly generated **PEM** file;
119
130
2. Once logged in, open the **Faucet** from the **Tools**;
120
131
3. Request **5 xEGLD** to top up your wallet with test EGLD.
@@ -129,11 +140,14 @@ With the wallet setup complete, let's move on to the backend—the blockchain la
129
140
130
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).
131
142
132
-
Make sure you are still in the **ping-pong** folder.
143
+
:::important
144
+
Make sure you are still in the `ping-pong/` folder.
This will create a **contract** folder within ping-pong, containing all the necessary files for the Ping-Pong smart contract.
138
152
139
153
[comment]: #(mx-context-auto)
@@ -159,28 +173,45 @@ This file contains the bytecode for the smart contract, ready to be deployed on
159
173
160
174
Next, let's deploy the smart contract to the blockchain.
161
175
162
-
Make sure `wallet_owner.pem` is in the `wallet/` folder and that the smart contract is built.
176
+
:::tip
177
+
Ensure that `wallet_owner.pem` is in the `wallet/` folder and that the smart contract is built.
178
+
:::
163
179
164
180
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:
165
181
166
-
At the path `/ping-pong/contract/ping-pong/interactor/src` you will run:
167
-
168
-
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 from:
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.
You need to replace with the relative path from the **interactor crate** to the **created wallet**.
196
+
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`.
198
+
199
+
To access `wallet-owner.pem` you must navigate up three folders: `../../../`, then into the **wallet** directory.
200
+
:::
201
+
178
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".
179
203
180
204
This next command deploys the Ping-Pong contract with the following settings:
205
+
181
206
- Ping Amount: **1 EGLD**.
182
207
- Lock Duration: **180 seconds** (3 minutes).
183
208
209
+
:::important
210
+
Ensure that you run the next command inside the **interactor** crate, located at:
211
+
212
+
`ping-pong/contract/ping-pong/interactor`
213
+
:::
214
+
184
215
```bash
185
216
cargo run deploy --ping-amount 1000000000000000000 --duration-in-seconds 180
new address: erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6
196
227
```
228
+
197
229
Once the command runs, review the log output carefully. Two key details to note:
230
+
198
231
- Contract Address: in the example presented below is erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6
199
232
- Transaction Hash: in the example presented below is b6ca6c8e6ac54ed168bcd6929e762610e2360674f562115107cf3702b8a22467
200
233
@@ -209,6 +242,7 @@ With the smart contract successfully deployed, you can now interact with it usin
209
242
The smart contract source code resides in`ping-pong/contract/ping-pong/src/ping_pong.rs`.
210
243
211
244
The contract includes several view functions for querying information. These are invoked using the [MultiversX API](https://devnet-gateway.multiversx.com/#/vm-values/post_vm_values_query):
245
+
212
246
- `didUserPing`;
213
247
- `getPongEnableTimestamp`;
214
248
- `getTimeToPong`;
@@ -269,7 +303,7 @@ If the server is hosted on a remote machine, access it using the server's IP add
269
303
270
304
The production build of the app consists only of static files, so you can deploy it on any hosting platform you prefer.
271
305
272
-
Once the development server is up and running, seeing the _Template dApp_ screen confirms that your application is live and ready!
306
+
Once the development server is up and running, seeing the _Template dApp_ screen confirms that your application is live and ready!
0 commit comments