You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integrating Pyth Entropy requires a simple call an onchain function to request a random number from Entropy. The function takes a random number that one can generate offchain and pass it to the onchain function which returns a sequence number. Pyth Entropy will then callback your contract with the generated random number once the request is fulfilled.
3
+
Integrating Pyth Entropy requires calling an onchain function to request a random number from Entropy. The function takes a random number that one can generate offchain and pass it to the Entropy contract which returns a sequence number. Pyth Entropy will then callback your contract with the generated random number once the request is fulfilled.
4
4
5
5
See [How to Generate Random numbers in EVM dApps](generate-random-numbers/evm.mdx) to integrate your application with Pyth Entropy.
Copy file name to clipboardExpand all lines: pages/entropy/generate-random-numbers/evm.mdx
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,13 +56,13 @@ Entropy also requires selecting a **randomness provider**. The randomness provid
56
56
who participates in the generation process. Each provider is identified by an address and hosts
57
57
a keeper service for fullfilling requests.
58
58
59
-
The simplest way to choose a provider is to use the default provider called [**Fortuna**](https://github.com/pyth-network/pyth-crosschain/tree/main/apps/fortuna).
59
+
The simplest way to choose a provider is to use the [default provider](../contract-addresses).
60
60
The default provider for each contract and their corresponding URI is also listed in the
You can also get the default provider's address by calling the [`getDefaultProvider`](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/entropy_sdk/solidity/IEntropy.sol#L94) method:
65
+
You can also get the default provider's address by calling the [`getDefaultProvider`](https://github.com/pyth-network/pyth-crosschain/blob/f8ebeb6af31d98f94ce73edade6da2ebab7b2456/target_chains/ethereum/entropy_sdk/solidity/IEntropy.sol#L94) method:
66
66
67
67
```solidity copy
68
68
address provider = entropy.getDefaultProvider();
@@ -110,7 +110,7 @@ This method returns a sequence number and emits a [`RequestedWithCallback`](http
110
110
111
111
### 3. Implement callback for Entropy
112
112
113
-
```solidity {28-37} copy
113
+
```solidity {28-38} copy
114
114
pragma solidity ^0.8.0;
115
115
116
116
import { IEntropyConsumer } from "@pythnetwork/entropy-sdk-solidity/IEntropyConsumer.sol";
@@ -138,11 +138,12 @@ contract YourContract is IEntropyConsumer {
138
138
// Store the sequence number to identify the callback request
139
139
}
140
140
141
-
// It is called by the entropy contract when a random number is generated.
141
+
// @param sequenceNumber The sequence number of the request.
142
+
// @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.
143
+
// @param randomNumber The generated random number.
144
+
// This method is called by the entropy contract when a random number is generated.
142
145
function entropyCallback(
143
146
uint64 sequenceNumber,
144
-
// If your app uses multiple providers, you can use this argument to
145
-
// distinguish which one is calling the app back.
146
147
address provider,
147
148
bytes32 randomNumber
148
149
) internal override {
@@ -168,7 +169,7 @@ You may find these additional resources helpful while integrating Pyth Entropy i
168
169
169
170
### Debug Callback Failures
170
171
171
-
Check how to [Debug Callback Failures](/entropy/debug-callback-failures) if you are having trouble getting the callback to run.
172
+
Check how to [Debug Callback Failures](../debug-callback-failures) if you are having trouble getting the callback to run.
172
173
173
174
### Pyth Entropy Contract Addresses
174
175
@@ -180,4 +181,4 @@ Check the [Current Fees](../current-fees) to find the current fee for each provi
180
181
181
182
### Best Practices
182
183
183
-
Check out the [Best Practices](/entropy/best-practices) guide for tips to limit gas usage, or generate multiple random numbers in a single transaction.
184
+
Check out the [Best Practices](../best-practices) guide for tips to limit gas usage, or generate multiple random numbers in a single transaction.
0 commit comments