From af71b4d08158bf177d0c2435b0cb6eb455fe4b4c Mon Sep 17 00:00:00 2001 From: Nanolucas Date: Sat, 2 Jan 2021 20:29:10 +0100 Subject: [PATCH] implement event log getter --- src/Contract.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Contract.php b/src/Contract.php index 8885fa5..1be941d 100644 --- a/src/Contract.php +++ b/src/Contract.php @@ -863,4 +863,29 @@ class Contract return $functionData; } } + + /** + * getEventLogs + * + * @param string $eventName + * @return string + */ + public function getEventLogs($eventName) + { + $eventSignature = $this->ethabi->encodeEventSignature($eventName); + $eventInputParametersStringArray = $this->ethabi->encodeParameters($this->events[$eventName]); + + $this->eth->getLogs([ + 'topics' => array($eventSignature), + 'address' => $this->toAddress + ], + function ($error, $result) use (&$output) { + if ($error !== null) { + throw new RuntimeException($error->getMessage()); + } + $output = $result; + }); + + return $this->ethabi->decodeParameters($eventInputParametersStringArray, $output[0]->data); + } }