[entropy] Minor updates to parameters / docs (#1131)

* update parameters

* install instructions

* format stuff
This commit is contained in:
Jayant Krishnamurthy 2023-11-01 13:34:47 -07:00 committed by GitHub
parent 44ebfbaf55
commit 8c35091831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 31 additions and 24 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fortuna" name = "fortuna"
version = "0.1.0" version = "1.0.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -76,13 +76,12 @@ pub struct RandomnessOptions {
/// A secret used for generating new hash chains. A 64-char hex string. /// A secret used for generating new hash chains. A 64-char hex string.
#[arg(long = "secret")] #[arg(long = "secret")]
#[arg(env = "FORTUNA_SECRET")] #[arg(env = "FORTUNA_SECRET")]
#[arg(default_value = "0000000000000000000000000000000000000000000000000000000000000000")]
pub secret: String, pub secret: String,
/// The length of the hash chain to generate. /// The length of the hash chain to generate.
#[arg(long = "chain-length")] #[arg(long = "chain-length")]
#[arg(env = "FORTUNA_CHAIN_LENGTH")] #[arg(env = "FORTUNA_CHAIN_LENGTH")]
#[arg(default_value = "32")] #[arg(default_value = "10000")]
pub chain_length: u64, pub chain_length: u64,
} }

View File

@ -29,7 +29,6 @@ pub struct GenerateOptions {
/// Submit a randomness request to this provider /// Submit a randomness request to this provider
#[arg(long = "provider")] #[arg(long = "provider")]
#[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")]
pub provider: Address, pub provider: Address,
#[arg(long = "url")] #[arg(long = "url")]

View File

@ -22,7 +22,6 @@ pub struct GetRequestOptions {
/// Retrieve a randomness request to this provider /// Retrieve a randomness request to this provider
#[arg(long = "provider")] #[arg(long = "provider")]
#[arg(env = "FORTUNA_PROVIDER")] #[arg(env = "FORTUNA_PROVIDER")]
#[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")]
pub provider: Address, pub provider: Address,
/// The sequence number of the request to retrieve /// The sequence number of the request to retrieve

View File

@ -28,6 +28,5 @@ pub struct RequestRandomnessOptions {
/// Submit a randomness request to this provider /// Submit a randomness request to this provider
#[arg(long = "provider")] #[arg(long = "provider")]
#[arg(env = "FORTUNA_PROVIDER")] #[arg(env = "FORTUNA_PROVIDER")]
#[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")]
pub provider: Address, pub provider: Address,
} }

View File

@ -26,6 +26,5 @@ pub struct RunOptions {
/// The public key of the provider whose requests the server will respond to. /// The public key of the provider whose requests the server will respond to.
#[arg(long = "provider")] #[arg(long = "provider")]
#[arg(env = "FORTUNA_PROVIDER")] #[arg(env = "FORTUNA_PROVIDER")]
#[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")]
pub provider: Address, pub provider: Address,
} }

View File

