getEth()->getBalance($addr, $cb); return $cb->result; } function broadcast($rawtx) { $cb = new Callback; $this->getEth()->sendRawTransaction($rawtx, $cb); return $cb->result; } function getReceipt($txid) { $cb = new Callback; $this->getEth()->getTransactionReceipt($txid, $cb); return $cb->result; } function waitForConfirmation($txid, $timeout = 300) { $expire = time() + $timeout; while (time() < $expire) { try { $receipt = $this->getReceipt($txid); if (!is_null($receipt)) return $receipt; sleep(2); } catch (Exception $e) { } } throw new Exception('tx not confirmed yet.'); } function getBlockByNumber() { $cb = new Callback; $number = hex(436); $this->getEth()->getBlockByNumber($number, true, $cb); return $cb->result; } }