Skip to content

Commit 7b1341e

Browse files
authored
feat: graph middleware not dependant on SCS and IPFS anymore (#109)
## Summary by Sourcery New Features: - Connect the Graph Middleware directly to a blockchain node.
1 parent 511dc27 commit 7b1341e

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

docs/using-platform/11_middleware.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,41 @@ SettleMint offers two Middleware solutions: **The Graph Middleware (for all EVM-
66

77
## Adding a middleware
88

9-
Before adding a middleware make sure that you have installed **smart contract sets** and **IPFS (decentralized)** storage
9+
Before adding a middleware make sure that you have a **blockchain node** running.
1010

1111
Navigate to the **application** where you want to add a middleware. Click **Middleware** in the left navigation, and then click **Add a middleware**. This opens a form.
1212

1313
Follow these steps to add the middleware:
1414

15-
1. Select to which of your **smart contract sets** the middleware needs to connect, and click **Continue**.
16-
2. Choose [Graph Middleware](#the-graph-middleware) or [Smart Contract Portal Middleware](#the-smart-contract-portal-middleware)
17-
3. Choose a **Middleware name**. Choose one that will be easily recognizable in your dashboards.
18-
4. Select the **storage provider** if needed.
19-
5. Choose a **deployment plan**. Select the type, cloud provider, region and resource pack. [More about deployment plans.](../launch-platform/managed-cloud-deployment/13_deployment-plans.md)
20-
6. You see the **resource cost** for this middleware displayed at the bottom of the form. Click **Confirm** to add the smart contract set.
15+
1. Choose [Graph Middleware](#the-graph-middleware) or [Smart Contract Portal Middleware](#the-smart-contract-portal-middleware)
16+
2. Choose a **Middleware name**. Choose one that will be easily recognizable in your dashboards.
17+
3. Select the **blockchain node** you want to connect to. This is the blockchain node that will be used to index the blockchain data.
18+
4. Choose a **deployment plan**. Select the type, cloud provider, region and resource pack. [More about deployment plans.](../launch-platform/managed-cloud-deployment/13_deployment-plans.md)
19+
5. You see the **resource cost** for this middleware displayed at the bottom of the form. Click **Confirm** to add the smart contract set.
2120

2221
When the middleware is deployed, click it from the list and start using it.
2322

2423
## The Graph Middleware
2524

26-
[The Graph](https://thegraph.com/en/) is a protocol for indexing and querying blockchain data from networks. It can be used with all EVM-compatible chains like Ethereum, Hyperledger Besu, Polygon, Avalanche, etc. You can run it on your own blockchain nodes (both public and permissioned) and IPFS nodes.
25+
[The Graph](https://thegraph.com/en/) is a protocol for indexing and querying blockchain data from networks. It can be used with all EVM-compatible chains like Ethereum, Hyperledger Besu, Polygon, Avalanche, etc. You can run it on your own blockchain nodes (both public and permissioned).
2726

28-
Using the Graph protocol, you can create **subgraphs** that define which blockchain data will be indexed. These subgraphs are **defined in the smart contract set** and deployed to the middleware. The middleware will then use these subgraphs to correctly index your smart contracts and expose a developer-friendly and efficient **GraphQL API**, allowing you to query the data you need.
27+
Using the Graph protocol, you can create **subgraphs** that define which blockchain data will be indexed. The middleware will then use these subgraphs to correctly index your smart contracts and expose a developer-friendly and efficient **GraphQL API**, allowing you to query the data you need.
2928

30-
The middleware is fully preconfigured and integrated with the smart contract sets. We have some prebuild subgraph indexing modules, but you can build your own modules if you have a custom smart contract set.
29+
We have some prebuilt subgraph indexing modules included in the smart contract set IDE, and you can build your own modules if you have a custom smart contract set.
3130

3231
:::warning Warning
3332

3433
Before you start, make sure you are running:
3534

36-
- An EVM-compatible network (Ethereum, Polygon, Hyperleder Besu, Avalanche, etc.)
37-
- A smart contract set with a deployed smart contract
38-
- An IPFS node
39-
- A private key
35+
- An EVM-compatible network (Ethereum, Polygon, Hyperledger Besu, Avalanche, etc.)
4036

4137
:::
4238

4339
When the middleware is deployed, follow these steps to start using it:
4440

4541
### Define and deploy a subgraph
4642

47-
Navigate to the **smart contract set** that you connected to the middleware, go the **details** and open the **IDE**. Here you will define the subgraph to set the indexing specifications, and deploy it so it can be loaded into the middleware.
43+
Navigate to the **smart contract set** which you want to index, go the **details** and open the **IDE**. Here you will define the subgraph to set the indexing specifications, and deploy it so it can be loaded into the middleware. There are instructions included in the IDE to help you.
4844

4945
#### Subgraph raw configuration
5046

@@ -117,7 +113,7 @@ Benefits of using the smart contract portal:
117113

118114
Before you start, make sure you are running:
119115

120-
- An EVM-compatible network (Ethereum, Polygon, Hyperleder Besu, Avalanche, etc.)
116+
- An EVM-compatible network (Ethereum, Polygon, Hyperledger Besu, Avalanche, etc.)
121117
- A private key
122118

123119
:::
@@ -161,25 +157,25 @@ Standard Webhooks has built [SDKs and useful tools](https://www.standardwebhooks
161157
An example using Typescript, [Elysia](https://elysiajs.com/) and [standard webhooks](https://www.standardwebhooks.com/).
162158

163159
```ts
164-
import { Elysia, t } from 'elysia';
165-
import { Webhook } from 'standardwebhooks';
160+
import { Elysia, t } from "elysia";
161+
import { Webhook } from "standardwebhooks";
166162

167163
async function webhookConsumerBootstrap(secret: string) {
168164
const webhookConsumer = new Elysia().post(
169-
'/scp-listener',
165+
"/scp-listener",
170166
({ headers, body }) => {
171167
try {
172168
const wh = new Webhook(btoa(secret));
173169
const verifiedPayload = wh.verify(JSON.stringify(body.payload), {
174-
'webhook-id': headers['btp-portal-event-id']!,
175-
'webhook-signature': headers['btp-portal-event-signature']!,
176-
'webhook-timestamp': headers['btp-portal-event-timestamp']!,
170+
"webhook-id": headers["btp-portal-event-id"]!,
171+
"webhook-signature": headers["btp-portal-event-signature"]!,
172+
"webhook-timestamp": headers["btp-portal-event-timestamp"]!,
177173
});
178174
console.log(
179175
`Received a webhook event: ${JSON.stringify(verifiedPayload)}`
180176
);
181177
} catch (err) {
182-
console.error('Webhook payload invalid', err);
178+
console.error("Webhook payload invalid", err);
183179
throw err;
184180
}
185181
},
@@ -206,7 +202,7 @@ async function webhookConsumerBootstrap(secret: string) {
206202
webhookConsumerBootstrap(process.env.WEBHOOK_SECRET!)
207203
.then((app) => app.listen(process.env.PORT || 5555))
208204
.catch((error: Error) => {
209-
console.error('Failed to start webhook consumer', error);
205+
console.error("Failed to start webhook consumer", error);
210206
process.exit(1);
211207
});
212208
```
@@ -218,7 +214,7 @@ The websocket endpoint exposes functionality to get real time updates on process
218214
The url can be copied from the Connect tab.
219215

220216
```ts
221-
import type { TransactionReceipt } from 'viem';
217+
import type { TransactionReceipt } from "viem";
222218

223219
// Should include an api key (eg wss://smart-contract-portal-middleware.settlemint.com/sm_pat_.../ws)
224220
const webSocketHost = process.env.WS_URL!;
@@ -242,7 +238,7 @@ export async function waitForTransactionReceipt(transactionHash: string) {
242238
webSocket.onerror = reject;
243239
webSocket.onclose = () => {
244240
if (!isResolved) {
245-
reject(new Error('Nothing received from the WebSocket'));
241+
reject(new Error("Nothing received from the WebSocket"));
246242
}
247243
};
248244
if (webSocket.readyState === WebSocket.OPEN) {

0 commit comments

Comments
 (0)