diff --git a/bindings/nodejs/examples/client/00-get-info.ts b/bindings/nodejs/examples/client/00-get-info.ts
deleted file mode 100644
index 2e11b4f3c2..0000000000
--- a/bindings/nodejs/examples/client/00-get-info.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2021-2023 IOTA Stiftung
-// SPDX-License-Identifier: Apache-2.0
-
-import { Client, initLogger } from '@iota/sdk';
-require('dotenv').config({ path: '.env' });
-
-// Run with command:
-// yarn run-example ./client/00-get-info.ts
-
-// In this example we will get information about the node
-async function run() {
- initLogger();
- if (!process.env.NODE_URL) {
- throw new Error('.env NODE_URL is undefined, see .env.example');
- }
-
- const client = new Client({
- // Insert your node URL in the .env.
- nodes: [process.env.NODE_URL],
- localPow: true,
- });
-
- try {
- const nodeInfo = await client.getInfo();
- console.log('Node info: ', nodeInfo);
- } catch (error) {
- console.error('Error: ', error);
- }
-}
-
-run().then(() => process.exit());
-
-// Example output:
-// Node info: {
-// nodeInfo: {
-// name: 'HORNET',
-// version: '2.0.0-alpha.25',
-// status: {
-// isHealthy: true,
-// latestMilestone: [Object],
-// confirmedMilestone: [Object],
-// pruningIndex: 0
-// },
-// supportedProtocolVersions: [ 2 ],
-// protocol: {
-// version: 2,
-// networkName: 'dummy-1',
-// bech32Hrp: 'rms',
-// minPowScore: 1500,
-// rentStructure: [Object],
-// tokenSupply: '1450896407249092'
-// },
-// pendingProtocolParameters: [],
-// baseToken: {
-// name: 'Shimmer',
-// tickerSymbol: 'SMR',
-// unit: 'SMR',
-// subunit: 'glow',
-// decimals: 6,
-// useMetricPrefix: false
-// },
-// metrics: {
-// blocksPerSecond: 1.2,
-// referencedBlocksPerSecond: 1.2,
-// referencedRate: 100
-// },
-// features: []
-// },
-// url: 'https://api.testnet.shimmer.network'
-// }
diff --git a/bindings/nodejs/examples/how_tos/client/get-health.ts b/bindings/nodejs/examples/how_tos/client/get-health.ts
new file mode 100644
index 0000000000..f42d21fd83
--- /dev/null
+++ b/bindings/nodejs/examples/how_tos/client/get-health.ts
@@ -0,0 +1,31 @@
+// Copyright 2021-2023 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+import { Client, initLogger } from '@iota/sdk';
+require('dotenv').config({ path: '.env' });
+
+// Run with command:
+// yarn run-example ./how_tos/client/get-health.ts
+
+// In this example we will get the node health
+async function run() {
+ initLogger();
+ if (!process.env.NODE_URL) {
+ throw new Error('.env NODE_URL is undefined, see .env.example');
+ }
+
+ const client = new Client({
+ // Insert your node URL in the .env.
+ nodes: [process.env.NODE_URL],
+ localPow: true,
+ });
+
+ try {
+ const isHealthy = await client.getHealth(process.env.NODE_URL);
+ console.log('Healthy: ', isHealthy);
+ } catch (error) {
+ console.error('Error: ', error);
+ }
+}
+
+run().then(() => process.exit());
diff --git a/bindings/nodejs/examples/how_tos/client/get-info.ts b/bindings/nodejs/examples/how_tos/client/get-info.ts
new file mode 100644
index 0000000000..4c6c4188ff
--- /dev/null
+++ b/bindings/nodejs/examples/how_tos/client/get-info.ts
@@ -0,0 +1,31 @@
+// Copyright 2021-2023 IOTA Stiftung
+// SPDX-License-Identifier: Apache-2.0
+
+import { Client, initLogger } from '@iota/sdk';
+require('dotenv').config({ path: '.env' });
+
+// Run with command:
+// yarn run-example ./how_tos/client/get-info.ts
+
+// In this example we will get information about the node
+async function run() {
+ initLogger();
+ if (!process.env.NODE_URL) {
+ throw new Error('.env NODE_URL is undefined, see .env.example');
+ }
+
+ const client = new Client({
+ // Insert your node URL in the .env.
+ nodes: [process.env.NODE_URL],
+ localPow: true,
+ });
+
+ try {
+ const nodeInfo = (await client.getInfo()).nodeInfo;
+ console.log(nodeInfo);
+ } catch (error) {
+ console.error('Error: ', error);
+ }
+}
+
+run().then(() => process.exit());
diff --git a/bindings/nodejs/examples/client/03-get-address-outputs.ts b/bindings/nodejs/examples/how_tos/client/get-outputs.ts
similarity index 80%
rename from bindings/nodejs/examples/client/03-get-address-outputs.ts
rename to bindings/nodejs/examples/how_tos/client/get-outputs.ts
index d7494bda7f..ebbef29b82 100644
--- a/bindings/nodejs/examples/client/03-get-address-outputs.ts
+++ b/bindings/nodejs/examples/how_tos/client/get-outputs.ts
@@ -5,7 +5,7 @@ import { Client, initLogger } from '@iota/sdk';
require('dotenv').config({ path: '.env' });
// Run with command:
-// yarn run-example ./client/03-get-address-outputs.ts
+// yarn run-example ./how_tos/client/get-outputs.ts
// In this example we will get the outputs of a known address
async function run() {
@@ -30,10 +30,11 @@ async function run() {
{ hasTimelock: false },
{ hasStorageDepositReturn: false },
]);
- console.log('Output ids: ', outputIdsResponse, '\n');
+ console.log('First output of query:');
+ console.log('ID: ', outputIdsResponse.items[0]);
- const addressOutputs = await client.getOutputs(outputIdsResponse.items);
- console.log('Address outputs: ', addressOutputs);
+ const outputs = await client.getOutputs(outputIdsResponse.items);
+ console.log(outputs[0]);
} catch (error) {
console.error('Error: ', error);
}
diff --git a/bindings/python/examples/how_tos/client/get_health.py b/bindings/python/examples/how_tos/client/get_health.py
new file mode 100644
index 0000000000..93e8fe5ef0
--- /dev/null
+++ b/bindings/python/examples/how_tos/client/get_health.py
@@ -0,0 +1,15 @@
+from iota_sdk import Client
+from dotenv import load_dotenv
+import json
+import os
+
+load_dotenv()
+
+node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network')
+
+# Create a Client instance
+client = Client(nodes=[node_url])
+
+# Get the node health
+is_healthy = client.get_health(node_url)
+print(f'Healthy: {is_healthy}')
diff --git a/bindings/python/examples/client/00_get_info.py b/bindings/python/examples/how_tos/client/get_info.py
similarity index 71%
rename from bindings/python/examples/client/00_get_info.py
rename to bindings/python/examples/how_tos/client/get_info.py
index 3ef8ebdb0a..d29cde7e43 100644
--- a/bindings/python/examples/client/00_get_info.py
+++ b/bindings/python/examples/how_tos/client/get_info.py
@@ -1,5 +1,6 @@
from iota_sdk import Client
from dotenv import load_dotenv
+import json
import os
load_dotenv()
@@ -10,5 +11,5 @@
client = Client(nodes=[node_url])
# Get the node info
-node_info = client.get_info()
-print(f'{node_info}')
+node_info = client.get_info()["nodeInfo"]
+print(f'{json.dumps(node_info, indent=4)}')
diff --git a/bindings/python/examples/client/03_get_address_outputs.py b/bindings/python/examples/how_tos/client/get_outputs.py
similarity index 84%
rename from bindings/python/examples/client/03_get_address_outputs.py
rename to bindings/python/examples/how_tos/client/get_outputs.py
index e34d859bbd..6d7baca2c6 100644
--- a/bindings/python/examples/client/03_get_address_outputs.py
+++ b/bindings/python/examples/how_tos/client/get_outputs.py
@@ -1,5 +1,6 @@
from iota_sdk import Client, NodeIndexerAPI
from dotenv import load_dotenv
+import json
import os
load_dotenv()
@@ -18,8 +19,9 @@
# Get output ids of basic outputs that can be controlled by this address without further unlock constraints
output_ids_response = client.basic_output_ids(query_parameters)
-print(f'{output_ids_response}')
+print('First output of query:')
+print(f'ID: {output_ids_response.items[0]}')
# Get the outputs by their id
outputs = client.get_outputs(output_ids_response.items)
-print(f'{outputs}')
+print(f'{json.dumps(outputs[0], indent=4)}')
diff --git a/documentation/sdk/docs/_admonitions/_account-client.md b/documentation/sdk/docs/_admonitions/_account-client.md
new file mode 100644
index 0000000000..a8debdf003
--- /dev/null
+++ b/documentation/sdk/docs/_admonitions/_account-client.md
@@ -0,0 +1,5 @@
+:::tip Client in Wallet
+
+If you are using a wallet you can always get the client by calling the `client()`/`getClient()`/`get_client()` method
+
+:::
\ No newline at end of file
diff --git a/documentation/sdk/docs/how-tos/client/get-health.md b/documentation/sdk/docs/how-tos/client/get-health.md
new file mode 100644
index 0000000000..dc527ab343
--- /dev/null
+++ b/documentation/sdk/docs/how-tos/client/get-health.md
@@ -0,0 +1,57 @@
+---
+title: Get Node Health
+description: 'Check any nodes health.'
+image: /img/logo/iota_mark_light.png
+keywords:
+- how to
+- client
+- load balancer
+- node health
+- nodejs
+- python
+- rust
+---
+
+import CodeBlock from '@theme/CodeBlock';
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+import NodejsCode from '!!raw-loader!../../../../../bindings/nodejs/examples/how_tos/client/get-health.ts';
+import PythonCode from '!!raw-loader!../../../../../bindings/python/examples/how_tos/client/get_health.py';
+import RustCode from '!!raw-loader!../../../../../sdk/examples/how_tos/client/get_health.rs';
+import AccountClient from '../../_admonitions/_account-client.md'
+
+You can check the health of any node.
+
+
+
+The following code example will:
+
+1. Create a `Client` which will connect to the [Shimmer Testnet](https://api.testnet.shimmer.network).
+2. Use the created client to get the health of the specified url.
+3. Print the information to the console.
+
+## Code Example
+
+
+
+
+ {RustCode}
+
+
+
+
+ {NodejsCode}
+
+
+
+
+ {PythonCode}
+
+
+
+
+## Expected Output
+
+```bash
+Healthy: true
+```
diff --git a/documentation/sdk/docs/how-tos/client/get-info.md b/documentation/sdk/docs/how-tos/client/get-info.md
new file mode 100644
index 0000000000..c98c09a68d
--- /dev/null
+++ b/documentation/sdk/docs/how-tos/client/get-info.md
@@ -0,0 +1,215 @@
+---
+title: Get Node Information
+description: Sometimes it's needed to get certain info from the Node to determine for example if the node is synced or which features it has enabled. You can get this info from a Client instance.
+image: /img/logo/iota_mark_light.png
+keywords:
+- how to
+- client
+- load balancer
+- node info
+- nodejs
+- python
+- rust
+---
+
+import CodeBlock from '@theme/CodeBlock';
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+import NodejsCode from '!!raw-loader!../../../../../bindings/nodejs/examples/how_tos/client/get-info.ts';
+import PythonCode from '!!raw-loader!../../../../../bindings/python/examples/how_tos/client/get_info.py';
+import RustCode from '!!raw-loader!../../../../../sdk/examples/how_tos/client/get_info.rs';
+import AccountClient from '../../_admonitions/_account-client.md'
+
+Sometimes it's needed to get certain info from the Node to determine for example if the node is synced or which features it has enabled. You can get this info from a Client instance.
+
+
+
+The following code example will:
+
+1. Create a `Client` which will connect to the [Shimmer Testnet](https://api.testnet.shimmer.network).
+2. Use the created client to get information about the node.
+3. Print the information to the console.
+
+## Code Example
+
+
+
+
+ {RustCode}
+
+
+
+
+ {NodejsCode}
+
+
+
+
+ {PythonCode}
+
+
+
+
+## Expected Output
+
+
+
+
+```bash
+{
+ "name": "HORNET",
+ "version": "2.0.0-rc.6",
+ "status": {
+ "isHealthy": true,
+ "latestMilestone": {
+ "index": 5857259,
+ "timestamp": 1687786864,
+ "milestoneId": "0x4acfdc55bf4d7eab9e947cda3f6c4c88578c3fd59e44d3b461b706ef73186622"
+ },
+ "confirmedMilestone": {
+ "index": 5857259,
+ "timestamp": 1687786864,
+ "milestoneId": "0x4acfdc55bf4d7eab9e947cda3f6c4c88578c3fd59e44d3b461b706ef73186622"
+ },
+ "pruningIndex": 4749782
+ },
+ "supportedProtocolVersions": [
+ 2
+ ],
+ "protocol": {
+ "version": 2,
+ "networkName": "testnet-1",
+ "bech32Hrp": "rms",
+ "minPowScore": 1500,
+ "belowMaxDepth": 15,
+ "rentStructure": {
+ "vByteCost": 100,
+ "vByteFactorKey": 10,
+ "vByteFactorData": 1
+ },
+ "tokenSupply": "1450896407249092"
+ },
+ "pendingProtocolParameters": [],
+ "baseToken": {
+ "name": "Shimmer",
+ "tickerSymbol": "SMR",
+ "unit": "SMR",
+ "subunit": "glow",
+ "decimals": 6,
+ "useMetricPrefix": false
+ },
+ "metrics": {
+ "blocksPerSecond": 1.2,
+ "referencedBlocksPerSecond": 0.6,
+ "referencedRate": 50.0
+ },
+ "features": []
+}
+```
+
+
+
+
+````bash
+{
+ name: 'HORNET',
+ version: '2.0.0-rc.6',
+ status: {
+ isHealthy: true,
+ latestMilestone: {
+ index: 5792633,
+ timestamp: 1687456380,
+ milestoneId: '0x5d554e0c20779dae25288efefb33c385b11c2dc6088f9418d3a1fececa1385fc'
+ },
+ confirmedMilestone: {
+ index: 5792633,
+ timestamp: 1687456380,
+ milestoneId: '0x5d554e0c20779dae25288efefb33c385b11c2dc6088f9418d3a1fececa1385fc'
+ },
+ pruningIndex: 4750998
+ },
+ supportedProtocolVersions: [ 2 ],
+ protocol: {
+ version: 2,
+ networkName: 'testnet-1',
+ bech32Hrp: 'rms',
+ minPowScore: 1500,
+ belowMaxDepth: 15,
+ rentStructure: { vByteCost: 100, vByteFactorKey: 10, vByteFactorData: 1 },
+ tokenSupply: '1450896407249092'
+ },
+ pendingProtocolParameters: [],
+ baseToken: {
+ name: 'Shimmer',
+ tickerSymbol: 'SMR',
+ unit: 'SMR',
+ subunit: 'glow',
+ decimals: 6,
+ useMetricPrefix: false
+ },
+ metrics: {
+ blocksPerSecond: 1.4,
+ referencedBlocksPerSecond: 0.2,
+ referencedRate: 14.285714285714285
+ },
+ features: []
+}
+````
+
+
+
+
+```bash
+{
+ "name": "HORNET",
+ "version": "2.0.0-rc.6",
+ "status": {
+ "isHealthy": true,
+ "latestMilestone": {
+ "index": 5792633,
+ "timestamp": 1687456380,
+ "milestoneId": "0x5d554e0c20779dae25288efefb33c385b11c2dc6088f9418d3a1fececa1385fc"
+ },
+ "confirmedMilestone": {
+ "index": 5792633,
+ "timestamp": 1687456380,
+ "milestoneId": "0x5d554e0c20779dae25288efefb33c385b11c2dc6088f9418d3a1fececa1385fc"
+ },
+ "pruningIndex": 4750998
+ },
+ "supportedProtocolVersions": [
+ 2
+ ],
+ "protocol": {
+ "version": 2,
+ "networkName": "testnet-1",
+ "bech32Hrp": "rms",
+ "minPowScore": 1500,
+ "belowMaxDepth": 15,
+ "rentStructure": {
+ "vByteCost": 100,
+ "vByteFactorKey": 10,
+ "vByteFactorData": 1
+ },
+ "tokenSupply": "1450896407249092"
+ },
+ "pendingProtocolParameters": [],
+ "baseToken": {
+ "name": "Shimmer",
+ "tickerSymbol": "SMR",
+ "unit": "SMR",
+ "subunit": "glow",
+ "decimals": 6,
+ "useMetricPrefix": false
+ },
+ "metrics": {
+ "blocksPerSecond": 1.4,
+ "referencedBlocksPerSecond": 0.2,
+ "referencedRate": 14.285714285714285
+ },
+ "features": []
+}
+```
+
+
+
diff --git a/documentation/sdk/docs/how-tos/client/get-outputs.md b/documentation/sdk/docs/how-tos/client/get-outputs.md
new file mode 100644
index 0000000000..c1c05e4dfc
--- /dev/null
+++ b/documentation/sdk/docs/how-tos/client/get-outputs.md
@@ -0,0 +1,148 @@
+---
+title: Get Outputs
+description: 'Find outputs specifying certain search criteria'
+image: /img/logo/iota_mark_light.png
+keywords:
+- how to
+- client
+- outputs
+- nodejs
+- python
+- rust
+---
+
+import CodeBlock from '@theme/CodeBlock';
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+import NodejsCode from '!!raw-loader!../../../../../bindings/nodejs/examples/how_tos/client/get-outputs.ts';
+import PythonCode from '!!raw-loader!../../../../../bindings/python/examples/how_tos/client/get_outputs.py';
+import RustCode from '!!raw-loader!../../../../../sdk/examples/how_tos/client/get_outputs.rs';
+import AccountClient from '../../_admonitions/_account-client.md'
+
+You can use the indexer to query for specific outputs. You can query for any output type, just change the function to the output type you need
+
+
+
+The following code example will:
+
+1. Create a `Client` which will connect to the [Shimmer Testnet](https://api.testnet.shimmer.network).
+2. Use the created client to query for outputs with the specified parameters.
+3. Print the first output found.
+
+## Code Example
+
+
+
+
+ {RustCode}
+
+
+
+
+ {NodejsCode}
+
+
+
+
+ {PythonCode}
+
+
+
+
+## Expected Output
+
+
+
+
+```bash
+First output of query:
+ID: OutputId(0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000)
+OutputWithMetadata {
+ output: BasicOutput {
+ amount: 12310426,
+ native_tokens: NativeTokens(
+ [],
+ ),
+ unlock_conditions: UnlockConditions(
+ [
+ AddressUnlockCondition(
+ Ed25519Address(0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3),
+ ),
+ ],
+ ),
+ features: Features(
+ [],
+ ),
+ },
+ metadata: OutputMetadata {
+ block_id: BlockId(0x2a006e26f54f1221b4fa5738bf2b3501a0a2e7085ff8dcc03d0700f75bbcc43c),
+ output_id: OutputId(0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000),
+ is_spent: false,
+ milestone_index_spent: None,
+ milestone_timestamp_spent: None,
+ transaction_id_spent: None,
+ milestone_index_booked: 5300818,
+ milestone_timestamp_booked: 1684939216,
+ ledger_index: 5794425,
+ },
+}
+```
+
+
+
+
+```bash
+First output of query:
+ID: 0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000
+OutputResponse {
+ metadata: {
+ blockId: '0x2a006e26f54f1221b4fa5738bf2b3501a0a2e7085ff8dcc03d0700f75bbcc43c',
+ transactionId: '0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c',
+ outputIndex: 0,
+ isSpent: false,
+ milestoneIndexBooked: 5300818,
+ milestoneTimestampBooked: 1684939216,
+ ledgerIndex: 5794505
+ },
+ output: BasicOutput {
+ type: 3,
+ amount: '12310426',
+ unlockConditions: [ [AddressUnlockCondition] ]
+ }
+}
+```
+
+
+
+
+```bash
+First output of query:
+ID: 0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c0000
+{
+ "metadata": {
+ "blockId": "0x2a006e26f54f1221b4fa5738bf2b3501a0a2e7085ff8dcc03d0700f75bbcc43c",
+ "transactionId": "0x57a796e9b8c5fc96c330fa45c2658f37d04f631eedc85d8e1e23434ca599eb8c",
+ "outputIndex": 0,
+ "isSpent": false,
+ "milestoneIndexBooked": 5300818,
+ "milestoneTimestampBooked": 1684939216,
+ "ledgerIndex": 5794538
+ },
+ "output": {
+ "type": 3,
+ "amount": "12310426",
+ "unlockConditions": [
+ {
+ "type": 0,
+ "address": {
+ "type": 0,
+ "pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"
+ }
+ }
+ ]
+ }
+}
+```
+
+
+
diff --git a/documentation/sdk/docs/how-tos/outputs/features.mdx b/documentation/sdk/docs/how-tos/outputs/features.mdx
index e78ae6e046..96f500ae64 100644
--- a/documentation/sdk/docs/how-tos/outputs/features.mdx
+++ b/documentation/sdk/docs/how-tos/outputs/features.mdx
@@ -17,9 +17,12 @@ import TabItem from "@theme/TabItem";
import RustCode from '!!raw-loader!../../../../../sdk/examples/how_tos/outputs/features.rs';
import NodejsCode from '!!raw-loader!../../../../../bindings/nodejs/examples/how_tos/outputs/features.ts';
import PythonCode from '!!raw-loader!../../../../../bindings/python/examples/how_tos/outputs/features.py';
+import AccountClient from '../../_admonitions/_account-client.md'
Outputs can have different features. This how to exaplains how to add them to an output.
+
+
:::info Output Features
Different outputs can have different featues. This tables shows you which ouput has which features. You can find the output specs in [TIP-018](https://wiki.iota.org/tips/tips/TIP-0018)
diff --git a/documentation/sdk/docs/how-tos/outputs/unlock-conditions.mdx b/documentation/sdk/docs/how-tos/outputs/unlock-conditions.mdx
index 91063ddb46..d0d222d88d 100644
--- a/documentation/sdk/docs/how-tos/outputs/unlock-conditions.mdx
+++ b/documentation/sdk/docs/how-tos/outputs/unlock-conditions.mdx
@@ -17,9 +17,12 @@ import TabItem from "@theme/TabItem";
import RustCode from '!!raw-loader!../../../../../sdk/examples/how_tos/outputs/unlock_conditions.rs';
import NodejsCode from '!!raw-loader!../../../../../bindings/nodejs/examples/how_tos/outputs/unlock-conditions.ts';
import PythonCode from '!!raw-loader!../../../../../bindings/python/examples/how_tos/outputs/unlock_conditions.py';
+import AccountClient from '../../_admonitions/_account-client.md'
Outputs can have different unlock conditions. This how to exaplains how to add them to an output.
+
+
:::info Output Unlock Conditions
Different outputs can have different unlock conditions. This tables shows you which ouput is compatible with which unlock condition. You can find the output specs in [TIP-018](https://wiki.iota.org/tips/tips/TIP-0018)
diff --git a/documentation/sdk/sidebars.js b/documentation/sdk/sidebars.js
index cfae2780b0..50233270ca 100644
--- a/documentation/sdk/sidebars.js
+++ b/documentation/sdk/sidebars.js
@@ -146,6 +146,16 @@ module.exports = {
dirName: 'how_tos/nfts'
}
]
+ },
+ {
+ type: "category",
+ label: 'Client',
+ items: [
+ {
+ type: 'autogenerated',
+ dirName: 'how-tos/client'
+ }
+ ]
}
]
},
diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml
index 417b2029bb..71f474bcd2 100644
--- a/sdk/Cargo.toml
+++ b/sdk/Cargo.toml
@@ -241,6 +241,21 @@ name = "output_features"
path = "examples/how_tos/outputs/features.rs"
required-features = [ "client" ]
+# Client Examples
+
+[[example]]
+name = "get_health"
+path = "examples/how_tos/client/get_health.rs"
+
+[[example]]
+name = "get_info"
+path = "examples/how_tos/client/get_info.rs"
+required-features = [ "serde" ]
+
+[[example]]
+name = "get_outputs"
+path = "examples/how_tos/client/get_outputs.rs"
+
# Block examples
[[example]]
@@ -285,21 +300,11 @@ required-features = [ "client" ]
# Node API core examples
-[[example]]
-name = "node_api_core_get_health"
-path = "examples/client/node_api_core/00_get_health.rs"
-required-features = [ "client" ]
-
[[example]]
name = "node_api_core_get_routes"
path = "examples/client/node_api_core/01_get_routes.rs"
required-features = [ "client" ]
-[[example]]
-name = "node_api_core_get_info"
-path = "examples/client/node_api_core/02_get_info.rs"
-required-features = [ "client" ]
-
[[example]]
name = "node_api_core_get_tips"
path = "examples/client/node_api_core/03_get_tips.rs"
@@ -402,11 +407,6 @@ required-features = [ "client" ]
# Node API indexer examples
-[[example]]
-name = "node_api_indexer_get_basic_outputs"
-path = "examples/client/node_api_indexer/00_get_basic_outputs.rs"
-required-features = [ "client" ]
-
[[example]]
name = "node_api_indexer_get_alias_output"
path = "examples/client/node_api_indexer/01_get_alias_output.rs"
diff --git a/sdk/examples/client/node_api_core/00_get_health.rs b/sdk/examples/how_tos/client/get_health.rs
similarity index 90%
rename from sdk/examples/client/node_api_core/00_get_health.rs
rename to sdk/examples/how_tos/client/get_health.rs
index 020de4dbf4..aec5e2a5d5 100644
--- a/sdk/examples/client/node_api_core/00_get_health.rs
+++ b/sdk/examples/how_tos/client/get_health.rs
@@ -24,9 +24,9 @@ async fn main() -> Result<()> {
.await?;
// Get node health.
- let health = client.get_health(&node_url).await?;
+ let is_healthy = client.get_health(&node_url).await?;
- println!("Health: {health}");
+ println!("Healthy: {is_healthy}");
Ok(())
}
diff --git a/sdk/examples/client/node_api_core/02_get_info.rs b/sdk/examples/how_tos/client/get_info.rs
similarity index 85%
rename from sdk/examples/client/node_api_core/02_get_info.rs
rename to sdk/examples/how_tos/client/get_info.rs
index 484af289ff..832d6168cf 100644
--- a/sdk/examples/client/node_api_core/02_get_info.rs
+++ b/sdk/examples/how_tos/client/get_info.rs
@@ -3,7 +3,7 @@
//! Returns general information about the node by calling `GET /api/core/v2/info`.
//!
-//! `cargo run --example node_api_core_get_info --release -- [NODE URL]`
+//! `cargo run --release --example get_info -- [NODE URL]`
use iota_sdk::client::{Client, Result};
@@ -24,9 +24,9 @@ async fn main() -> Result<()> {
.await?;
// Get node info.
- let info = client.get_info().await?;
+ let info = client.get_info().await?.node_info;
- println!("{info:#?}");
+ println!("{info}");
Ok(())
}
diff --git a/sdk/examples/client/node_api_indexer/00_get_basic_outputs.rs b/sdk/examples/how_tos/client/get_outputs.rs
similarity index 78%
rename from sdk/examples/client/node_api_indexer/00_get_basic_outputs.rs
rename to sdk/examples/how_tos/client/get_outputs.rs
index 8c736c5bdd..10f0874443 100644
--- a/sdk/examples/client/node_api_indexer/00_get_basic_outputs.rs
+++ b/sdk/examples/how_tos/client/get_outputs.rs
@@ -4,7 +4,7 @@
//! TODO: by calling
//! `GET api/indexer/v1/outputs/basic`.
//!
-//! `cargo run --example node_api_indexer_get_basic_outputs --release -- [NODE_URL] [ADDRESS]`.
+//! `cargo run --release --example get_outputs -- [NODE_URL] [ADDRESS]`.
use iota_sdk::{
client::{node_api::indexer::query_parameters::QueryParameter, Client, Result},
@@ -32,7 +32,7 @@ async fn main() -> Result<()> {
std::env::args()
.nth(2)
.as_deref()
- .unwrap_or("rms1qrrdjmdkadtcnuw0ue5n9g4fmkelrj3dl26eyeshkha3w3uu0wheu5z5qqz"),
+ .unwrap_or("rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy"),
)?;
// Get output IDs of basic outputs that can be controlled by this address without further unlock constraints.
@@ -45,12 +45,13 @@ async fn main() -> Result<()> {
])
.await?;
- println!("Basic output IDs: {output_ids_response:#?}");
+ println!("First output of query:");
+ println!("ID: {:#?}", output_ids_response.first().expect("No outputs found"));
// Get the outputs by their IDs.
- let outputs_responses = client.get_outputs(&output_ids_response.items).await?;
+ let outputs_response = client.get_outputs(&output_ids_response.items).await?;
- println!("{outputs_responses:#?}");
+ println!("{:#?}", outputs_response.first().unwrap());
Ok(())
}
diff --git a/sdk/src/types/api/core/response.rs b/sdk/src/types/api/core/response.rs
index 9bdaf5c2d5..dd44a86c39 100644
--- a/sdk/src/types/api/core/response.rs
+++ b/sdk/src/types/api/core/response.rs
@@ -36,6 +36,13 @@ pub struct InfoResponse {
pub features: Vec,
}
+#[cfg(feature = "serde")]
+impl core::fmt::Display for InfoResponse {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ write!(f, "{}", serde_json::to_string_pretty(self).unwrap())
+ }
+}
+
/// Returned in [`InfoResponse`].
/// Status information about the node.
#[derive(Clone, Debug, Eq, PartialEq)]