whats-new-entropyv2.mdx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ---
  2. title: What's New in Entropy v2
  3. description: New features and improvements in Entropy v2
  4. icon: Sparkle
  5. ---
  6. import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
  7. ## Key Improvements
  8. Pyth Entropy v2 brings new features and improvements that make random number generation more flexible, efficient, and easier to integrate.
  9. ### 1. Multiple Request Variants
  10. Entropy v2 provides multiple ways to request random numbers:
  11. - **Basic Request**: Simplest implementation with default settings
  12. - **Custom Gas Limit**: Specify gas limits for complex callbacks
  13. - **Custom Provider**: Choose specific entropy providers
  14. - **Full Control**: Specify all parameters (provider, gas limit, user random number)
  15. Each of these request types is described in more detail with examples in [Request Callback Variants](request-callback-variants).
  16. ### 2. Improved Fee Structure
  17. The new version offers more granular fee calculation:
  18. <DynamicCodeBlock lang="solidity" code={`// Get fee for default provider and gas limit
  19. uint256 basicFee = entropy.getFeeV2();
  20. // Get fee for custom gas limit
  21. uint256 customGasFee = entropy.getFeeV2(gasLimit);
  22. // Get fee for specific provider and gas limit
  23. uint256 providerFee = entropy.getFeeV2(provider, gasLimit);
  24. `} />
  25. ### 3. Enhanced Callback Status
  26. Entropy V2 introduces callback statuses, which allow users to track the status of their callbacks.
  27. [Pyth Dev-Forum Announcement](https://dev-forum.pyth.network/t/announcing-entropy-v2/324#p-649-enhanced-callback-statuses-2) provides more details on enhanced callback statuses.
  28. ### 4. Entropy Debugger
  29. Entropy V2 includes a public Entropy Explorer, that lets teams easily track the status of their callbacks and re-request them if they fail on-chain.
  30. See [Entropy Explorer](https://entropy-debugger.pyth.network/) to search and debug your callbacks.
  31. ### 5. Gas Optimization
  32. Improved contract efficiency reduces overall gas costs for entropy requests.
  33. ## Migration Guide
  34. If you're upgrading from Entropy v1 to v2:
  35. 1. Update your imports to use [`IEntropyV2`](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/entropy_sdk/solidity/IEntropyV2.sol).
  36. 2. Replace `request()` calls with [`requestV2()`](https://github.com/pyth-network/pyth-crosschain/blob/f5402df8e44158c519496bcd2fac5d3afe856a0e/target_chains/ethereum/entropy_sdk/solidity/IEntropyV2.sol#L26)
  37. 3. Update fee calculation to use [`getFeeV2()`](https://github.com/pyth-network/pyth-crosschain/blob/f5402df8e44158c519496bcd2fac5d3afe856a0e/target_chains/ethereum/entropy_sdk/solidity/IEntropyV2.sol#L135)
  38. 4. Test thoroughly with the new interface
  39. ## Backward Compatibility
  40. Entropy v2 maintains backward compatibility with v1 for existing applications. However, we recommend migrating to v2 for new applications to take advantage of the improved features.