Get Node Information
You can access all the features of the iota.rs
library using an instance of the Client
class. The Client
class
provides high-level abstraction to all interactions over IOTA network (Tangle). You have to instantiate this class
before you start any interactions with the library, or more precisely with the
IOTA nodes that power IOTA network.
The following code example will:
- Create a
Client
which will connect to the Shimmer Testnet. - Use the created client to get information about the node.
- Print the information to the console.
You can also find this guide in the native iota.js library
Code Example
- Rust
- Nodejs
- Python
- Java
This example uses dotenv, which is not safe to use in production environments.
loading...
Run the Example
Run the example by running the following command:
cargo run --example node_api_core_get_info --release -- https://api.testnet.shimmer.network
- You can replace
https://api.testnet.shimmer.network
with any node url.
loading...
You can run the example by running the following command from the bindings/node/examples/
folder:
node dist/00_get_info.js
loading...
You can run the example by running the following command from the binding/python/examples
folder:
python3 00_get_info.py
loading...
Expected Output
- Rust
- Nodejs
- Python
- Java
NodeInfoWrapper {
node_info: InfoResponse {
name: "HORNET",
version: "2.0.0-beta.5",
status: StatusResponse {
is_healthy: true,
latest_milestone: LatestMilestoneResponse {
index: 746869,
timestamp: 1661868434,
milestone_id: "0xbab289ebb1fdcc8516772074c3c465aaad648f234a4c1ff138f16c65a88b1298",
},
confirmed_milestone: ConfirmedMilestoneResponse {
index: 746869,
timestamp: 1661868434,
milestone_id: "0xbab289ebb1fdcc8516772074c3c465aaad648f234a4c1ff138f16c65a88b1298",
},
pruning_index: 0,
},
supported_protocol_versions: [
2,
],
protocol: ProtocolResponse {
version: 2,
network_name: "testnet-1",
bech32_hrp: "rms",
min_pow_score: 1500.0,
rent_structure: RentStructureResponse {
v_byte_cost: 100,
v_byte_factor_key: 10,
v_byte_factor_data: 1,
},
token_supply: "1450896407249092",
},
pending_protocol_parameters: [],
base_token: BaseTokenResponse {
name: "Shimmer",
ticker_symbol: "SMR",
unit: "SMR",
subunit: Some(
"glow",
),
decimals: 6,
use_metric_prefix: false,
},
metrics: MetricsResponse {
blocks_per_second: 8.4,
referenced_blocks_per_second: 9.2,
referenced_rate: 109.52380952380952,
},
features: [],
},
url: "https://api.testnet.shimmer.network",
}
Node info: {
nodeInfo: {
name: 'HORNET',
version: '2.0.0-beta.5',
status: {
isHealthy: true,
latestMilestone: [Object],
confirmedMilestone: [Object],
pruningIndex: 0
},
supportedProtocolVersions: [ 2 ],
protocol: {
version: 2,
networkName: 'testnet-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: 10.4,
referencedBlocksPerSecond: 10,
referencedRate: 96.15384615384616
},
features: []
},
url: 'https://api.testnet.shimmer.network'
}
{
'nodeInfo': {
'name': 'HORNET',
'version': '2.0.0-beta.5',
'status': {
'isHealthy': True,
'latestMilestone': {
'index': 746844,
'timestamp': 1661868309,
'milestoneId': '0xee26fb7ff5b4bed7b89a761ca3d75a9c99f8c4589e55d3ec0598c9a37717a61b'
},
'confirmedMilestone': {
'index': 746844,
'timestamp': 1661868309,
'milestoneId': '0xee26fb7ff5b4bed7b89a761ca3d75a9c99f8c4589e55d3ec0598c9a37717a61b'
},
'pruningIndex': 0
},
'supportedProtocolVersions': [
2
],
'protocol': {
'version': 2,
'networkName': 'testnet-1',
'bech32Hrp': 'rms',
'minPowScore': 1500.0,
'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': 9.8,
'referencedBlocksPerSecond': 8.4,
'referencedRate': 85.71428571428571
},
'features': [
]
},
'url': 'https://api.testnet.shimmer.network'
}
{
"name": "HORNET",
"version": "2.0.0-beta.5",
"status": {
"isHealthy": true,
"latestMilestone": {
"index": 747006,
"timestamp": 1661869119,
"milestoneId": "0x34559d7ba255d1b1127529cf4e28ccc9d5a8da4fcc811d465a8fce8107a0ef53"
},
"confirmedMilestone": {
"index": 747006,
"timestamp": 1661869119,
"milestoneId": "0x34559d7ba255d1b1127529cf4e28ccc9d5a8da4fcc811d465a8fce8107a0ef53"
},
"pruningIndex": 0
},
"supportedProtocolVersions": [2],
"protocol": {
"version": 2,
"networkName": "testnet-1",
"bech32Hrp": "rms",
"minPowScore": 1500.0,
"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": 9.0,
"referencedBlocksPerSecond": 8.6,
"referencedRate": 95.55555555555556
},
"features": []
}