Callbacks can be used to manage the outcome of your transaction submission. This advanced feature enables your functions to adapt based on the execution status, whether successful or not, thus providing a robust way to handle different scenarios that may occur during task execution. Let’s explore the two types of callbacks available:
This callback gets invoked after a successful on-chain execution. It’s especially useful for tracking successful transactions or for further processing after a task completes.
The Web3FunctionSuccessContext
offers access to the transactionHash
, allowing you to reference and track the successful transaction within your application.
Triggered when an on-chain execution encounters issues such as:
This callback is crucial for handling errors and implementing fallback logic.
In the context of the onFail
callback:
reason
: This is a string indicating why the failure occurred.transactionHash
: Provided when the reason for failure is ExecutionReverted
, this is the unique identifier of the reverted transaction.callData
: Available when the reason is SimulationFailed
, this is the data that was used during the function run, which can be useful for debugging the failure.You can test your callbacks locally using specific flags during the test execution. This helps in ensuring that your callbacks function as intended before deployment.
Callbacks can be used to manage the outcome of your transaction submission. This advanced feature enables your functions to adapt based on the execution status, whether successful or not, thus providing a robust way to handle different scenarios that may occur during task execution. Let’s explore the two types of callbacks available:
This callback gets invoked after a successful on-chain execution. It’s especially useful for tracking successful transactions or for further processing after a task completes.
The Web3FunctionSuccessContext
offers access to the transactionHash
, allowing you to reference and track the successful transaction within your application.
Triggered when an on-chain execution encounters issues such as:
This callback is crucial for handling errors and implementing fallback logic.
In the context of the onFail
callback:
reason
: This is a string indicating why the failure occurred.transactionHash
: Provided when the reason for failure is ExecutionReverted
, this is the unique identifier of the reverted transaction.callData
: Available when the reason is SimulationFailed
, this is the data that was used during the function run, which can be useful for debugging the failure.You can test your callbacks locally using specific flags during the test execution. This helps in ensuring that your callbacks function as intended before deployment.