Fetching Offchain Events and Logs from a Cluster
Phat Contract events and logs are accessed through a special API because they run inside a cluster. On the Phala Blockchain, each cluster has a log server contract that handles logs, which we call 'Event Chain.' The Event Chain doesn't store logs forever. It only keeps a significant amount of them. When you get logs from the logserver, you're actually using a Phat Contract query API to reach the offchain node. Also, each type of log has its own visibility rules:
- Logs from transactions are accessible across the cluster nodes.
- Logs from queries appear only on the node that executed the query with PRuntime.
When you create the client using getClient
, you can easily get the logger
contract instance like this:
const logger = client.loggerContract
To learn more about logger, see the PinkLoggerContractPromise
.