Skip to content

Commit 86c3dfb

Browse files
committed
chore(dev-docs) Entropy Contract Address table
1 parent efb003e commit 86c3dfb

File tree

14 files changed

+366
-143
lines changed

14 files changed

+366
-143
lines changed
Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
---
22
title: Contract Addresses
3-
description: Entropy contract addresses on different networks
3+
description: Pyth Entropy contract addresses on EVM networks
44
---
55

6-
# Entropy Contract Addresses on EVM
6+
import { EntropyTable } from "../../../src/components/EntropyTable";
77

88
## Mainnets
99

1010
The Entropy contract is deployed on the following mainnet chains:
1111

12-
| Network | Contract Address | Gas Limit | Provider |
13-
| --------- | -------------------------------------------- | --------- | -------------------------------------------- |
14-
| Ethereum | `0x98046Bd286715D3B0BC227Dd7a956b83D8978603` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
15-
| Arbitrum | `0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
16-
| Avalanche | `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
17-
| Base | `0x98046Bd286715D3B0BC227Dd7a956b83D8978603` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
18-
| BNB Chain | `0x98046Bd286715D3B0BC227Dd7a956b83D8978603` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
19-
| Optimism | `0x98046Bd286715D3B0BC227Dd7a956b83D8978603` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
20-
| Polygon | `0x98046Bd286715D3B0BC227Dd7a956b83D8978603` | 100,000 | `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506` |
12+
<EntropyTable isMainnet={true} />
2113

2214
**The default provider for above mainnet chains is `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506`.**
2315

@@ -30,18 +22,8 @@ The default provider fulfills the request by sending a transaction with a gas li
3022

3123
The Entropy contract is deployed on the following testnet chains:
3224

33-
| Network | Contract Address | Gas Limit | Provider |
34-
| ---------------- | -------------------------------------------- | --------- | -------------------------------------------- |
35-
| Ethereum Sepolia | `0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
36-
| Arbitrum Sepolia | `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
37-
| Avalanche Fuji | `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
38-
| Base Sepolia | `0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
39-
| BNB Testnet | `0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
40-
| Optimism Sepolia | `0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
41-
| Polygon Amoy | `0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c` | 100,000 | `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` |
25+
<EntropyTable isMainnet={false} />
4226

4327
**The default provider for above testnet chains is `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344`.**
4428

4529
The default provider on testnet has reveal delays identical to the corresponding mainnet chains to ensure consistent environment.
46-
47-
The default provider fulfills the request by sending a transaction with a gas limit as mentioned in above table. Entropy callbacks the consumer as part of this transaction.

apps/developer-hub/content/docs/entropy/debug-callback-failures.mdx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,62 @@
22
title: Debug Callback Failures
33
description: How to identify and resolve issues with Entropy callbacks
44
---
5-
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
5+
6+
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
67

78
This guide explains how to identify and resolve issues with the Entropy callback.
89
The intended audience for this guide is developers who have made an Entropy random number request, but their application hasn't received a callback.
910

