implement event log getter

This commit is contained in:
Nanolucas 2021-01-02 20:29:10 +01:00
parent 665b15b261
commit af71b4d081

View File

@ -863,4 +863,29 @@ class Contract
return $functionData; 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);
}
} }