Environment Variables
Environment variables are a crucial part of configuring your Envio indexer. They allow you to manage sensitive information and configuration settings without hardcoding them in your codebase.
Naming Convention
All environment variables used by Envio must be prefixed with ENVIO_
. This naming convention:
- Prevents conflicts with other environment variables
- Makes it clear which variables are used by the Envio indexer
- Ensures consistency across different environments
Envio API Token (required for HyperSync)
To ensure continued access to HyperSync, set an Envio API token in your environment.
- Use
ENVIO_API_TOKEN
to provide your token at runtime - See the API Tokens guide for how to generate a token: API Tokens
Envio-specific environment variables
The following variables are used by HyperIndex:
-
ENVIO_API_TOKEN
: API token for HyperSync access (required for continued access in self-hosted deployments) -
ENVIO_HASURA
: Set tofalse
to disable Hasura integration for self-hosted indexers -
ENVIO_PG_PORT
: Port for the Postgres service used by HyperIndex during local development -
ENVIO_PG_PASSWORD
: Postgres password (self-hosted) -
ENVIO_PG_USER
: Postgres username (self-hosted) -
ENVIO_PG_DATABASE
: Postgres database name (self-hosted) -
ENVIO_PG_PUBLIC_SCHEMA
: Postgres schema name override for the generated/public schema
Example Environment Variables
Here are some commonly used environment variables:
# Envio API Token (required for continued HyperSync access)
ENVIO_API_TOKEN=your-secret-token
# Blockchain RPC URL
ENVIO_RPC_URL=https://arbitrum.direct.dev/your-api-key
# Starting block number for indexing
ENVIO_START_BLOCK=12345678
# Coingecko API key
ENVIO_COINGECKO_API_KEY=api-key
Setting Environment Variables
Local Development
For local development, you can set environment variables in several ways:
- Using a
.env
file in your project root:
# .env
ENVIO_API_TOKEN=your-secret-token
ENVIO_RPC_URL=https://arbitrum.direct.dev/your-api-key
ENVIO_START_BLOCK=12345678
- Directly in your terminal:
export ENVIO_API_TOKEN=your-secret-token
export ENVIO_RPC_URL=https://arbitrum.direct.dev/your-api-key
Hosted Service
When using the Envio Hosted Service, you can configure environment variables through the Envio platform's dashboard. Remember that all variables must still be prefixed with ENVIO_
.
For more information about environment variables in the hosted service, see the Hosted Service documentation.
Configuration File
For use of environment variables in your configuration file, read the docs here: Configuration File.
Best Practices
- Never commit sensitive values: Always use environment variables for sensitive information like API keys and database credentials
- Never commit or use private keys: Never commit or use private keys in your codebase
- Use descriptive names: Make your environment variable names clear and descriptive
- Document your variables: Keep a list of required environment variables in your project's README
- Use different values: Use different environment variables for development, staging, and production environments
- Validate required variables: Check that all required environment variables are set before starting your indexer
Troubleshooting
If you encounter issues with environment variables:
- Verify that all required variables are set
- Check that variables are prefixed with
ENVIO_
- Ensure there are no typos in variable names
- Confirm that the values are correctly formatted
For more help, see our Troubleshooting Guide.