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
Copy file name to clipboardExpand all lines: docs/developers/tutorials/your-first-microservice.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ This guide has been made available in video format as well:
20
20
21
21
## Ping Pong Microservice
22
22
23
-
This guide extends the decentralized app we have built in our previous guide [**Build a dApp in 15 minutes**](/developers/tutorials/your-first-dapp). If you haven't followed it so far, [please do it now](https://www.youtube.com/watch?v=IdkgvlK3rb8).
23
+
This guide extends the decentralized app we have built in our previous guide [**Build a dApp in 15 minutes**](/developers/tutorials/your-first-dapp). If you haven't followed it so far, please do it now.
24
24
25
25
In this guide we're going to build a microservice (an API), which is an intermediary layer between the blockchain layer and the app layer. Our app will consume this microservice instead of making requests directly on the blockchain.
26
26
@@ -97,7 +97,7 @@ We'll find a configuration file specific for every network we want to deploy the
97
97
98
98
First we're going to configure the redis server url. If we run a redis-server on the same machine (or on our development machine) then we can leave the default value.
99
99
100
-
Now we'll move on to the smart contract address. We can find it in our `dapp` repository (if we followed the previous guide ["Build a dApp in 15 minutes"](https://www.youtube.com/watch?v=IdkgvlK3rb8)). If you don't have a smart contract deployed on devnet, then we suggest to follow the previous guide first and then get back to this step.
100
+
Now we'll move on to the smart contract address. We can find it in our `dapp` repository (if we followed the previous guide ["Build a dApp in 15 minutes"](/docs/developers/tutorials/your-first-dapp.md)). If you don't have a smart contract deployed on devnet, then we suggest to follow the previous guide first and then get back to this step.
101
101
102
102
Set the `contracts.pingPong` key with the value for the smart contract address and we're done with configuring the microservice.
103
103
@@ -107,13 +107,13 @@ Set the `contracts.pingPong` key with the value for the smart contract address a
107
107
108
108
We'll install the dependencies using npm
109
109
110
-
```
110
+
```sh
111
111
npm install
112
112
```
113
113
114
114
and then we will start the microservice for the devnet:
115
115
116
-
```
116
+
```sh
117
117
npm run start:devnet
118
118
```
119
119
@@ -211,29 +211,29 @@ We can now verify that on the dashboard we still have the countdown and the Pong
211
211
212
212
You can also find the complete code on our public repository for the dApp in the branch `microservice`:
###Let's deep dive into the microservice code and explain the 2 basic features we implemented.
220
+
## Let's deep dive into the microservice code and explain the 2 basic features we implemented
221
221
222
222
We want to minimize the number of requests done directly on the blockchain because of the overhead they incur, so we'll first read the time to `pong` from the blockchain, we'll cache that value and all the subsequent reads will be done from the cache. That value won't change over time. It will only reset AFTER we `pong`.
@@ -257,7 +257,7 @@ The function `this.getPongDeadlineRaw` will invoke the only read action on the b
257
257
258
258
[comment]: # (mx-context-auto)
259
259
260
-
## The Transaction Processor
260
+
### The Transaction Processor
261
261
262
262
After the user clicks the `Pong` button and performs the `pong` transaction, we have to invalidate the cache and we will use the transaction processor to identify all the `pong` transactions on the blockchain that have the receiver set to our smart contract address.
0 commit comments