Environment Variables
You can pass encrypted environment variables to your Acurast deployments. They are encrypted at deployment time and only decrypted when the code runs on a processor. Useful for API keys and other secrets.
Setup
1. Add variables to your local .env file:
API_KEY=your-api-key
2. Reference them in acurast.json:
{
"projects": {
"my-project": {
"includeEnvironmentVariables": ["API_KEY"]
}
}
}
See the Deployment Config reference for all config fields.
3. Access them in your deployment code:
On acurast deploy, the listed variables are encrypted and attached to the deployment automatically. How you access them in your code depends on the runtime environment:
Node.js Runtime Environment
const API_KEY = _STD_.env.API_KEY;
Cargo Runtime Environment
In the Cargo runtime, environment variables are available as standard system environment variables on the deployment's distro image. For example, in Node.js:
const API_KEY = process.env.API_KEY;
Rotating variables between executions
For interval-based deployments with multiple executions, you can update environment variables between runs. Edit .env and then:
acurast deployments <id> --update-env-vars
This is useful for rotating API keys on a schedule without redeploying the script.
Programmatic access (SDK)
When using the SDK, the same workflow is available via setEnvVars and JobEnvironmentService from @acurast/sdk/chain.
See also
- Node.js Runtime Environment - the full
_STD_API available to Node.js scripts - Cargo Runtime Environment - the RPC API available to Cargo deployments
- CLI reference