Logs & Error Handling
Lit Action Responses and SDK Logs.
The getLogs
method retrieves and returns the logs of the circuit. The logs provide a chronological record of events and actions that have taken place in the execution of the circuit. This can be helpful for debugging purposes or for recording the progression of circuit tasks.
You can optionally specify a category to get logs of that category only. There are three categories:
Error: Returns errors logged in the circuit.
Response: Returns a stringified JSON of the Lit Action response object.
Condition: Returns the matched or unmatched status for each conditional check and the Emitted Value from the Contract or Webhook Event.
Broadcast: Returns the broadcast Transaction Hash for broadcast
ContractActions
.Execution: Returns when Conditional Logic or Execution Constraints are updated.
The SDK retains a rolling log of the most recent 1000 entries; for more extensive or permanent log storage, please consider using an external database or logging service.
When a log is recorded a log event is also emitted. You can subscribe to the events in real time through the .on
method.
Lit Action Response Object
The Response returned by the Lit.Actions.setResponse() method is a concatenated response object of all responses logged in the code, including error handling. It is found as a stringified JSON in the responseObject.response
field of the returned log.
Every action is wrapped in a function with a unique name based on its type and priority, for example custom0
, fetch1
, contract2
, etc.
When an action is executed the result is saved in the concatenatedResponse
object under a key with the same name as the action function.
If you have a CustomAction
with a priority of 0
, and that action function returns the string "Custom Action 1", then the concatenatedResponse
object will have a key-value pair of: custom0: "Custom Action 1"
.
For ContractActions
the returned response value is the generatedUnsignedTransactionData
, for FetchActions
the returned response value is an object value found at the response path under the value key, and a boolean under signed, indicating whether the transaction was signed or not according to any signCondition
. For CustomActions
the custom indicated response object is returned.
Any console logs or signatures created when executing the Lit Action are also returned in the responseObject
under the signatures
and logs
fields.
Each signature is named according to the SetAction
type and priority order for FetchActions
and ContractActions
.
Last updated