debug-callback-failures.mdx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---
  2. title: Debug Callback Failures
  3. description: How to identify and resolve issues with Entropy callbacks
  4. icon: Bug
  5. ---
  6. This guide explains how to identify and resolve issues with the Entropy callback.
  7. The intended audience for this guide is developers who have made an Entropy random number request, but their application hasn't received a callback.
  8. > 🔍 **Quick Debug Tool**
  9. >
  10. > Use the [Entropy Explorer](https://entropy-explorer.pyth.network/) to quickly diagnose and resolve callback issues.
  11. ## Dependencies
  12. This guide uses [Foundry](https://book.getfoundry.sh/getting-started/installation) to submit transactions to the blockchain.
  13. Please install Foundry before continuing.
  14. ## Run the Callback
  15. Developers can run the Entropy callback themselves to see the reason for the failure.
  16. To run the callback, invoke the `revealWithCallback` function on the Entropy contract on your blockchain.
  17. The function has the following signature:
  18. ```solidity copy
  19. function revealWithCallback(
  20. address provider,
  21. uint64 sequenceNumber,
  22. bytes32 userContribution,
  23. bytes32 providerContribution
  24. )
  25. ```
  26. This call requires the chain ID, contract address, and four other arguments.
  27. The chain ID and contract address can be retrieved from [Chainlist and Fee Details](./chainlist) page.
  28. Export these values as environment variables for later use:
  29. ```bash copy
  30. export CHAIN_ID=blast
  31. export ENTROPY_ADDRESS=0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb
  32. ```
  33. Three of the other arguments can be retrieved from the request transaction's event logs.
  34. Look at the event logs of the request transaction in a block explorer.
  35. You should see a `RequestedWithCallback` event emitted from the Entropy contract.
  36. Copy the following values from the event into environment variables:
  37. ```bash copy
  38. export PROVIDER=0x52DeaA1c84233F7bb8C8A45baeDE41091c616506
  39. export SEQUENCE_NUMBER=12345
  40. export USER_RANDOM_NUMBER=0x1234...
  41. ```
  42. The fourth argument (provider contribution) must be retrieved from the provider's API.
  43. This value becomes available after the reveal delay has passed.
  44. ## Common Issues
  45. There are a few common issues that can cause the callback to fail.
  46. ### Gas Limit Exceeded
  47. If your callback function uses too much gas, the transaction will fail. Check the gas limit for your chain on the [chainlist](./chainlist) page and ensure your callback function uses less gas.
  48. > 💡 **Tip**
  49. > Refer to the [Set Custom Gas Limits](./set-custom-gas-limits) guide to set a custom gas limit for your callback function.
  50. ### Callback Function Errors
  51. Your callback function might contain logic that throws an error. Review your callback implementation for:
  52. - Division by zero
  53. - Array out of bounds access
  54. - Failed require statements
  55. - Insufficient contract balance for operations
  56. ### Transaction Timing
  57. Make sure you're attempting the callback after the reveal delay has passed. The reveal delay varies by network and helps prevent MEV attacks.
  58. Refer to the [chainlist](./chainlist) page for the reveal delay for each network.