Skip to main content
The tenderly actions init command guides you through setting up a new Actions project. It creates the source directory structure, generates configuration files, and provides example code to get you started quickly.

Usage

tenderly actions init [flags]

What It Does

When you run tenderly actions init, the command:
1

Authenticates

Verifies you’re logged in to Tenderly
2

Selects Project

Prompts you to choose a project or uses the --project flag
3

Configures Language

Sets up TypeScript or JavaScript based on your preference
4

Creates Structure

Generates the source directory with example files
5

Installs Dependencies

Runs npm install for TypeScript projects
6

Updates Config

Adds Actions configuration to tenderly.yaml

Flags

--sources

--sources string    The path where the actions will be created
Specify a custom directory for your Actions source code. If not provided, the CLI will prompt you or use the default (actions/ or src/actions/). Example:
tenderly actions init --sources ./my-actions

--language

--language string    Initialize actions for this language (default "typescript")
Choose between TypeScript and JavaScript. Supported values:
  • typescript (default)
  • javascript
Example:
tenderly actions init --language javascript

--template

--template string    Initialize actions from this template
Bootstrap your project from a template in the Tenderly/tenderly-actions repository. This is useful for starting with pre-built examples. Example:
tenderly actions init --template basic-webhook

--project

--project string    The project slug in which the actions will be published & deployed
Specify the project without being prompted. Format: username/project-slug Example:
tenderly actions init --project myusername/my-project

Examples

Basic Initialization (TypeScript)

tenderly actions init
This will:
  1. Prompt you to select a project
  2. Prompt for the sources directory (default: actions/)
  3. Create TypeScript project structure
  4. Install dependencies

JavaScript Project

tenderly actions init --language javascript --sources ./src/actions
Creates a JavaScript-based Actions project in the ./src/actions directory.

Using a Template

tenderly actions init --template webhook-example --project myusername/my-project
Initializes from a template without prompts.

Generated Files

After running tenderly actions init for TypeScript, you’ll get:
actions/
├── example.ts          # Example action function
├── package.json        # Dependencies including @tenderly/actions
├── tsconfig.json       # TypeScript configuration
├── .gitignore          # Git ignore for node_modules and build output
└── node_modules/       # Installed dependencies

example.ts

import {
  ActionFn,
  Context,
  Event,
  BlockEvent,
} from '@tenderly/actions';

export const blockHelloWorldFn: ActionFn = async (context: Context, event: Event) => {
  let blockEvent = event as BlockEvent;
  console.log(blockEvent);
}

package.json

{
  "name": "actions",
  "version": "1.0.0",
  "dependencies": {
    "@tenderly/actions": "^0.2.0"
  },
  "scripts": {
    "build": "tsc"
  },
  "devDependencies": {
    "typescript": "^4.9.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "outDir": "./out",
    "rootDir": "./",
    "strict": true,
    "esModuleInterop": true
  }
}

.gitignore

# Dependency directories
node_modules/

# Ignore tsc output
out/**/*

Configuration in tenderly.yaml

The init command adds an Actions section to your tenderly.yaml:
actions:
  username/project-slug:
    runtime: v2
    sources: actions
    specs:
      example:
        description: "This is just an example, but you can publish this action."
        function: example:blockHelloWorldFn
        trigger:
          type: block
          block:
            network:
              - 1
            blocks: 10
        execution_type: parallel

Configuration Fields

  • runtime: Runtime version (v1 or v2). Defaults to v2.
  • sources: Directory containing your Action source files.
  • specs: Map of action names to their specifications.
    • description: Optional description of what the action does.
    • function: Function locator in format filename:functionName.
    • trigger: Trigger configuration (type and parameters).
    • execution_type: parallel or sequential.

Function Locator Format

The function field uses the format: filename:functionName
  • filename: Relative path to the file (without extension) from the sources directory
  • functionName: The exported function name
Examples:
function: example:blockHelloWorldFn        # File: example.ts/js
function: handlers/blocks:onNewBlock       # File: handlers/blocks.ts/js
function: utils/monitoring:checkBalance    # File: utils/monitoring.ts/js

TypeScript Configuration

For TypeScript projects, the tsconfig.json must have compilerOptions.outDir set. This tells the compiler where to output compiled JavaScript files.
The CLI automatically:
  1. Detects parent tsconfig.json files
  2. Excludes the Actions directory from parent compilation
  3. Creates an isolated TypeScript environment for Actions
This prevents conflicts with existing TypeScript projects.

Dependencies

@tenderly/actions

The TypeScript/JavaScript runtime requires the @tenderly/actions package (version ^0.2.0 or later).
npm install @tenderly/actions
This package provides:
  • Type definitions for ActionFn, Context, Event
  • Event types: BlockEvent, TransactionEvent, WebhookEvent, etc.
  • Helper utilities for working with blockchain data

Error Handling

Already Initialized

If you run init in a project that already has Actions configured:
Actions for project my-project are already initialized, see tenderly.yaml
Check your tenderly.yaml file to see the existing configuration.

Directory Exists

If the specified sources directory already exists:
Selected sources directory already exists.
Choose a different directory name or remove the existing one.

Language Not Supported

Language python not supported
Only typescript and javascript are supported values for the --language flag.

Next Steps

After initialization:
1

Customize Your Action

Edit the generated action files to implement your logic
2

Configure Triggers

Modify the trigger configuration in tenderly.yaml to match your needs
3

Build and Test

Run tenderly actions build to validate your code
4

Deploy

Use tenderly actions deploy to deploy your actions

See Also

Actions Overview

Learn about Web3 Actions concepts

Publish Command

Publish and deploy your Actions

Build docs developers (and LLMs) love