Skip to content

Entropy callback warning #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pages/entropy/generate-random-numbers/evm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ This method returns a sequence number and emits a [`RequestedWithCallback`](http

### 3. Implement callback for Entropy

```solidity {28-38} copy
```solidity {28-42} copy
pragma solidity ^0.8.0;

import { IEntropyConsumer } from "@pythnetwork/entropy-sdk-solidity/IEntropyConsumer.sol";
Expand Down Expand Up @@ -151,6 +151,10 @@ contract YourContract is IEntropyConsumer {
// @param provider The address of the provider that generated the random number. If your app uses multiple providers, you can use this argument to distinguish which one is calling the app back.
// @param randomNumber The generated random number.
// This method is called by the entropy contract when a random number is generated.
// This method **must** be implemented on the same contract that requested the random number.
// This method should **never** return an error -- if it returns an error, then the keeper will not be able to invoke the callback.
// If you are having problems receiving the callback, the most likely cause is that the callback is erroring.
// See the callback debugging guide here to identify the error https://docs.pyth.network/entropy/debug-callback-failures
function entropyCallback(
uint64 sequenceNumber,
address provider,
Expand All @@ -170,7 +174,12 @@ contract YourContract is IEntropyConsumer {

When the final random number is ready to use, the entropyCallback function will be called by the Entropy contract. This will happen in a separate transaction submitted by the requested provider.

**The entropyCallback function should be implemented in the same contract that is requesting the random number.**
<Callout type="warning" emoji="⚠️">
The `entropyCallback` function should **never** return an error. If it returns
an error, the keeper will not be able to invoke the callback. If you are
having problems receiving the callback, please see [Debugging Callback
Failures](/entropy/debug-callback-failures).
</Callout>

## Additional Resources

Expand Down
Loading