Skip to content

Commit

Permalink
Merge pull request #373 from gnosischain/fixing-folder
Browse files Browse the repository at this point in the history
hotfix
  • Loading branch information
alebanzas authored Feb 1, 2023
2 parents 0c32f87 + 5fb19e4 commit 0113d02
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 62 deletions.
1 change: 1 addition & 0 deletions docs/node/guide/server/_partials/_install-initial.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import JwtGenerationPartial from '@site/docs/node/guide/server/_partials/_jwt-ge
Place the `jwt.hex` file in the jwtsecret folder, so it can be referenced in the next steps as `../jwtsecret/jwt.hex` for the `consensus` and `execution` clients.
:::
</TabItem>
<TabItem value="ipc"></TabItem>
</Tabs>


Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Lighthouse only runs on Linux. To run it on Windows, [Install Linux on Windows w
:::

</TabItem>
<TabItem value="others"></TabItem>
</Tabs>

<Tabs className="tabgroup-with-label network-tabgroup" groupId="network" defaultValue="gnosis" values={[
Expand Down
31 changes: 0 additions & 31 deletions docs/tools/oracles/supraoracles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@ To get started, you will want to visit [SupraOracles' docs site](https://supra

Add the following code to the Solidity smart contract that you wish to retrieve an S-Value.

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
interface ISupraSValueFeed {
function checkPrice(string memory marketPair) external view returns (int256 price, uint256 timestamp);
}
```

</TabItem>
</Tabs>

This creates the interface that you will later apply in order to fetch a price from SupraOracles.


Expand All @@ -53,9 +47,6 @@ For Gnosis Chiado TestNet, the address is:

When you have the proper address, create an instance of the S-Value Feed using the interface we previously defined for Gnosis Chiado TestNet:

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
contract ISupraSValueFeedExample {
ISupraSValueFeed internal sValueFeed;
Expand All @@ -66,17 +57,10 @@ contract ISupraSValueFeedExample {
}
```

</TabItem>
</Tabs>


### Step 3: Get The S-Value Crypto Price

Now you can simply access the S-Value Crypto Price of our supported market pairs. In this step, we'll get the price of ETH/USDT (eth_usdt) by applying the following code to our Smart Contract.

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
function getEthUsdtPrice() external view returns (int) {
(
Expand All @@ -88,14 +72,8 @@ function getEthUsdtPrice() external view returns (int) {
}
```

</TabItem>
</Tabs>

Here's an example of what your implementation should look like.

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
Expand Down Expand Up @@ -123,16 +101,10 @@ contract ISupraSValueFeedExample {
}
```

</TabItem>
</Tabs>

You now have a method in your Smart Contract that you can call at any time to retrieve the price of ETH in USDT.

### Extra: S-Value Feeds with ethers.js

<Tabs>
<TabItem value="js" label="Javascript" default>

```js
// example assumes that the ethers library has been imported and is accessible within your scope
const getEthUsdtPrice = async () => {
Expand All @@ -148,9 +120,6 @@ const getEthUsdtPrice = async () => {
getEthUsdtPrice()
```

</TabItem>
</Tabs>

For additional tutorials and guides based on example use-cases, please refer to the [Supra docs](https://supraoracles.com/docs/additional-guides).


Expand Down
32 changes: 1 addition & 31 deletions docs/tools/oracles/supraoracles/vrf.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ To get started, you will want to visit [SupraOracles' docs site](https://supraor

Add the following code to the requester contract i.e, the contract which uses VRF as a service. You can also add the code in a separate Interface and inherit the interface in the requester contract.

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
interface ISupraRouter {
function generateRequest(string memory _functionSig , uint8 _rngCount, uint256 _numConfirmations) external returns(uint256);
function generateRequest(string memory _functionSig , uint8 _rngCount, uint256 _numConfirmations, uint256 _clientSeed) external returns(uint256);
}
```

</TabItem>
</Tabs>

This interface will help the requester contract interact with the Supra Router contract and through which the requester contract can use the VRF service.


Expand All @@ -55,10 +49,6 @@ For Gnosis Chiado TestNet, the address is:

We’ll store the set the address within the constructor and use it later to interact with the interface.


<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
contract ExampleContract {
address supraAddr;
Expand All @@ -69,9 +59,6 @@ contract ExampleContract {
}
```

</TabItem>
</Tabs>

### Step 3: Use the VRF service and request a Random Number

In this step, we'll use the “generateRequest” function of the Supra Router Contract to create a request for random numbers. There are two modes for the "generateRequest" function. The only difference between them is that you can optionally provide a client-side input, which will also be part of the payload being threshold signed to provide randomness.
Expand All @@ -83,9 +70,6 @@ Supra's VRF process requires splitting the contract logic into two functions.
* The request function - the signature of this function is up to the developer
* The callback function - the signature must be of the form **“uint256 nonce, uint256[] calldata rngList”**

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
function exampleRNG() external {
//Function validation and logic
Expand All @@ -102,25 +86,16 @@ function exampleRNG() external {
}
```

</TabItem>
</Tabs>

### Step 4 - Add the validation in the callback function of requester contract

Inside the callback function where the requester contract wants the random number (in this example the callback function is exampleCallback), the requester contract will have to add the validation such that only the Supra router contract can call the function. The validation is necessary to protect against malicious contracts/users executing the callback with fake data.

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
function exampleCallback(uint256 _nonce ,uint256[] _rngList) external {
require(msg.sender == supraAddr);
// Following the required logic of the function
}
```

</TabItem>
</Tabs>
```

### Example Implementation

Expand All @@ -130,9 +105,6 @@ In the example below,
* Then the callback function prints the random numbers requested by a specific user and it has the signature: myCallbackUsername(uint256 nonce, uint256[] calldata rngList)
Once Supra generates the random number and it is verified by the on-chain logic to be authentic, myCallbackUsername is executed by the Supra Router, which completes the second half of the process. The nonce from the first argument is used to look up the username that originated the request.

<Tabs>
<TabItem value="solidity" label="Solidity" default>

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
Expand Down Expand Up @@ -170,8 +142,6 @@ contract Interaction {
}
}
```
</TabItem>
</Tabs>

For additional tutorials and guides based on example use-cases, please refer to the [Supra Docs](https://supraoracles.com/docs/additional-guides).

Expand Down

0 comments on commit 0113d02

Please sign in to comment.