@ -9,17 +9,22 @@ Use this protocol at your own risk.
## Install ## Install
TODO ```shell
npm install @pythnetwork/entropy-sdk-solidity
```
## Setup ## Setup
To use the SDK, you need the address of an Entropy contract on your blockchain and a randomness provider. To use the SDK, you need the address of an Entropy contract on your blockchain and a randomness provider.
The following table lists the current deployments of entropy. The following table lists the current deployments of entropy.
| Chain | Entropy Address | Provider | ```
| avalanche-fuji | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x368397bDc956b4F23847bE244f350Bde4615F25E | Chain | Entropy Address | Provider |
| optimism-goerli | 0x28F16Af4D87523910b843a801454AEde5F9B0459 | 0x368397bDc956b4F23847bE244f350Bde4615F25E |-----------------|--------------------------------------------|--------------------------------------------|
| eos-evm-testnet | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x368397bDc956b4F23847bE244f350Bde4615F25E | avalanche-fuji | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 |
| optimism-goerli | 0x28F16Af4D87523910b843a801454AEde5F9B0459 | 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 |
| eos-evm-testnet | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 |
```
Choose one of these networks and instantiate an `IEntropy` contract in your solidity contract: Choose one of these networks and instantiate an `IEntropy` contract in your solidity contract:
@ -55,7 +60,7 @@ If you are invoking this off-chain, the method also emits a `PythRandomEvents.Re
### 3. Fetch the provider's number ### 3. Fetch the provider's number
Fetch the provider's random number from them. Fetch the provider's random number from them.
For the provider `0x368397bDc956b4F23847bE244f350Bde4615F25E` you can query the webservice at https://fortuna-staging.pyth.network : For the provider `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344` you can query the webservice at https://fortuna-staging.pyth.network :
```typescript ```typescript
await axios.get( await axios.get(

View File

@ -1,6 +1,6 @@
{ {
"name": "@pythnetwork/entropy-sdk-solidity", "name": "@pythnetwork/entropy-sdk-solidity",
"version": "0.1.0", "version": "0.1.1",
"description": "Generate secure random numbers with Pyth Entropy", "description": "Generate secure random numbers with Pyth Entropy",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -16,8 +16,13 @@ These commands will build dependencies for the typescript project.
Next, choose a network to run the example on. Next, choose a network to run the example on.
The example has been deployed on the following networks: The example has been deployed on the following networks:
| Chain Name | Address | RPC | ```
| optimism-goerli | 0x075A5160FF6462924B4124595F6f987187496476 | https://goerli.optimism.io | | Chain Name | Address | RPC |
|-----------------|--------------------------------------------|--------------------------------------------|
| optimism-goerli | 0x3bA217Cd7840Cc5B34FD5B7263Cebd8CD8665788 | https://goerli.optimism.io |
| avalanche-fuji | 0xE7E52C85907d59C45b2C56EF32B78F514F8c547a | https://api.avax-test.network/ext/bc/C/rpc |
| eos-evm-testnet | 0x413405Aee2db95cb028B60CBAd87FC0B932947f4 | https://api.testnet.evm.eosnetwork.com/ |
```
You will also need the private key of a wallet with some gas tokens for your chosen network. You will also need the private key of a wallet with some gas tokens for your chosen network.
Then, from the `coin_flip/app` directory, run the following command: Then, from the `coin_flip/app` directory, run the following command:

View File

@ -106,7 +106,7 @@ async function main() {
// Note that there is a potential race condition here: the server may not have observed the request ^ // Note that there is a potential race condition here: the server may not have observed the request ^
// before this HTTP response. Hence, we retry fetching the url a couple of times. // before this HTTP response. Hence, we retry fetching the url a couple of times.
const response = await fetchWithRetry(url, 3); const response = await fetchWithRetry(url, 3);
const providerRandom = web3.utils.bytesToHex(response.value); const providerRandom = `0x${response.value.data}`;
console.log(` number : ${providerRandom}`); console.log(` number : ${providerRandom}`);
console.log("4. Revealing the result of the coin flip..."); console.log("4. Revealing the result of the coin flip...");

View File

@ -1,14 +1,16 @@
#!/bin/bash -e #!/bin/bash -e
# URL of the ethereum RPC node to use. Choose this based on your target network # URL of the ethereum RPC node to use. Choose this based on your target network
RPC_URL=https://goerli.optimism.io RPC_URL=https://api.testnet.evm.eosnetwork.com/
# The address of the Pyth contract on your network. See the list of contract addresses here https://docs.pyth.network/documentation/pythnet-price-feeds/evm # The address of the Pyth contract on your network. See the list of contract addresses here https://docs.pyth.network/documentation/pythnet-price-feeds/evm
ENTROPY_CONTRACT_ADDRESS="0x28F16Af4D87523910b843a801454AEde5F9B0459" ENTROPY_CONTRACT_ADDRESS="0xD42c7a708E74AD19401D907a14146F006c851Ee3"
PROVIDER="0x368397bDc956b4F23847bE244f350Bde4615F25E" PROVIDER="0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344"
# Deployed contracts # Deployments
# Optimism goerli 0x075A5160FF6462924B4124595F6f987187496476 # optimism-goerli 0x3bA217Cd7840Cc5B34FD5B7263Cebd8CD8665788
# avalanche-fuji 0xE7E52C85907d59C45b2C56EF32B78F514F8c547a
# eos-evm-testnet 0x413405Aee2db95cb028B60CBAd87FC0B932947f4
# Note the -l here uses a ledger wallet to deploy your contract. You may need to change this # Note the -l here uses a ledger wallet to deploy your contract. You may need to change this
# option if you are using a different wallet. # option if you are using a different wallet.

View File

@ -30,7 +30,7 @@ contract CoinFlip {
// 1. Operating an off-chain service that reveals their random numbers once they've been committed to on-chain // 1. Operating an off-chain service that reveals their random numbers once they've been committed to on-chain
// 2. Maintaining the secrecy of the other random numbers // 2. Maintaining the secrecy of the other random numbers
// Users should choose a reliable provider who they trust to uphold these commitments. // Users should choose a reliable provider who they trust to uphold these commitments.
// (For the moment, the only available provider is 0x368397bDc956b4F23847bE244f350Bde4615F25E) // (For the moment, the only available provider is 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344)
IEntropy private entropy; IEntropy private entropy;
address private entropyProvider; address private entropyProvider;
@ -84,7 +84,7 @@ contract CoinFlip {
// committed to, as well as the entropy provider's random number. The provider's random number can be retrieved // committed to, as well as the entropy provider's random number. The provider's random number can be retrieved
// from them in a provider-dependent manner. // from them in a provider-dependent manner.
// //
// For the moment, the provider 0x368397bDc956b4F23847bE244f350Bde4615F25E hosts a webservice at // For the moment, the provider 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 hosts a webservice at
// https://fortuna-staging.pyth.network/ that allows anyone to retrieve their random values. // https://fortuna-staging.pyth.network/ that allows anyone to retrieve their random values.
// Fetch the following url: // Fetch the following url:
// https://fortuna-staging.pyth.network/v1/chains/<chain id>/revelations/<sequence number> // https://fortuna-staging.pyth.network/v1/chains/<chain id>/revelations/<sequence number>