From 897b81fad26b3435b5b5d2b1ae130b8490db8d59 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Wed, 1 Nov 2023 12:37:07 -0700 Subject: [PATCH 1/3] update parameters --- fortuna/src/config.rs | 3 +-- fortuna/src/config/generate.rs | 1 - fortuna/src/config/get_request.rs | 1 - fortuna/src/config/request_randomness.rs | 1 - fortuna/src/config/run.rs | 1 - .../ethereum/entropy_sdk/solidity/README.md | 8 ++++---- target_chains/ethereum/examples/coin_flip/README.md | 4 +++- .../ethereum/examples/coin_flip/app/src/flip_coin.ts | 2 +- .../examples/coin_flip/contract/scripts/deploy.sh | 12 +++++++----- .../examples/coin_flip/contract/src/CoinFlip.sol | 4 ++-- 10 files changed, 18 insertions(+), 19 deletions(-) diff --git a/fortuna/src/config.rs b/fortuna/src/config.rs index 73cd5dce9..71e80f900 100644 --- a/fortuna/src/config.rs +++ b/fortuna/src/config.rs @@ -76,13 +76,12 @@ pub struct RandomnessOptions { /// A secret used for generating new hash chains. A 64-char hex string. #[arg(long = "secret")] #[arg(env = "FORTUNA_SECRET")] - #[arg(default_value = "0000000000000000000000000000000000000000000000000000000000000000")] pub secret: String, /// The length of the hash chain to generate. #[arg(long = "chain-length")] #[arg(env = "FORTUNA_CHAIN_LENGTH")] - #[arg(default_value = "32")] + #[arg(default_value = "10000")] pub chain_length: u64, } diff --git a/fortuna/src/config/generate.rs b/fortuna/src/config/generate.rs index 163c8c93b..b33256bb1 100644 --- a/fortuna/src/config/generate.rs +++ b/fortuna/src/config/generate.rs @@ -29,7 +29,6 @@ pub struct GenerateOptions { /// Submit a randomness request to this provider #[arg(long = "provider")] - #[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")] pub provider: Address, #[arg(long = "url")] diff --git a/fortuna/src/config/get_request.rs b/fortuna/src/config/get_request.rs index 0e20f3b65..d4fb242f7 100644 --- a/fortuna/src/config/get_request.rs +++ b/fortuna/src/config/get_request.rs @@ -22,7 +22,6 @@ pub struct GetRequestOptions { /// Retrieve a randomness request to this provider #[arg(long = "provider")] #[arg(env = "FORTUNA_PROVIDER")] - #[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")] pub provider: Address, /// The sequence number of the request to retrieve diff --git a/fortuna/src/config/request_randomness.rs b/fortuna/src/config/request_randomness.rs index 01a76bacf..dd5ae6aff 100644 --- a/fortuna/src/config/request_randomness.rs +++ b/fortuna/src/config/request_randomness.rs @@ -28,6 +28,5 @@ pub struct RequestRandomnessOptions { /// Submit a randomness request to this provider #[arg(long = "provider")] #[arg(env = "FORTUNA_PROVIDER")] - #[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")] pub provider: Address, } diff --git a/fortuna/src/config/run.rs b/fortuna/src/config/run.rs index 46ebdb7ab..adef3f56b 100644 --- a/fortuna/src/config/run.rs +++ b/fortuna/src/config/run.rs @@ -26,6 +26,5 @@ pub struct RunOptions { /// The public key of the provider whose requests the server will respond to. #[arg(long = "provider")] #[arg(env = "FORTUNA_PROVIDER")] - #[arg(default_value = "0x368397bDc956b4F23847bE244f350Bde4615F25E")] pub provider: Address, } diff --git a/target_chains/ethereum/entropy_sdk/solidity/README.md b/target_chains/ethereum/entropy_sdk/solidity/README.md index 55ff8e687..a585bb4cd 100644 --- a/target_chains/ethereum/entropy_sdk/solidity/README.md +++ b/target_chains/ethereum/entropy_sdk/solidity/README.md @@ -17,9 +17,9 @@ To use the SDK, you need the address of an Entropy contract on your blockchain a The following table lists the current deployments of entropy. | Chain | Entropy Address | Provider | -| avalanche-fuji | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x368397bDc956b4F23847bE244f350Bde4615F25E -| 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: @@ -55,7 +55,7 @@ If you are invoking this off-chain, the method also emits a `PythRandomEvents.Re ### 3. Fetch the provider's number 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 await axios.get( diff --git a/target_chains/ethereum/examples/coin_flip/README.md b/target_chains/ethereum/examples/coin_flip/README.md index 4583a87ce..9781b3769 100644 --- a/target_chains/ethereum/examples/coin_flip/README.md +++ b/target_chains/ethereum/examples/coin_flip/README.md @@ -17,7 +17,9 @@ Next, choose a network to run the example on. The example has been deployed on the following networks: | Chain Name | Address | RPC | -| optimism-goerli | 0x075A5160FF6462924B4124595F6f987187496476 | https://goerli.optimism.io | +| 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. Then, from the `coin_flip/app` directory, run the following command: diff --git a/target_chains/ethereum/examples/coin_flip/app/src/flip_coin.ts b/target_chains/ethereum/examples/coin_flip/app/src/flip_coin.ts index 351f2f7fb..320f4488a 100644 --- a/target_chains/ethereum/examples/coin_flip/app/src/flip_coin.ts +++ b/target_chains/ethereum/examples/coin_flip/app/src/flip_coin.ts @@ -106,7 +106,7 @@ async function main() { // 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. 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("4. Revealing the result of the coin flip..."); diff --git a/target_chains/ethereum/examples/coin_flip/contract/scripts/deploy.sh b/target_chains/ethereum/examples/coin_flip/contract/scripts/deploy.sh index 404007078..658af760d 100755 --- a/target_chains/ethereum/examples/coin_flip/contract/scripts/deploy.sh +++ b/target_chains/ethereum/examples/coin_flip/contract/scripts/deploy.sh @@ -1,14 +1,16 @@ #!/bin/bash -e # 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 -ENTROPY_CONTRACT_ADDRESS="0x28F16Af4D87523910b843a801454AEde5F9B0459" -PROVIDER="0x368397bDc956b4F23847bE244f350Bde4615F25E" +ENTROPY_CONTRACT_ADDRESS="0xD42c7a708E74AD19401D907a14146F006c851Ee3" +PROVIDER="0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344" -# Deployed contracts -# Optimism goerli 0x075A5160FF6462924B4124595F6f987187496476 +# Deployments +# 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 # option if you are using a different wallet. diff --git a/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol b/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol index 36fa5d63d..6c023ee0e 100644 --- a/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol +++ b/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol @@ -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 // 2. Maintaining the secrecy of the other random numbers // 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; 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 // 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. // Fetch the following url: // https://fortuna-staging.pyth.network/v1/chains//revelations/ From cf86ed990b06c4cbe023e033e7cfa19fd53c16b4 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Wed, 1 Nov 2023 12:46:33 -0700 Subject: [PATCH 2/3] install instructions --- target_chains/ethereum/entropy_sdk/solidity/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target_chains/ethereum/entropy_sdk/solidity/README.md b/target_chains/ethereum/entropy_sdk/solidity/README.md index a585bb4cd..a70cca523 100644 --- a/target_chains/ethereum/entropy_sdk/solidity/README.md +++ b/target_chains/ethereum/entropy_sdk/solidity/README.md @@ -9,7 +9,9 @@ Use this protocol at your own risk. ## Install -TODO +```shell +npm install @pythnetwork/entropy-sdk-solidity +``` ## Setup From 377709fd388782a490a7127d4deb0a6c6415ae42 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Wed, 1 Nov 2023 13:16:45 -0700 Subject: [PATCH 3/3] format stuff --- fortuna/Cargo.toml | 2 +- target_chains/ethereum/entropy_sdk/solidity/README.md | 11 +++++++---- .../ethereum/entropy_sdk/solidity/package.json | 2 +- target_chains/ethereum/examples/coin_flip/README.md | 11 +++++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fortuna/Cargo.toml b/fortuna/Cargo.toml index 5eb8fd4b5..7d39aa1ad 100644 --- a/fortuna/Cargo.toml +++ b/fortuna/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fortuna" -version = "0.1.0" +version = "1.0.0" edition = "2021" [dependencies] diff --git a/target_chains/ethereum/entropy_sdk/solidity/README.md b/target_chains/ethereum/entropy_sdk/solidity/README.md index a70cca523..86d0122e1 100644 --- a/target_chains/ethereum/entropy_sdk/solidity/README.md +++ b/target_chains/ethereum/entropy_sdk/solidity/README.md @@ -18,10 +18,13 @@ npm install @pythnetwork/entropy-sdk-solidity 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. -| Chain | Entropy Address | Provider | -| avalanche-fuji | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 -| optimism-goerli | 0x28F16Af4D87523910b843a801454AEde5F9B0459 | 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 -| eos-evm-testnet | 0xD42c7a708E74AD19401D907a14146F006c851Ee3 | 0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 +``` +| Chain | Entropy Address | Provider | +|-----------------|--------------------------------------------|--------------------------------------------| +| 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: diff --git a/target_chains/ethereum/entropy_sdk/solidity/package.json b/target_chains/ethereum/entropy_sdk/solidity/package.json index a295184e3..750432b95 100644 --- a/target_chains/ethereum/entropy_sdk/solidity/package.json +++ b/target_chains/ethereum/entropy_sdk/solidity/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/entropy-sdk-solidity", - "version": "0.1.0", + "version": "0.1.1", "description": "Generate secure random numbers with Pyth Entropy", "repository": { "type": "git", diff --git a/target_chains/ethereum/examples/coin_flip/README.md b/target_chains/ethereum/examples/coin_flip/README.md index 9781b3769..8864677a1 100644 --- a/target_chains/ethereum/examples/coin_flip/README.md +++ b/target_chains/ethereum/examples/coin_flip/README.md @@ -16,10 +16,13 @@ These commands will build dependencies for the typescript project. Next, choose a network to run the example on. The example has been deployed on the following networks: -| 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/ | +``` +| 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. Then, from the `coin_flip/app` directory, run the following command: