Introduction
Example Orders
This section explains how to enable on-chain capabilities for a Warden Agent created with the Warden Agent Kit.
The guides you'll find here cover an example we created for demonstration purposes. It implements Orders – Solidity smart contracts performing on-chain actions and utilizing AI-driven price predictions.
You can implement custom logic by using Warden modules, Keychains, and other features. In particular, the x/async
module allows you to create smart contracts utilizing outputs of AI models.
In our example, Orders perform swaps on Uniswap, but you can make them send any transactions to any Ethereum-based and EVM L2 app. For example, your application can transfer ETH or call an arbitrary contract.
Please note that the articles in this section typically contain only fragments of code.
You can find the full code of the example on GitHub: /orders
Order types
You'll learn how to build two types of Orders:
-
Automated Orders: the
BasicOrder
contractThe basic automated Orders monitor prices and automatically execute token swaps on Uniswap when user-defined price thresholds are met, signing transactions with Keychains.
-
Automated Orders with price prediction: the
AdvancedOrder
contractThis is a more advanced version of automated Orders. It uses the
x/async
Warden module to make AI-driven price predictions. Then it performs token swaps based on these predictions, signing transactions with Keychains.noteThe price prediction model is just an example of what you can build with
x/async
. With this module, you can implement any logic combining off-chain computation with on-chain verification – limited only by your imagination.
Architecture
The core logic of Orders in implemented in two smart contracts:
BasicOrder
: A contract implementing Automated OrdersAdvancedOrder
: A contract implementing Automated Orders with price prediction
Both Order types share common infrastructure:
- Helpers and utils, including the
Registry
contract for storing the Order and transaction data - Warden & Slinky: Mock precompiles for signing transactions and fetching prices
IExecution
: A contract implementing the Order execution interfaceOrderFactory
: A contract facilitating the creation of Orders
Get started
To get started, take thise steps: