debug-callback-failures.mdx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ---
  2. title: Debug Callback Failures
  3. description: How to identify and resolve issues with Entropy callbacks
  4. ---
  5. import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
  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-debugger.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. <DynamicCodeBlock
  19. lang="solidity"
  20. code={`function revealWithCallback(
  21. address provider,
  22. uint64 sequenceNumber,
  23. bytes32 userContribution,
  24. bytes32 providerContribution
  25. )
  26. `}
  27. />
  28. This call requires the chain ID, contract address, and four other arguments.
  29. The chain ID and contract address can be retrieved from [Contract Addresses](contract-addresses).
  30. Export these values as environment variables for later use:
  31. <DynamicCodeBlock
  32. lang="bash"
  33. code={`export CHAIN_ID=blast
  34. export ENTROPY_ADDRESS=0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb
  35. `}
  36. />
  37. Three of the other arguments can be retrieved from the request transaction's event logs.
  38. Look at the event logs of the request transaction in a block explorer.
  39. You should see a `RequestedWithCallback` event emitted from the Entropy contract.
  40. Copy the following values from the event into environment variables:
  41. <DynamicCodeBlock
  42. lang="bash"
  43. code={`export PROVIDER=0x52DeaA1c84233F7bb8C8A45baeDE41091c616506
  44. export SEQUENCE_NUMBER=12345
  45. export USER_RANDOM_NUMBER=0x1234...
  46. `}
  47. />
  48. The fourth argument (provider contribution) must be retrieved from the provider's API.
  49. This value becomes available after the reveal delay has passed.
  50. ## Common Issues
  51. There are a few common issues that can cause the callback to fail.
  52. ### Gas Limit Exceeded
  53. If your callback function uses too much gas, the transaction will fail. Check the gas limit for your chain on the [contract addresses](contract-addresses) page and ensure your callback function uses less gas.
  54. > 💡 **Tip**
  55. > Refer to the [Set Custom Gas Limits](set-custom-gas-limits) guide to set a custom gas limit for your callback function.
  56. ### Callback Function Errors
  57. Your callback function might contain logic that throws an error. Review your callback implementation for:
  58. - Division by zero
  59. - Array out of bounds access
  60. - Failed require statements
  61. - Insufficient contract balance for operations
  62. ### Transaction Timing
  63. Make sure you're attempting the callback after the reveal delay has passed. The reveal delay varies by network and helps prevent MEV attacks.
  64. Refer to the [Contract Addresses](contract-addresses) page for the reveal delay for each network.