Skip to content

Latest commit

 

History

History
71 lines (60 loc) · 2.39 KB

002_examples_clientinfo.md

File metadata and controls

71 lines (60 loc) · 2.39 KB

tanglePHP

Discord Twitter
Apache-2.0 license IOTA >PHP 8 WorkflowUnitTest >packagist_stable

Basics examples (Client)

Include and create a client

<?php
  // include iota lib
  require_once("autoload.php");
  // create client
  $client = new IOTA\Client\SingleNodeClient();

Getting client health

  echo "Health: " . ($client->health() ? "ok" : "error");

Getting client info

This example will output a json string

  echo $client->info();

Each method returns an Object to get the direct parameter

  $info = $client->info();

  echo $info->name;
  echo $info->version;
  echo $info->isHealthy;
  echo $info->networkId;
  echo $info->bech32HRP;
  echo $info->minPoWScore;
  echo $info->messagesPerSecond;
  echo $info->referencedMessagesPerSecond;
  echo $info->referencedRate;
  echo $info->latestMilestoneTimestamp;
  echo $info->latestMilestoneIndex;
  echo $info->confirmedMilestoneIndex;
  echo $info->pruningIndex;
  print_r($info->features);

Short example

  echo ($client->info())->name;

Getting tips

  echo $client->tips();

Additional Examples

Please find other examples in the examples folder.


<- Back to Overview