whats-new-entropyv2.mdx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. title: What's New in Entropy v2
  3. description: New features and improvements in Entropy v2
  4. ---
  5. # What's New in Entropy v2
  6. Entropy v2 introduces several improvements and new features to make random number generation more flexible and efficient.
  7. ## Key Improvements
  8. ### 1. Multiple Request Variants
  9. Entropy v2 provides multiple ways to request random numbers:
  10. - **Basic Request**: Simplest implementation with default settings
  11. - **Custom Gas Limit**: Specify gas limits for complex callbacks
  12. - **Custom Provider**: Choose specific entropy providers
  13. - **Full Control**: Specify all parameters (provider, gas limit, user random number)
  14. ### 2. Improved Fee Structure
  15. The new version offers more granular fee calculation:
  16. ```solidity
  17. // Get fee for default provider and gas limit
  18. uint256 basicFee = entropy.getFeeV2();
  19. // Get fee for custom gas limit
  20. uint256 customGasFee = entropy.getFeeV2(gasLimit);
  21. // Get fee for specific provider and gas limit
  22. uint256 providerFee = entropy.getFeeV2(provider, gasLimit);
  23. ```
  24. ### 3. Better Error Handling
  25. Enhanced error messages and more specific error codes help developers debug issues more effectively.
  26. ### 4. Gas Optimization
  27. Improved contract efficiency reduces overall gas costs for entropy requests.
  28. ## Migration Guide
  29. If you're upgrading from Entropy v1 to v2:
  30. 1. Update your imports to use `IEntropyV2`
  31. 2. Replace `request()` calls with `requestV2()`
  32. 3. Update fee calculation to use `getFeeV2()`
  33. 4. Test thoroughly with the new interface
  34. ## Backward Compatibility
  35. 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.