Skip to content

Commit b1e25f0

Browse files
SaeeDawodsaeeddawodbl0upjanb87
authored
feat: add sdk examples (#141)
## Summary by Sourcery Add SDK examples for creating and managing middleware to the documentation. New Features: - Added usage examples for the SettleMint SDK for JavaScript, including how to create, list, read, and delete middleware. Documentation: - Document how to add and manage middleware using the Platform UI, SDK CLI, and SDK JS. --------- Co-authored-by: saeeddawod <saeed.dawod@gmail.com> Co-authored-by: bl0up <ambroise.m2@gmail.com> Co-authored-by: Jan Bevers <12234016+janb87@users.noreply.github.com>
1 parent 2756a02 commit b1e25f0

File tree

11 files changed

+1339
-537
lines changed

11 files changed

+1339
-537
lines changed

docs/using-platform/0_create-an-application.md

Lines changed: 105 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,127 @@ description: Guide to creating a blockchain application on SettleMint
44
sidebar_position: 1
55
---
66

7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
710
# Create an application
811

912
An application is the context in which you organize your networks, nodes, smart contract sets and any other related blockchain resource.
1013

1114
:::info Note
12-
1315
You will always need to create an application before you can deploy or join networks, and add nodes.
14-
1516
:::
1617

1718
## How to create a new application
1819

20+
<Tabs>
21+
<TabItem value="platform-ui" label="Platform UI">
22+
1923
![Create an App](../../static/img/about-settlemint/create-app.png)
2024

21-
You created your first application when you signed up to use the SettleMint platform, but you can create as many applications as you want within an organization.
25+
1. In the upper right corner of any page, click the **grid icon**.
26+
2. Navigate to your workspace and click **Create new application**.
27+
3. Choose a **name** for your application.
28+
4. Click **Confirm** to create the application.
29+
30+
</TabItem>
31+
<TabItem value="sdk-cli" label="SDK CLI">
32+
33+
First, install the [SDK CLI](https://github.com/settlemint/sdk/blob/main/sdk/cli/README.md#usage) as a global dependency.
34+
35+
Then, ensure you're authenticated. For more information on authentication, see the [SDK CLI documentation](https://github.com/settlemint/sdk/blob/main/sdk/cli/README.md#login-to-the-platform).
36+
```bash
37+
settlemint login
38+
```
39+
40+
Create an application:
41+
```bash
42+
settlemint platform create application <name>
43+
```
44+
45+
</TabItem>
46+
<TabItem value="sdk-js" label="SDK JS">
47+
48+
```typescript
49+
import { createSettleMintClient } from '@settlemint/sdk-js';
50+
51+
const client = createSettleMintClient({
52+
accessToken: 'your_access_token',
53+
instance: 'https://console.settlemint.com'
54+
});
55+
56+
// Create application
57+
const createApp = async () => {
58+
const result = await client.application.create({
59+
workspaceUniqueName: "your-workspace",
60+
name: "myApp"
61+
});
62+
console.log('Application created:', result);
63+
};
64+
65+
// List applications
66+
const listApps = async () => {
67+
const apps = await client.application.list("your-workspace");
68+
console.log('Applications:', apps);
69+
};
2270

23-
Follow these steps to create a new application:
71+
// Read application details
72+
const readApp = async () => {
73+
const app = await client.application.read("app-unique-name");
74+
console.log('Application details:', app);
75+
};
2476

25-
1. In the upper right corner of any page, click the **grid icon**. Here you see an overview of all your organizations and applications.
26-
2. Navigate to the organization in which you want to create the application, and click **Create new application**.
27-
3. Choose a **name** for your application. Choose one that is easily recognizable in your dashboards. You may want to choose a name related to what you are building, e.g. track and trace, NFT, data exchange, etc. You can change the name of your application at any time.
28-
4. Click **Confirm** to go to the application dashboard. The dashboard is still empty for now. Start by [adding a network to the application](1_add-a-network-to-an-application.md).
77+
// Delete application
78+
const deleteApp = async () => {
79+
await client.application.delete("application-unique-name");
80+
};
81+
```
82+
83+
:::tip
84+
Get your access token from the Platform UI under User Settings → API Tokens.
85+
:::
86+
87+
</TabItem>
88+
</Tabs>
2989

3090
## Manage an application
3191

32-
Navigate to the **application dashboard**.
92+
<Tabs>
93+
<TabItem value="platform-ui" label="Platform UI">
94+
95+
Navigate to your application and click **Manage app** to see available actions:
96+
- View application details
97+
- Update application name
98+
- Delete application
99+
100+
</TabItem>
101+
<TabItem value="sdk-cli" label="SDK CLI">
102+
103+
```bash
104+
# List applications
105+
settlemint platform list applications
106+
107+
# Delete application
108+
settlemint platform delete application <name>
109+
```
33110

34-
Click **Manage app** to see the available actions. You can only perform these actions if you have administrator rights.
111+
</TabItem>
112+
<TabItem value="sdk-js" label="SDK JS">
35113

36-
- **Change name** - Changes the name of the application without any further impact.
37-
- **Delete application** - Removes the application from the platform.
114+
```typescript
115+
// List applications
116+
await client.application.list("your-workspace");
117+
118+
// Read application
119+
await client.application.read("app-unique-name");
120+
121+
// Delete application
122+
await client.application.delete("app-unique-name");
123+
```
124+
125+
</TabItem>
126+
</Tabs>
127+
128+
:::info Note
129+
All operations require appropriate permissions in your workspace.
130+
:::

docs/using-platform/10_insights.md

Lines changed: 135 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,152 @@
1+
---
2+
title: Insights
3+
description: Guide to using blockchain explorers in SettleMint
4+
---
5+
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
19
# Insights
210

3-
To view and inspect transactions in your blockchain application, SettleMint provides insightful dashboards via the integrated Blockscout blockchain explorer.
11+
To view and inspect transactions in your blockchain application, SettleMint provides insightful dashboards via integrated blockchain explorers:
12+
- **Blockscout** - For EVM compatible networks (Besu, Polygon Edge)
13+
- **Hyperledger Explorer** - For Fabric networks
14+
- **Otterscan** - Alternative EVM explorer with advanced features
415

5-
**Blockscout** can be hooked up to any of your permissioned EVM compatible blockchain networks running in SettleMint. This includes **Hyperledger Besu and Polygon Edge**.
16+
## Add Blockchain Explorer
617

7-
## Adding the blockchain explorer
18+
<Tabs>
19+
<TabItem value="platform-ui" label="Platform UI">
820

921
Navigate to the **application** where you want to add a blockchain explorer. Click **Insights** in the left navigation, and then click **Add Insights**. This opens a form.
1022

11-
Follow these steps to add the blockchain explorer:
12-
23+
Follow these steps:
1324
1. Select **Blockchain Explorer**
14-
2. Select the target **blockchain node** for the blockchain explorer and click **Continue**. Make sure you have a **Hyperledger Besu node or Polygon Edge node** in place.
15-
3. Enter a **name** for this instance of the blockchain explorer.
16-
4. Choose a **deployment plan**. Select the type, cloud provider, region and resource pack. [More about deployment plans](launch-platform/managed-cloud-deployment/3_deployment-plans.md)
17-
5. You see the **resource cost** for this blockchain explorer displayed at the bottom of the form. Click **Confirm** to add the blockchain explorer.
25+
2. Select the target **blockchain node** and click **Continue**
26+
3. Enter a **name** for your explorer instance
27+
4. Configure deployment settings (provider, region, size)
28+
5. Click **Confirm** to add the explorer
29+
30+
</TabItem>
31+
<TabItem value="sdk-cli" label="SDK CLI">
32+
33+
First ensure you're authenticated:
34+
```bash
35+
settlemint login
36+
```
37+
38+
Create blockchain explorer:
39+
```bash
40+
# Create blockchain explorer
41+
settlemint platform create insights blockscout <name>
42+
43+
# Get information about the command and all available options
44+
settlemint platform create insights blockscout --help
45+
```
46+
47+
</TabItem>
48+
<TabItem value="sdk-js" label="SDK JS">
49+
50+
For a full example of how to create a blockchain explorer using the SDK, see the [Blockscout SDK API Reference](https://www.npmjs.com/package/@settlemint/sdk-blockscout#api-reference).
51+
52+
</TabItem>
53+
</Tabs>
54+
55+
## Manage Explorer
56+
57+
<Tabs>
58+
<TabItem value="platform-ui" label="Platform UI">
59+
60+
Navigate to your explorer and click **Manage insights** to:
61+
- View explorer details and status
62+
- Monitor health status
63+
- Access the explorer interface
64+
- Update configurations
65+
66+
Current status values:
67+
- `DEPLOYING` - Initial deployment in progress
68+
- `COMPLETED` - Running normally
69+
- `FAILED` - Deployment or operation failed
70+
- `PAUSED` - Explorer is paused
71+
- `RESTARTING` - Explorer is restarting
72+
73+
Health status indicators:
74+
- `HEALTHY` - Operating normally
75+
- `HAS_INDEXING_BACKLOG` - Processing backlog
76+
- `NOT_HA` - High availability issue
77+
- `NO_PEERS` - Network connectivity issue
78+
79+
</TabItem>
80+
<TabItem value="sdk-cli" label="SDK CLI">
81+
82+
```bash
83+
# List explorers
84+
settlemint platform list services --type insights
85+
86+
# Restart explorer
87+
settlemint platform restart insights blockscout <name>
88+
```
89+
90+
</TabItem>
91+
<TabItem value="sdk-js" label="SDK JS">
92+
93+
```typescript
94+
// List explorers
95+
const listExplorers = async () => {
96+
const explorers = await client.insights.list("your-app");
97+
console.log('Explorers:', explorers);
98+
};
99+
100+
// Get explorer details
101+
const getExplorer = async () => {
102+
const explorer = await client.insights.read("explorer-unique-name");
103+
console.log('Explorer details:', explorer);
104+
};
105+
106+
// Restart explorer
107+
const restartExplorer = async () => {
108+
await client.insights.restart("explorer-unique-name");
109+
};
110+
```
111+
112+
</TabItem>
113+
</Tabs>
114+
115+
## Using the Explorer
18116

19-
## Using the blockchain explorer
117+
When the blockchain explorer is deployed and running successfully, you can:
20118

21-
When the blockchain explorer is deployed and running successfully, click it from the list and start using it. Click the **Interface tab** to access the web UI. You can view this in full screen mode by clicking **View in fullscreen mode**.
119+
1. Access the web interface through the **Interface tab**
120+
2. View in fullscreen mode for better visibility
121+
3. Inspect blocks, transactions, addresses and balances
22122

23-
You can inspect all blocks, transactions, addresses and balances.
123+
Key features:
124+
- View latest blocks and transactions
125+
- Search by block number, transaction hash, or address
126+
- Inspect transaction details and status
127+
- View account balances and token transfers
128+
- Monitor smart contract interactions
24129

25-
Click a block in the latest Blocks section to inspect its transactions, or click a transaction form the Transactions section to view its details. You can also click View all Blocks or View all Transactions button to view the full list of transactions or blocks.
130+
![Blockscout Interface](../../static/img/document360/Images/Blockscout%201.png)
26131

27-
![Blockscout 1.png](../../static/img/document360/Images/Blockscout%201.png)
132+
### Transaction Details
133+
Click a Transaction hash to see detailed information including:
134+
- Gas usage and fees
135+
- Input data and events
136+
- Status and confirmations
137+
- Related addresses
28138

29-
Click a Transaction hash to see the Transaction Details
139+
![Transaction View](../../static/img/document360/Images/Blockscout%202.png)
30140

31-
![Blockscout 2.png](../../static/img/document360/Images/Blockscout%202.png)
141+
### Address Details
142+
Click an Account address to view:
143+
- Balance and token holdings
144+
- Transaction history
145+
- Contract interactions
146+
- Analytics and graphs
32147

33-
Click an Account address to see the Address Details
148+
![Address View](../../static/img/document360/Images/Blockscout%203.png)
34149

35-
![Blockscout 3.png](../../static/img/document360/Images/Blockscout%203.png)
150+
:::info Note
151+
All operations require appropriate permissions in your workspace.
152+
:::

0 commit comments

Comments
 (0)