|
| 1 | +# What's New in Entropy V2 |
| 2 | + |
| 3 | +Entropy V2 is a major update to the Pyth Randomness Protocol. |
| 4 | + |
| 5 | +It introduces a series of developer experience improvements, shaped directly by the feedback of teams using it in production: |
| 6 | +configurable & customizable gas limits for callbacks, adding callback statuses, and an upcoming public Entropy Explorer. |
| 7 | + |
| 8 | +## What's New |
| 9 | + |
| 10 | +- [Configurable Gas Limits for Callbacks](#configurable-gas-limits-for-callbacks) |
| 11 | +- [Enhanced Callback Statuses](#enhanced-callback-statuses) |
| 12 | +- [Upcoming Public Entropy Explorer](#upcoming-public-entropy-explorer) |
| 13 | + |
| 14 | +### Configurable Gas Limits for Callbacks |
| 15 | + |
| 16 | +Entropy V2 introduces configurable gas limits for callbacks. |
| 17 | +This allows teams to set the gas limit for their callbacks, which can be useful for: |
| 18 | + |
| 19 | +- Computing expensive operations in the callback like minting an NFT collection. |
| 20 | +- Save money on gas fees by setting a lower gas limit. |
| 21 | + |
| 22 | +```solidity copy |
| 23 | +// Calculate the fee for the custom gas limit |
| 24 | +uint256 fee = entropy.getFeeV2(customGasLimit); |
| 25 | +
|
| 26 | +// Request random number with custom gas limit |
| 27 | +uint64 sequenceNumber = entropy.requestV2{ value: fee }(customGasLimit); |
| 28 | +``` |
| 29 | + |
| 30 | +### Enhanced Callback Statuses |
| 31 | + |
| 32 | +Entropy V2 introduces callback statuses, which allow teams to track the status of their callbacks. |
| 33 | +These callback statuses are emitted in the `Revealed` event. |
| 34 | + |
| 35 | +Previous version of Entropy use to emit the following `RevealedWithCallback` event: |
| 36 | + |
| 37 | +```solidity copy |
| 38 | +event RevealedWithCallback( |
| 39 | + EntropyStructs.Request request, |
| 40 | + bytes32 userRandomNumber, |
| 41 | + bytes32 providerRevelation, |
| 42 | + bytes32 randomNumber |
| 43 | +); |
| 44 | +``` |
| 45 | + |
| 46 | +Based on the feedback from teams, we have added the following statuses to the `Revealed` event: |
| 47 | + |
| 48 | +```solidity copy |
| 49 | +event Revealed( |
| 50 | + address indexed provider, |
| 51 | + address indexed caller, |
| 52 | + uint64 indexed sequenceNumber, |
| 53 | + bytes32 randomNumber, |
| 54 | + bytes32 userContribution, |
| 55 | + bytes32 providerContribution, |
| 56 | + bool callbackFailed, |
| 57 | + bytes callbackReturnValue, |
| 58 | + uint32 callbackGasUsed, |
| 59 | + bytes extraArgs |
| 60 | +); |
| 61 | +``` |
| 62 | + |
| 63 | +This updated `Revealed` event |
| 64 | + |
| 65 | +- denormalizes fields from `EntropyStructs.Request` to a flat representation in the `Revealed` event for easier consumption. |
| 66 | +- adds a `callbackFailed` boolean to indicate if the callback failed. |
| 67 | + |
| 68 | +This will help teams to easily track the status of their callbacks and re-request them if they fail on-chain. |
| 69 | + |
| 70 | +### Upcoming Public Entropy Explorer |
| 71 | + |
| 72 | +Entropy V2 introduces an upcoming public Entropy Explorer, which will allow teams to easily track the status of their callbacks and re-request them if they fail on-chain. |
| 73 | + |
| 74 | +This will help teams to easily track the status of their callbacks and re-request them if they fail on-chain. |
| 75 | + |
| 76 | +## Additional Resources |
| 77 | + |
| 78 | +These following resources will help you get started with Entropy V2: |
| 79 | + |
| 80 | +- [Entropy V2 Guide](./generate-random-numbers/evm.mdx) |
| 81 | +- [Entropy V2 Contracts](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/ethereum/contracts/contracts/entropy) |
| 82 | +- [Entropy V2 SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/ethereum/entropy_sdk/solidity) |
| 83 | +- [Entropy V2 Examples](https://github.com/pyth-network/pyth-examples/tree/main/entropy) |
0 commit comments