Dynamic Oracles

This guide explains how to implement a Solidity smart contract that utilizes Truebit to perform off-chain computation.

What Is Dynamic Oracles?

With Truebit’s Dynamic Oracle, smart contracts can securely trigger external computations or data requests that are handled by Truebit’s off-chain execution and verification layer. The platform ensures that results are returned verifiably and without requiring trust in third parties.

This Enables:

  • Running heavy or external computations off-chain while keeping on-chain trust

  • Cryptographic proof of task correctness

  • Seamless integration with smart contract logic

Available Execution Types

  • Dynamic JS Function: Execute a single JavaScript function directly from a smart contract without the need to deploy the function task previously. It will execute the code directly without the need to register in the platform.

  • Truebit API Task: Run your deployed Truebit API tasks directly from a smart contract and retrieve the result without encoding (bytes).

  • Truebit API Task with n8n Orchestration: Trigger an n8n workflow via a Truebit API and receive the result ABI-encoded.

System Components

  1. User Contract A custom smart contract developed by the task developer. It inherits from tbBaseContract, calls the _requestExecution method, and handles the callback with the computed result.

  2. WatchTower A Truebit-developed contract responsible for emitting events when new execution are requested and managing the response callbacks once computation is completed. This contract has all the needed logic required to interact with Truebit.


Technical Prerequisites

Before starting, please clone the examples repository to start working with Truebit.

git clone https://github.com/TruebitProtocol/truebit-nextgen-examples.git
  • You will find the following files under the folder "Blockchain"

    • /BaseTBContract.sol

    • /interfaces/IBaseTBContract.sol

    • /interfaces/IWatchTower.sol

    • /abstract/Types.sol

    • /examples/DemoContract.sol : You can use this contract as a reference for implementing a Dynamic Oracle within your own smart contract.

  • A Solidity development environment (^0.8.0)

  • WatchTower Address: 0xEcd0EeD24Ed6a54d05a07125c4ccb809b3A09868

Create Your Contract

Please review the implementation guides we’ve prepared to help you integrate with the Dynamic Oracle feature.

Last updated

Was this helpful?