Developers
Deploy a Pre-configured Reputer

Deploy a Coin Prediction Reputer

This is an example of a setup for running an Allora Network reputer node for providing ground truth and reputation, where the Allora Network node defers the requests to another container which is responsible for providing the ground truth, which is run in a separate container. It also provides a means of updating the internal database of the ground truth provider.

Components

  • Reputer: The node that responds to reputer requests from the Allora Network.
  • Truth: A container that performs reputation tasks, maintains the state of the model, and responds to reputation requests via a simple Flask application. It fetches data from CoinGecko.
  • Updater: A cron-like container designed to periodically trigger the Truth node's data updates.

A full working example for a reputer node for ETH price prediction topics is provided in the docker-compose.yml file (opens in a new tab) of our example repo. Simply run:

Setup a Reputer Node with docker-compose

Download the Repository

git clone https://github.com/allora-network/coin-prediction-reputer.git
cd coin-prediction-reputer

Configure Your Environment

  1. Copy config.example.json and name the copy config.json.
  2. Open config.json and update the necessary fields inside the wallet sub-object and worker config with your specific values:

wallet Sub-object

  1. nodeRpc: The RPC URL for the corresponding network the node will be deployed on
  2. addressKeyName: The name you gave your wallet key when setting up your wallet
  3. addressRestoreMnemonic: The mnemonic that was outputted when setting up a new key

reputer Config

  1. topicId: The specific topic ID you created the reputer for.
  2. SourceOfTruthEndpoint: The endpoint exposed by your source of truth server to provide the truth data to the network.
  3. Token: The token for the specific topic you are verifying truth data for. This token should be included in the source of truth endpoint for retrieval.
    • The Token variable is specific to the endpoint you expose in your main.py file. It is not related to any blockchain parameter and is only locally specific.
  4. minStake: The minimum stake required to participate as a reputer. This stake will be deducted from the reputer's wallet balance.
  5. loopSeconds: The amount of seconds to wait between attempts to get the next reputer nonce
💡

When placing your minimum stake, the system will verify the amount of funds you have already staked in the topic. If your staked amount is insufficient, it will automatically pull the necessary funds from your wallet to meet the required minimum.

⚠️

The reputer config is an array of sub-objects, each representing a different topic ID. This structure allows you to manage multiple topic IDs, each within its own sub-object.

To deploy a reputer that provides inferences for multiple topics, you can duplicate the existing sub-object and add it to the reputer array. Update the topicId, SourceOfTruthEndpoint, minStake and Token fields with the appropriate values for each new topic:

"worker": [
      {
          "topicId": 1,
          "reputerEntrypointName": "api-worker-reputer",
          "loopSeconds": 30,
          "minStake": 100000,
          "parameters": {
              "SourceOfTruthEndpoint": "http://source:8888/truth/{Token}/{BlockHeight}",
              "Token": "ethereum"
          }
      },
      // reputer providing ground truth for topic ID 2
      {
          "topicId": 2,
          "reputerEntrypointName": "api-worker-reputer",
          "loopSeconds": 30,
          "minStake": 100000,
          "parameters": {
              "SourceOfTruthEndpoint": "http://source:8888/truth/{Token}/{BlockHeight}",
              "Token": "ethereum"
          }
      }
    ],

Running the Node

Now that the node is configured, let's deploy and register it to the network. To run the node, follow these steps:

Export Variables

Execute the following command from the root directory:

chmod +x init.config
./init.config 

This command will automatically export the necessary variables from the account created. These variables are used by the offchain node and are bundled with your provided config.json, then passed to the node as environment variables.

💡

If you need to make changes to your config.json file after you ran the init.config command, rerun:

chmod +x init.config
./init.config 

before proceeding.

Request from Faucet

Copy your Allora address and request some tokens from the Allora Testnet Faucet (opens in a new tab) to register your reputer in the next step successfully.

Deploy the Node

docker compose up --build

Both the offchain node and the source services will be started. They will communicate through endpoints attached to the internal DNS.

A successful response from your Reputer should display:

{"level":"debug","msg":"Send Reputer Data to chain","txHash":"<tx-hash>","time":"<timestamp>","message":"Success"}

Congratulations! You've successfully deployed and registered your node on Allora.

Keep it updated

You can keep the state updated by hitting the url:

http://localhost:8000/update/<token-name>/<token-from>/<token-to>

where:

  • token-name: the name of the token on internal database, e.g. ETHUSD
  • token-from: the name of the token on Coingecko naming, e.g. ethereum
  • token-to: the name of the token on Coingecko naming, e.g. usd

It is expected that this endpoint is hit periodically, as this is crucial for maintaining the accuracy of the provided ground truth.

Testing the Truth Service

Here we'll setup a reputer with only the "truth service", which fetches the ground truth.

To only test the truth service, you can simply follow these steps:

  • Run docker compose up --build truth and wait for the initial data load.
  • Requests can now be sent, e.g. ETH price ground truths can be fetched with:
      $ curl http://localhost:8000/gt/ETHUSD/1719565747
      {"value":"3431.440268842158"}
    or you can trigger an update to the current ETH price:
      $ curl http://localhost:8000/update/ETHUSD/ethereum/usd