|
| 1 | +--- |
| 2 | +description: Deploy a trustless Eliza AI agent on Oasis using ROFL enclaves, |
| 3 | + with enclave-managed keys and on-chain verification on Sapphire. |
| 4 | +tags: [ROFL, AI, appd, secrets] |
| 5 | +--- |
| 6 | + |
| 7 | +import Tabs from '@theme/Tabs'; |
| 8 | +import TabItem from '@theme/TabItem'; |
| 9 | + |
| 10 | +# Trustless AI Agent |
| 11 | + |
| 12 | +Learn how to deploy a trustless Eliza agent on Oasis using ROFL enclaves. |
| 13 | + |
| 14 | +## What You’ll Build |
| 15 | + |
| 16 | +By the end you will have a working Eliza agent running inside a ROFL Trusted |
| 17 | +Execution Environment (TEE), registered and validated as a trustless agent in |
| 18 | +the [ERC-8004] registry. The agent's code can be fully audited and proved that |
| 19 | +the deployed instance really originates from it and cannot be silently altered. |
| 20 | + |
| 21 | +[ERC-8004]: https://eips.ethereum.org/EIPS/eip-8004 |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +You will need: |
| 26 | +- Docker (or Podman) with credentials on docker.io, ghcr.io or other public OCI |
| 27 | + registry |
| 28 | +- [Oasis CLI] |
| 29 | +- Node.js 22+ (for Eliza and helper scripts) |
| 30 | +- a Sapphire Testnet account funded with TEST |
| 31 | +- OpenAI API key |
| 32 | +- RPC URL for accessing the ERC-8004 registry |
| 33 | +- Pinata JWT for storing agent information to IPFS |
| 34 | + |
| 35 | +[Oasis CLI]: https://github.com/oasisprotocol/cli/blob/master/docs/README.md |
| 36 | + |
| 37 | +## Create an Eliza Agent |
| 38 | + |
| 39 | +Initialize a project using the ElizaOS CLI and prepare it for ROFL. |
| 40 | + |
| 41 | +```shell |
| 42 | +# Install bun and ElizaOS CLI |
| 43 | +bun --version || curl -fsSL https://bun.sh/install | bash |
| 44 | +bun install -g @elizaos/cli |
| 45 | + |
| 46 | +# Create and configure the agent |
| 47 | +elizaos create -t project rofl-eliza |
| 48 | +# 1) Select Pqlite database |
| 49 | +# 2) Select the OpenAI model and enter your OpenAI key |
| 50 | + |
| 51 | +# Test the agent locally |
| 52 | +cd rofl-eliza |
| 53 | +elizaos start |
| 54 | +# Visiting http://localhost:3000 with your browser should open Eliza UI |
| 55 | +``` |
| 56 | + |
| 57 | +## Containerize the App and the ERC-8004 wrapper |
| 58 | + |
| 59 | +The Eliza agent startup wizard already generated the `Dockerfile` that packs |
| 60 | +your agent into a container. |
| 61 | + |
| 62 | +Next, we'll make sure that the Eliza agent is registered as a trustless agent in |
| 63 | +the ERC-8004 registry. A helper image called [`rofl-8004`] will do the |
| 64 | +registration for us. Create the following `compose.yaml` file: |
| 65 | + |
| 66 | +```yaml title="compose.yaml" |
| 67 | +services: |
| 68 | + rofl-eliza: |
| 69 | + build: . |
| 70 | + image: docker.io/YOUR_USERNAME/rofl-eliza:latest |
| 71 | + platform: linux/amd64 |
| 72 | + environment: |
| 73 | + - OPENAI_API_KEY=${OPENAI_API_KEY} |
| 74 | + volumes: |
| 75 | + - eliza-storage:/root/.eliza |
| 76 | + |
| 77 | + rofl-8004: |
| 78 | + image: ghcr.io/oasisprotocol/rofl-8004 |
| 79 | + platform: linux/amd64 |
| 80 | + environment: |
| 81 | + # RPC for ERC-8004 registry. e.g. https://sepolia.infura.io/v3/<YOUR_KEY> |
| 82 | + - RPC_URL=${RPC_URL} |
| 83 | + # Pinata token for storing token URI when registering new agent. |
| 84 | + - PINATA_JWT=${PINATA_JWT} |
| 85 | + volumes: |
| 86 | + - /run/rofl-appd.sock:/run/rofl-appd.sock |
| 87 | + |
| 88 | +volumes: |
| 89 | + eliza-storage: |
| 90 | +``` |
| 91 | +
|
| 92 | +Build and push: |
| 93 | +
|
| 94 | +```shell |
| 95 | +docker compose build |
| 96 | +docker compose push |
| 97 | +``` |
| 98 | + |
| 99 | +For extra security and verifiability pin the digest and use |
| 100 | +`image: ...@sha256:...` in `compose.yaml`. |
| 101 | + |
| 102 | +[`rofl-8004`]: https://github.com/oasisprotocol/erc-8004 |
| 103 | + |
| 104 | +## Init ROFL and Create App |
| 105 | + |
| 106 | +The agent will run in a container inside a TEE. ROFL will handle the startup |
| 107 | +attestation of the container and the secrets in form of environment variables. |
| 108 | +This way TEE will be completely transparent to the agent app. |
| 109 | + |
| 110 | +```shell |
| 111 | +oasis rofl init |
| 112 | +oasis rofl create --network testnet |
| 113 | +``` |
| 114 | + |
| 115 | +After creation, you should be able to find your app on the [Oasis Explorer]. |
| 116 | + |
| 117 | +## Build ROFL bundle |
| 118 | + |
| 119 | +Eliza requires at least 2 GiB of memory and 5 GB of storage. Update the |
| 120 | +`resources` section in `rofl.yaml` to at least: `memory: 2048` and |
| 121 | +`storage.size: 5000`. |
| 122 | + |
| 123 | +Then, build the ROFL bundle by invoking: |
| 124 | + |
| 125 | +<Tabs> |
| 126 | + <TabItem value="Native Linux"> |
| 127 | + ```shell |
| 128 | + oasis rofl build |
| 129 | + ``` |
| 130 | + </TabItem> |
| 131 | + <TabItem value="Docker (Mac/Windows/Linux)"> |
| 132 | + ```shell |
| 133 | + docker run --platform linux/amd64 --volume .:/src \ |
| 134 | + -it ghcr.io/oasisprotocol/rofl-dev:main oasis rofl build |
| 135 | + ``` |
| 136 | + </TabItem> |
| 137 | +</Tabs> |
| 138 | + |
| 139 | +## Secrets |
| 140 | + |
| 141 | +Let's end-to-end encrypt `OPENAI_API_KEY` and store it on-chain. Also, provide |
| 142 | +the `RPC_URL` and `PINATA_JWT` values for ERC-8004 registration. |
| 143 | + |
| 144 | +```shell |
| 145 | +echo -n "<your-openai-key-here>" | oasis rofl secret set OPENAI_API_KEY - |
| 146 | +echo -n "<rpc-url-including-infura-key>" | oasis rofl secret set RPC_URL - |
| 147 | +echo -n "<your-pinata-key-here>" | oasis rofl secret set PINATA_JWT - |
| 148 | +``` |
| 149 | + |
| 150 | +Then store enclave identities and secrets on-chain: |
| 151 | + |
| 152 | +```shell |
| 153 | +oasis rofl update |
| 154 | +``` |
| 155 | + |
| 156 | +## Deploy |
| 157 | + |
| 158 | +Deploy your Eliza agent to a ROLF provider by invoking: |
| 159 | + |
| 160 | +```shell |
| 161 | +oasis rofl deploy |
| 162 | +``` |
| 163 | + |
| 164 | +By default, the Oasis-maintained provider is selected on Testnet, but you can |
| 165 | +pick any other provider by passing the [`--provider <address>`][provider] |
| 166 | +parameter. |
| 167 | + |
| 168 | +[provider]: https://github.com/oasisprotocol/cli/blob/master/docs/rofl.md#deploy |
| 169 | + |
| 170 | +## Testing it out |
| 171 | + |
| 172 | +After deploying the agent, use the CLI to check machine status and view logs. |
| 173 | + |
| 174 | +```shell |
| 175 | +# Show machine details (IDs, state, proxy URLs, expiration). |
| 176 | +oasis rofl machine show |
| 177 | + |
| 178 | +# Fetch logs from your running ROFL app. |
| 179 | +oasis rofl machine logs |
| 180 | +``` |
| 181 | + |
| 182 | +When spinning up the agent for the first time, the `rofl-8004` service will |
| 183 | +derive the ethereum address for registering the agent. Look for `Please top it |
| 184 | +up` line in your logs and then send a small amount of ether to that address to |
| 185 | +pay for the fees. |
| 186 | + |
| 187 | +Also: |
| 188 | + |
| 189 | +- Expect standard output from your app container (anything your entrypoint |
| 190 | + prints). |
| 191 | +- If your app initializes services on startup, those startup logs will appear |
| 192 | + here. |
| 193 | +- Use this to check enclave startup issues and app readiness. |
| 194 | + |
| 195 | +:::warning |
| 196 | + |
| 197 | +Logs are accessible to the app admin and are stored unencrypted on the ROFL |
| 198 | +node. Avoid printing secrets. See the official docs: |
| 199 | + |
| 200 | +- [`oasis rofl machine logs`][machine-logs] |
| 201 | +- [ROFL workflow—logs and deploy notes][sdk-deploy-logs] |
| 202 | + |
| 203 | +::: |
| 204 | + |
| 205 | +Inspect on-chain activity and app details in the [Oasis Explorer]. |
| 206 | + |
| 207 | +[machine-logs]: https://github.com/oasisprotocol/cli/blob/master/docs/rofl.md#machine-logs |
| 208 | +[sdk-deploy-logs]: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/workflow/deploy.md#check-that-the-app-is-running |
| 209 | +[Oasis Explorer]: https://explorer.oasis.io/testnet/sapphire |
0 commit comments