1011
> 🔍 **Quick Debug Tool**
11-
>
12+
>
1213
> Use the [Entropy Explorer](https://entropy-debugger.pyth.network/) to quickly diagnose and resolve callback issues.
1314
14-
1515
## Dependencies
1616

1717
This guide uses [Foundry](https://book.getfoundry.sh/getting-started/installation) to submit transactions to the blockchain.
1818
Please install Foundry before continuing.
19+
1920
## Run the Callback
2021

2122
Developers can run the Entropy callback themselves to see the reason for the failure.
2223
To run the callback, invoke the `revealWithCallback` function on the Entropy contract on your blockchain.
2324
The function has the following signature:
2425

25-
<DynamicCodeBlock lang="solidity"
26-
code={`function revealWithCallback(
26+
<DynamicCodeBlock
27+
lang="solidity"
28+
code={`function revealWithCallback(
2729
address provider,
2830
uint64 sequenceNumber,
2931
bytes32 userContribution,
3032
bytes32 providerContribution
3133
)
32-
`} />
34+
`}
35+
/>
3336

3437
This call requires the chain ID, contract address, and four other arguments.
3538
The chain ID and contract address can be retrieved from [Contract Addresses](contract-addresses).
3639
Export these values as environment variables for later use:
3740

38-
<DynamicCodeBlock lang="bash"
39-
code={`export CHAIN_ID=blast
41+
<DynamicCodeBlock
42+
lang="bash"
43+
code={`export CHAIN_ID=blast
4044
export ENTROPY_ADDRESS=0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb
41-
`} />
45+
`}
46+
/>
4247

4348
Three of the other arguments can be retrieved from the request transaction's event logs.
4449
Look at the event logs of the request transaction in a block explorer.
4550
You should see a `RequestedWithCallback` event emitted from the Entropy contract.
4651

4752
Copy the following values from the event into environment variables:
4853

49-
<DynamicCodeBlock lang="bash"
50-
code={`export PROVIDER=0x52DeaA1c84233F7bb8C8A45baeDE41091c616506
54+
<DynamicCodeBlock
55+
lang="bash"
56+
code={`export PROVIDER=0x52DeaA1c84233F7bb8C8A45baeDE41091c616506
5157
export SEQUENCE_NUMBER=12345
5258
export USER_RANDOM_NUMBER=0x1234...
53-
`} />
59+
`}
60+
/>
5461

5562
The fourth argument (provider contribution) must be retrieved from the provider's API.
5663
This value becomes available after the reveal delay has passed.
@@ -78,4 +85,4 @@ Your callback function might contain logic that throws an error. Review your cal
7885
### Transaction Timing
7986

8087
Make sure you're attempting the callback after the reveal delay has passed. The reveal delay varies by network and helps prevent MEV attacks.
81-
Refer to the [Contract Addresses](contract-addresses) page for the reveal delay for each network.
88+
Refer to the [Contract Addresses](contract-addresses) page for the reveal delay for each network.

apps/developer-hub/content/docs/entropy/generate-random-numbers-evm.mdx

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to integrate Pyth Entropy to generate random numbers in y
44
---
55

66
import { Step, Steps } from "fumadocs-ui/components/steps";
7-
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
7+
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
88

99
This guide explains how to integrate Pyth Entropy into EVM Contracts to generate on-chain random numbers.
1010
The intended audience for this guide is developers of any application that needs on-chain randomness, such as NFT mints or games.
@@ -26,9 +26,11 @@ npm install @pythnetwork/entropy-sdk-solidity
2626

2727
Then add the following line to your `remappings.txt` file:
2828

29-
<DynamicCodeBlock lang="text"
30-
code={`@pythnetwork/entropy-sdk-solidity/=node_modules/@pythnetwork/entropy-sdk-solidity
31-
`} />
29+
<DynamicCodeBlock
30+
lang="text"
31+
code={`@pythnetwork/entropy-sdk-solidity/=node_modules/@pythnetwork/entropy-sdk-solidity
32+
`}
33+
/>
3234

3335
</Tab>
3436
</Tabs>
@@ -49,11 +51,11 @@ import { IEntropyV2 } from "@pythnetwork/entropy-sdk-solidity/IEntropyV2.sol";
4951
5052
// @param entropyAddress The address of the entropy contract.
5153
contract YourContract is IEntropyConsumer {
52-
IEntropyV2 public entropy;
54+
IEntropyV2 public entropy;
5355
54-
constructor(address entropyAddress) {
55-
entropy = IEntropyV2(entropyAddress);
56-
}
56+
constructor(address entropyAddress) {
57+
entropy = IEntropyV2(entropyAddress);
58+
}
5759
}
5860
`} />
5961

@@ -78,7 +80,7 @@ These methods use the default randomness provider ([see here](#randomness-provid
7880
code={`function requestRandomNumber() external payable {
7981
uint256 fee = entropy.getFeeV2();
8082
81-
uint64 sequenceNumber = entropy.requestV2{ value: fee }();
83+
uint64 sequenceNumber = entropy.requestV2{ value: fee }();
8284
}
8385
`} />
8486

@@ -100,43 +102,44 @@ import { IEntropyConsumer } from "@pythnetwork/entropy-sdk-solidity/IEntropyCons
100102
import { IEntropyV2 } from "@pythnetwork/entropy-sdk-solidity/IEntropyV2.sol";
101103
102104
contract YourContract is IEntropyConsumer {
103-
IEntropyV2 entropy;
105+
IEntropyV2 entropy;
104106
105-
// @param entropyAddress The address of the entropy contract.
106-
constructor(address entropyAddress) {
107-
entropy = IEntropyV2(entropyAddress);
108-
}
107+
// @param entropyAddress The address of the entropy contract.
108+
constructor(address entropyAddress) {
109+
entropy = IEntropyV2(entropyAddress);
110+
}
109111
110-
function requestRandomNumber() external payable {
111-
// Get the fee for the request
112-
uint256 fee = entropy.getFeeV2();
112+
function requestRandomNumber() external payable {
113+
// Get the fee for the request
114+
uint256 fee = entropy.getFeeV2();
113115
114116
// Request the random number with the callback
115117
uint64 sequenceNumber = entropy.requestV2{ value: fee }();
116118
// Store the sequence number to identify the callback request
117-
}
118-
119-
// @param sequenceNumber The sequence number of the request.
120-
// @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.
121-
// @param randomNumber The generated random number.
122-
// This method is called by the entropy contract when a random number is generated.
123-
// This method **must** be implemented on the same contract that requested the random number.
124-
// This method should **never** return an error -- if it returns an error, then the keeper will not be able to invoke the callback.
125-
// If you are having problems receiving the callback, the most likely cause is that the callback is erroring.
126-
// See the callback debugging guide here to identify the error https://docs.pyth.network/entropy/debug-callback-failures
127-
function entropyCallback(
128-
uint64 sequenceNumber,
129-
address provider,
130-
bytes32 randomNumber
131-
) internal override {
132-
// Implement your callback logic here.
133-
}
134-
135-
// This method is required by the IEntropyConsumer interface.
136-
// It returns the address of the entropy contract which will call the callback.
137-
function getEntropy() internal view override returns (address) {
138-
return address(entropy);
139-
}
119+
120+
}
121+
122+
// @param sequenceNumber The sequence number of the request.
123+
// @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.
124+
// @param randomNumber The generated random number.
125+
// This method is called by the entropy contract when a random number is generated.
126+
// This method **must** be implemented on the same contract that requested the random number.
127+
// This method should **never** return an error -- if it returns an error, then the keeper will not be able to invoke the callback.
128+
// If you are having problems receiving the callback, the most likely cause is that the callback is erroring.
129+
// See the callback debugging guide here to identify the error https://docs.pyth.network/entropy/debug-callback-failures
130+
function entropyCallback(
131+
uint64 sequenceNumber,
132+
address provider,
133+
bytes32 randomNumber
134+
) internal override {
135+
// Implement your callback logic here.
136+
}
137+
138+
// This method is required by the IEntropyConsumer interface.
139+
// It returns the address of the entropy contract which will call the callback.
140+
function getEntropy() internal view override returns (address) {
141+
return address(entropy);
142+
}
140143
}
141144
`} />
142145

@@ -180,6 +183,8 @@ a keeper service for fullfilling requests.
180183

181184
You can 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:
182185

183-
<DynamicCodeBlock lang="solidity"
184-
code={`address provider = entropy.getDefaultProvider();
185-
`} />
186+
<DynamicCodeBlock
187+
lang="solidity"
188+
code={`address provider = entropy.getDefaultProvider();
189+
`}
190+
/>

0 commit comments

Comments
 (0)