Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
Block.php
Go to the documentation of this file.
1 <?php
12 
18 class Block extends EthDataType {
19 
23  public $number;
24 
28  public $hash;
29 
33  public $parentHash;
34 
38  public $nonce;
39 
43  public $sha3Uncles;
44 
48  public $logsBloom;
49 
54 
58  public $stateRoot;
59 
63  public $receiptsRoot;
64 
68  public $miner;
69 
73  public $difficulty;
74 
79 
83  public $extraData;
84 
88  public $size;
89 
93  public $gasLimit;
94 
98  public $gasUsed;
99 
103  public $timestamp;
104 
109 
113  public $uncles;
114 
136  public function __construct(EthQ $number = null, EthD32 $hash = null, EthD32 $parentHash = null, EthD $nonce = null, EthD $sha3Uncles = null, EthD $logsBloom = null, EthD $transactionsRoot = null, EthD $stateRoot = null, EthD $receiptsRoot = null, EthD $miner = null, EthQ $difficulty = null, EthQ $totalDifficulty = null, EthD $extraData = null, EthQ $size = null, EthQ $gasLimit = null, EthQ $gasUsed = null, EthQ $timestamp = null, array $transactions = null, array $uncles = null) {
137  $this->number = $number;
138  $this->hash = $hash;
139  $this->parentHash = $parentHash;
140  $this->nonce = $nonce;
141  $this->sha3Uncles = $sha3Uncles;
142  $this->logsBloom = $logsBloom;
143  $this->transactionsRoot = $transactionsRoot;
144  $this->stateRoot = $stateRoot;
145  $this->receiptsRoot = $receiptsRoot;
146  $this->miner = $miner;
147  $this->difficulty = $difficulty;
148  $this->totalDifficulty = $totalDifficulty;
149  $this->extraData = $extraData;
150  $this->size = $size;
151  $this->gasLimit = $gasLimit;
152  $this->gasUsed = $gasUsed;
153  $this->timestamp = $timestamp;
154  $this->transactions = $transactions;
155  $this->uncles = $uncles;
156  }
157 
161  public static function getTypeArray() {
162  return array(
163  'number' => 'EthQ',
164  'hash' => 'EthD32',
165  'parentHash' => 'EthD32',
166  'nonce' => 'EthD',
167  'sha3Uncles' => 'EthD',
168  'logsBloom' => 'EthD',
169  'transactionsRoot' => 'EthD',
170  'stateRoot' => 'EthD',
171  'receiptsRoot' => 'EthD',
172  'miner' => 'EthD',
173  'difficulty' => 'EthQ',
174  'totalDifficulty' => 'EthQ',
175  'extraData' => 'EthD',
176  'size' => 'EthQ',
177  'gasLimit' => 'EthQ',
178  'gasUsed' => 'EthQ',
179  'timestamp' => 'EthQ',
180  'transactions' => '[Transaction]',
181  'uncles' => '[EthD]',
182  );
183  }
184 
188  public function toArray() {
189  $return = [];
190  (!is_null($this->number)) ? $return['number'] = $this->number->hexVal() : NULL;
191  (!is_null($this->hash)) ? $return['hash'] = $this->hash->hexVal() : NULL;
192  (!is_null($this->parentHash)) ? $return['parentHash'] = $this->parentHash->hexVal() : NULL;
193  (!is_null($this->nonce)) ? $return['nonce'] = $this->nonce->hexVal() : NULL;
194  (!is_null($this->sha3Uncles)) ? $return['sha3Uncles'] = $this->sha3Uncles->hexVal() : NULL;
195  (!is_null($this->logsBloom)) ? $return['logsBloom'] = $this->logsBloom->hexVal() : NULL;
196  (!is_null($this->transactionsRoot)) ? $return['transactionsRoot'] = $this->transactionsRoot->hexVal() : NULL;
197  (!is_null($this->stateRoot)) ? $return['stateRoot'] = $this->stateRoot->hexVal() : NULL;
198  (!is_null($this->receiptsRoot)) ? $return['receiptsRoot'] = $this->receiptsRoot->hexVal() : NULL;
199  (!is_null($this->miner)) ? $return['miner'] = $this->miner->hexVal() : NULL;
200  (!is_null($this->difficulty)) ? $return['difficulty'] = $this->difficulty->hexVal() : NULL;
201  (!is_null($this->totalDifficulty)) ? $return['totalDifficulty'] = $this->totalDifficulty->hexVal() : NULL;
202  (!is_null($this->extraData)) ? $return['extraData'] = $this->extraData->hexVal() : NULL;
203  (!is_null($this->size)) ? $return['size'] = $this->size->hexVal() : NULL;
204  (!is_null($this->gasLimit)) ? $return['gasLimit'] = $this->gasLimit->hexVal() : NULL;
205  (!is_null($this->gasUsed)) ? $return['gasUsed'] = $this->gasUsed->hexVal() : NULL;
206  (!is_null($this->timestamp)) ? $return['timestamp'] = $this->timestamp->hexVal() : NULL;
207  (!is_null($this->transactions)) ? $return['transactions'] = Ethereum::valueArray($this->transactions, 'Transaction') : array();
208  (!is_null($this->uncles)) ? $return['uncles'] = Ethereum::valueArray($this->uncles, 'EthD') : array();
209  return $return;
210  }
211 }
static valueArray(array $values, string $typeClass)
Definition: Ethereum.php:571
static getTypeArray()
Definition: Block.php:161
__construct(EthQ $number=null, EthD32 $hash=null, EthD32 $parentHash=null, EthD $nonce=null, EthD $sha3Uncles=null, EthD $logsBloom=null, EthD $transactionsRoot=null, EthD $stateRoot=null, EthD $receiptsRoot=null, EthD $miner=null, EthQ $difficulty=null, EthQ $totalDifficulty=null, EthD $extraData=null, EthQ $size=null, EthQ $gasLimit=null, EthQ $gasUsed=null, EthQ $timestamp=null, array $transactions=null, array $uncles=null)
Definition: Block.php:136