Environment Variables
Environment variables are a crucial component of the Shade Agent Framework. They configure your Shade Agent and are passed encrypted into your agent when it goes live. Note that the same agent code (same Docker Compose file) can use different environment variables in different deployments.
The environment variables file must be named .env.development.local
.
Required Variables
Below, we'll walk through each environment variable required by the Shade Agent Framework:
-
NEAR_ACCOUNT_ID
ExampleNEAR_ACCOUNT_ID=example-account.testnet
This is the NEAR account ID that is used to create the agent contract's account when running the Shade Agent CLI and to automatically fund the agent account during startup. You should ensure this account remains funded as you continue to deploy additional agents.
You can create a NEAR account by using the NEAR CLI.
Install the CLI:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
Create an account:
export ACCOUNT_ID=example-name.testnet
near account create-account sponsor-by-faucet-service $ACCOUNT_ID autogenerate-new-keypair save-to-keychain network-config testnet createReplace
example-name.testnet
with a unique account ID. -
NEAR_SEED_PHRASE
ExampleNEAR_SEED_PHRASE="book chapter unknown knife strange inherit amazing artist mixture loan rotate lyrics"
This is the seed phrase for the NEAR_ACCOUNT_ID. When creating an account with the above command the seed phrase will be printed to the terminal
-
NEXT_PUBLIC_contractId
ExamplesNEXT_PUBLIC_contractId=ac-proxy.example-account.testnet NEXT_PUBLIC_contractId=ac-sandbox.example-account.testnet
This is the NEAR account ID where the agent contract will be deployed when running the Shade Agent CLI. The account is automatically created when you run the Shade Agent CLI. This account must be your NEAR_ACCOUNT_ID prefixed with either
ac-proxy.
orac-sandbox.
, which determines whether the deployment is local or to a TEE, respectively. Forac-proxy.
deployments, the agent contract doesn't require agent registration since local environments cannot provide valid TEE attestation. -
API_CODEHASH
The API_CODEHASH defines the code hash of the Shade Agent API. You only need to update this when a new API version is released. The Quickstart Template always includes the most up-to-date API code hash.
-
APP_CODEHASH
The APP_CODEHASH defines the code hash of your agent. You don't need to edit this as it will be automatically updated when running the Shade Agent CLI in production.
-
DOCKER_TAG
ExampleDOCKER_TAG=username/my-app
The
Docker_TAG
specifies how to find your app image on Docker hub. You need to edit the Docker tag so that the first part matches your Docker username. You can set the second part to whatever you want your image to be called. When the CLI is ran the docker tag for your apps image in the docker-compose.yaml will be automatically updated. -
PHALA_API_KEY
ExamplePHALA_API_KEY=phak_tIhrDY0mXJMgmLLMEMoM6yBxOsjfVM-sTmXmjOF4Fks
The PHALA_API_KEY is used to upload your agent to Phala Cloud when running the Shade Agent CLI. You can get a key here.
Optional Environment Variables
-
API_PORT
ExampleAPI_PORT=4000
The API_PORT defines which port number the Shade Agent API port is exposed on. The API by default is hosted on port 3140.
Your Own Variables
You should also set any additional environment variables your agent may need in the .env.development.local
file. Remember to update your Docker Compose file to pass these additional variables to your agent.