Deploying the AI DAO
On this page we'll guide you through deploying your own instance of the AI DAO.
Prerequisites
-
First please make sure you have all the prerequisites from our quickstart.
-
Additionally, you'll need to set up an account on
NEAR AI
, fund it, and obtain an API key. This can be done through the NEAR AI Dashboard.
-
First,
clone
the repo.git clone https://github.com/NearDeFi/shade-agent-template
cd shade-agent-template -
Rename the
.env.development.local.example
file name to.env.development.local
and configure yourenvironment variables
. -
Start up Docker:
- Linux
- Mac
sudo systemctl start docker
Simply open the Docker Desktop application or run:
open -a Docker
-
Install dependencies
npm i
Local Development
In this tutorial, the AI DAO uses a custom agent contract
. Because of this, you need to manually switch the contract deployed depending on whether you're developing locally or deploying the agent to a TEE.
-
For local development, you need to comment out the require approved code hash line within the
agent_vote
function. This allows anyone to call the function, not just a registered agent. By design, it's impossible for an agent to register when running locally, as it can't provide a valid TEE attestation.Loading...
-
Since the AI DAO uses a custom agent contract, you need to compile it yourself.
- Linux
- Mac
cargo near build non-reproducible-wasm
docker run --rm -v "$(pwd)":/workspace pivortex/near-builder@sha256:cdffded38c6cff93a046171269268f99d517237fac800f58e5ad1bcd8d6e2418 cargo near build non-reproducible-wasm
-
Make sure that the NEXT_PUBLIC_contractId prefix is set to
ac-proxy.
followed by your NEAR account ID so the CLI is configured for local deployment. -
Run the Shade Agent CLI with the
wasm
andfunding
flags. The wasm flag tells the CLI the path to the wasm file of the agent contract you're deploying, and the funding flag tells the CLI how much NEAR to fund the deployment with. 7 NEAR is sufficient for the size of the DAO contract.shade-agent-cli --wasm contract/target/near/contract.wasm --funding 7
The CLI may prompt you to enter your sudo password.
TEE Deployment
-
Re-introduce the require approved code hash line so it requires an agent to be registered, meaning it's running in a genuine TEE and executing the expected agent code.
Loading...
-
Because the contract has changed since you last deployed it, you need to compile it again.
- Linux
- Mac
cargo near build non-reproducible-wasm
docker run --rm -v "$(pwd)":/workspace pivortex/near-builder@sha256:cdffded38c6cff93a046171269268f99d517237fac800f58e5ad1bcd8d6e2418 cargo near build non-reproducible-wasm
-
Change the NEXT_PUBLIC_contractId prefix to
ac-sandbox.
followed by your NEAR account ID so the CLI is configured for TEE deployment. -
Run the Shade Agent CLI with the
wasm
andfunding
flags.shade-agent-cli --wasm contract/target/near/contract.wasm --funding 7
The CLI may prompt you to enter your sudo password.
After deploying to Phala Cloud, monitor your deployments and delete unused ones to avoid unnecessary costs. You can manage your deployments from thedashboard.
Interacting with the AI DAO
-
Set the DAO manifesto in the contract. Since the
NEAR_ACCOUNT_ID
in your environment variables is automatically assigned theowner
of the agent contract, you need to sign this transaction using itsSEED_PHRASE
.near contract call-function as-transaction YOUR_CONTRACT_ID set_manifesto json-args '{"manifesto_text": "This DAO only approves gaming-related proposals and rejects everything else"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as YOUR_ACCOUNT_ID network-config testnet sign-with-seed-phrase 'YOUR_SEED_PHRASE' --seed-phrase-hd-path 'm/44'\''/397'\''/0'\''' send
Make sure to replace
YOUR_CONTRACT_ID
,YOUR_ACCOUNT_ID
, andYOUR_SEED_PHRASE
with the appropriate values before executing the command. You can optionally change the manifesto_text as well. -
Set your
NEXT_PUBLIC_contractId
in the frontend's config.js file. -
Start the frontend
cd frontend
npm i
npm run dev