Project Configuration
This page explains how to manage configuration within Chainlink Runtime Environment (CRE) projects. It covers the standard project structure, the roles and usage of the configuration files (project.yaml and workflow.yaml), and the concept of targets for handling environment-specific settings.
You will understand:
- The recommended directory structure for CRE projects and the significance of key files.
- How to define global settings in
project.yamland override them with workflow-specific settings inworkflow.yaml. - The purpose of targets and how they enable seamless switching between different operational environments.
- The process by which the CRE CLI resolves and merges target configurations.
1. Glossary
Term | Definition |
|---|---|
| Project | A folder that groups one or more workflows plus shared files such as project.yaml, .env, and .gitignore. |
| Workflow | A sub-folder that contains everything needed to run one workflow (code, dependencies, build artifacts, and the optional workflow.yaml). |
| Config | Any YAML file that lets you adjust how a workflow behaves (timeouts, trigger frequency, etc.). |
| Settings | Values that describe the runtime environment. Project settings live in project.yaml; workflow settings live in workflow.yaml. If both define the same key, the workflow value wins. |
| Target | A named set of settings (e.g. staging-settings, production-settings). Switching the target switches networks, RPC URLs, contract addresses, and other environment-specific values in one step. |
secrets.yaml | A project-level file that defines logical names for secrets and maps them to environment variables. |
| ABI | Application Binary Interface - describes a smart contract's functions, events, and data structures. In TypeScript, ABIs are defined directly as TypeScript files using viem. |
2. Project structure
A typical CRE TypeScript project is organized as follows:
myProject/
โโโ .env # Secret values (never commit to a Version Control System like Git)
โโโ .gitignore
โโโ project.yaml # Global configuration
โโโ secrets.yaml # Secret name declarations
โโโ contracts/ # Contract-related files
โ โโโ abi/ # TypeScript ABI definitions (.ts files)
โ โโโ MessageEmitter.ts
โ โโโ index.ts
โ โโโ โฆ
โโโ workflow1/
โ โโโ package.json # NPM dependencies for this workflow
โ โโโ tsconfig.json # TypeScript configuration
โ โโโ bun.lock # Dependency lock file
โ โโโ node_modules/ # Installed dependencies
โ โโโ workflow.yaml # Workflow-specific configuration (optional)
โ โโโ main.ts # Your workflow code
โ โโโ โฆ
โโโ workflow2/
โ โโโ package.json # NPM dependencies for this workflow
โ โโโ tsconfig.json # TypeScript configuration
โ โโโ bun.lock # Dependency lock file
โ โโโ node_modules/ # Installed dependencies
โ โโโ workflow.yaml # Workflow-specific configuration (optional)
โ โโโ main.ts # Your workflow code
โ โโโ โฆ
โโโ โฆ
project.yaml: Global settings, shared by every workflow in the project.workflow.yaml: Local settings for a single workflow. Add this file only when the workflow needs overrides.secrets.yaml: Secret declarations, a manifest of logical secret names used across the project.contracts/abi/: TypeScript ABI definitions, where you place.tsfiles that export contract ABIs using viem's type system. Unlike Go, TypeScript doesn't require generating bindingsโABIs are used directly with viem.package.json/tsconfig.json: Workflow-specific dependencies and TypeScript configuration. Each workflow manages its own dependencies independently.node_modules/: Installed dependencies for the workflow (generated bynpm installor similar).
3. Configuration files
3.1. Global configuration (project.yaml)
project.yaml holds everything that rarely changes across workflows, such as RPC endpoints.
# project.yaml
staging-settings:
rpcs:
- chain-name: ethereum-testnet-sepolia
url: https://ethereum-sepolia-rpc.publicnode.com
# You can define other targets for future use
production-settings:
account:
workflow-owner-address: "0x..." # Optional: For multi-sig wallets
rpcs:
- chain-name: ethereum-testnet-sepolia
url: https://ethereum-sepolia-rpc.publicnode.com
- chain-name: ethereum-mainnet
url: https://mainnet.infura.io/v3/<YOUR-PROJECT-ID>
Configuration fields
Field | Required | When to use | Description |
|---|---|---|---|
account.workflow-owner-address | No | Multi-sig only | Multi-sig wallet address that owns the workflow. Required when using the --unsigned flag to generate unsigned transactions. For standard (non-multi-sig) deployments, omit this fieldโthe CLI uses the address from CRE_ETH_PRIVATE_KEY. See Using Multi-sig Wallets. |
rpcs | Yes | Always (if using EVM) | Array of RPC endpoints for chains your workflow interacts with. Each entry requires chain-name (e.g., ethereum-mainnet) and url (the RPC endpoint). Required for both simulation and deployed workflows that use EVM capabilities. The CLI pre-populates a public Sepolia RPC URL by default. |
3.2. Workflow configuration (workflow.yaml)
workflow.yaml captures details unique to one workflow instance, like its name and entry point file.
# workflow.yaml
staging-settings:
user-workflow:
workflow-name: "my-por-workflow-staging"
workflow-artifacts:
workflow-path: "./main.ts" # Points to the TypeScript entry file
config-path: "./config.staging.json"
secrets-path: "" # Empty if not using secrets
production-settings:
user-workflow:
workflow-owner-address: "<address>" # Optional: For multi-sig wallets
workflow-name: "my-por-workflow-production"
workflow-artifacts:
workflow-path: "./main.ts" # Points to the TypeScript entry file
config-path: "./config.production.json"
secrets-path: "" # e.g. "../secrets.yaml" if using secrets
Configuration fields
Field | Required | Description |
|---|---|---|
user-workflow.workflow-name | Yes | The name of your workflow. This name is used to identify the workflow when deploying, activating, or managing it via CLI commands. Best practice: include environment suffix (e.g., -staging, -production). |
user-workflow.workflow-owner-address | No | Multi-sig wallet address (if applicable). Overrides the value from project.yaml for this specific workflow. See the project.yaml configuration table above for details. |
workflow-artifacts.workflow-path | Yes | Path to your workflow entry point. For TypeScript: "./main.ts" (or your entry file name). For Go: "." (current directory). |
workflow-artifacts.config-path | Yes | Path to your workflow configuration JSON file (e.g., "./config.staging.json" or "./config.production.json"). |
workflow-artifacts.secrets-path | No | Path to your secrets YAML file (e.g., "../secrets.yaml"). Use "" (empty string) if not using secrets. See Secrets Management for details. |
3.3. Secrets configuration (secrets.yaml)
secrets.yaml is an optional project-level file that maps logical secret names to environment variables. This allows you to decouple the secret names used in your code from the actual environment variable names.
# secrets.yaml (at project root)
secretsNames:
DATA_SOURCE_API_KEY:
- DATA_SOURCE_API_KEY_ENV
To use secrets in your workflow, reference this file in your workflow.yaml:
workflow-artifacts:
secrets-path: "../secrets.yaml"
For simulation, secret values are loaded from your .env file or environment variables. For deployed workflows, secrets are managed through the Vault DON using cre secrets commands.
For complete details on using secrets in your workflows, see Secrets Management.
4. Targets
A target is a top-level key inside both project.yaml and workflow.yaml. It bundles all settings for a single environment or variant.
The CLI selects the active target using the --target flag. Example:
# Simulate using the 'staging-settings' target
cre workflow simulate my-workflow --target staging-settings
Alternatively, the CRE_TARGET environment variable can be used to specify the target. The CLI picks the active target in this order:
--target <name>flagCRE_TARGET=<name>environment variable
4.1. Defining Multiple Targets
You can store many targets in one file. This is useful for managing different environments (like simulation vs. production) or for testing variations of a workflow.
# In project.yaml
# Target for simulation and testing
staging-settings:
rpcs:
- chain-name: ethereum-testnet-sepolia
url: https://ethereum-sepolia-rpc.publicnode.com
# Target for production deployment
production-settings:
account:
workflow-owner-address: "0x123..." # Optional: For multi-sig wallets
rpcs:
- chain-name: ethereum-mainnet
url: https://mainnet.infura.io/v3/<YOUR-PROJECT-ID>
4.2. How Target Resolution Works
When you run a CLI command with a target, e.g., --target staging-settings:
- Load the
staging-settingstarget fromproject.yaml. - Load the same target from
workflow.yaml(if the file exists and contains a matching target definition). - Merge the two objects.
- Keys present in both files โ value from
workflow.yamlwins. - Keys present in only one file โ that value is used.
- Keys present in both files โ value from
- Validate the final object before execution.