Lifecycle at a glance
- Your contract submits a request and receives a
requestId. - Your contract stores any metadata needed to settle that request later.
- The coordinator progresses the request toward fulfillment.
- Your callback receives
requestIdandrandomNumber. - Your consumer marks the request as settled.
What to store when a request is created
Store enough information to finish the user action when the callback arrives. Typical fields include:- the player or account that initiated the request
- the game, round, or session identifier
- whether the request has already been settled
- any amount, guess, or configuration needed to compute the outcome
What can go wrong
Common failure modes:- your contract never stored request metadata
- the callback reverts because request state is incomplete
- callback logic is too expensive for the selected gas limit
- your app assumes fulfillment happens immediately after the request transaction
Design guidance
- Treat
requestIdas the join key between request creation and callback settlement. - Emit or index request IDs in your app layer so you can reconcile status later.
- Keep the callback focused on validation, state transition, and outcome settlement.
Related pages
Integration pattern
Copy a minimal implementation that stores and settles request state safely.
Consumer patterns
See common ways to map request IDs back to users and outcomes.
Troubleshooting
Diagnose requests that stay pending or callbacks that never settle.