Skip to main content

Output Formats

The Tenderly CLI supports two output modes: text (human-readable) and json (machine-readable). You can switch between them using the --output flag.

Text Output (Default)

Text output is designed for human readability with colors, formatting, and helpful messages.

Usage

tenderly [command]
# or explicitly
tenderly --output text [command]

Features

Colorized Output

Text mode includes color-coded messages:
  • Green - Success messages and important values
  • Red - Error messages and warnings
  • Yellow - Informational messages
  • Blue - Highlights and context

Progress Indicators

Visual feedback for long-running operations:
  • Spinner animations during uploads
  • Status messages for multi-step processes
  • Progress updates for large operations

Formatted Tables

Structured data presented in readable tables and lists

Examples

$ tenderly login --authentication-method email

Select authentication method:
 Email
  Access key can be generated at https://dashboard.tenderly.co/account/authorization

Enter your email: [email protected]
Password: ********

 Successfully logged in
$ tenderly whoami

ID: abc123def456
Email: [email protected]
Username: myusername
$ tenderly contracts push

Setting up your project...
Analyzing Hardhat configuration...

We have detected the following Smart Contracts:
 Token
 Marketplace
 NFT

 Uploading contracts...

Successfully pushed Smart Contracts for project my-project.
You can view your contracts at https://dashboard.tenderly.co/username/my-project/contracts
$ tenderly actions deploy

Building actions:
- tokenMonitor
- priceAlert

Validating triggers configuration...
Installing dependencies...
Building actions...
Validating actions...

Publishing and deploying actions:
- tokenMonitor
- priceAlert

 Deploying...

Published and deployed actions:
- tokenMonitor (actionId = act_123, versionId = ver_456) https://dashboard.tenderly.co/my-project/action/act_123
- priceAlert (actionId = act_789, versionId = ver_012) https://dashboard.tenderly.co/my-project/action/act_789
$ tenderly contracts push

Error: You need to initiate the project first.

You can do this by using the tenderly init command.

JSON Output

JSON output is designed for programmatic consumption, scripting, and automation.

Usage

tenderly --output json [command]

Features

Structured Data

All output is valid JSON that can be parsed by tools like jq, programming languages, or other CLI tools

Machine Readable

No colors, spinners, or formatting characters - just pure JSON data

Consistent Format

Predictable structure across all commands makes automation reliable

Examples

$ tenderly --output json whoami
{
  "id": "abc123def456",
  "email": "[email protected]",
  "username": "myusername",
  "type": "user"
}
For Organizations:
{
  "id": "org_abc123",
  "organization_name": "My Company",
  "username": "my-company",
  "type": "organization"
}
$ tenderly --output json version
{
  "version": "v2.5.0",
  "build_date": "2024-03-10",
  "commit": "a1b2c3d4"
}
$ tenderly --output json contracts push
{
  "error": {
    "message": "Project not initialized",
    "code": "PROJECT_NOT_INIT",
    "suggestion": "Run 'tenderly init' to initialize the project"
  }
}

Parsing JSON Output

JSON output is particularly useful for automation and scripting.

Using jq

jq is a powerful JSON processor for the command line.
# Get just the user ID
USER_ID=$(tenderly --output json whoami | jq -r '.id')
echo $USER_ID

Using Python

import json
import subprocess

# Run command and capture output
result = subprocess.run(
    ['tenderly', '--output', 'json', 'whoami'],
    capture_output=True,
    text=True
)

# Parse JSON
data = json.loads(result.stdout)

# Access fields
user_id = data['id']
username = data['username']
email = data.get('email', 'N/A')

print(f"User: {username} ({email})")
print(f"ID: {user_id}")

Using Node.js

const { execSync } = require('child_process');

// Run command and capture output
const output = execSync('tenderly --output json whoami', { 
  encoding: 'utf-8' 
});

// Parse JSON
const data = JSON.parse(output);

// Access fields
console.log(`User: ${data.username}`);
console.log(`ID: ${data.id}`);
if (data.email) {
  console.log(`Email: ${data.email}`);
}

Using Shell Scripts

#!/bin/bash

# Get user info
USER_JSON=$(tenderly --output json whoami)

# Parse with jq
USER_ID=$(echo $USER_JSON | jq -r '.id')
USERNAME=$(echo $USER_JSON | jq -r '.username')
USER_TYPE=$(echo $USER_JSON | jq -r '.type')

# Use the data
if [ "$USER_TYPE" = "organization" ]; then
  ORG_NAME=$(echo $USER_JSON | jq -r '.organization_name')
  echo "Logged in as organization: $ORG_NAME"
else
  EMAIL=$(echo $USER_JSON | jq -r '.email')
  echo "Logged in as user: $EMAIL"
fi

echo "Username: $USERNAME"
echo "ID: $USER_ID"

Logging and Debug Output

The --debug flag enables verbose logging regardless of output mode.

Debug Mode

tenderly --debug [command]
# or with JSON output
tenderly --debug --output json [command]

What Debug Mode Shows

Details about HTTP requests made to Tenderly API:
  • Request method and URL
  • Request headers
  • Request body
  • Response status
  • Response body
Information about file system operations:
  • Files being read
  • Directories being scanned
  • Build artifacts being processed
  • Config files being loaded
Internal processing details:
  • Contract compilation detection
  • Network resolution
  • Action function resolution
  • Validation steps

Debug Output Example

$ tenderly --debug contracts push

[DEBUG] Reading config from: /home/user/project/tenderly.yaml
[DEBUG] Project config: {"project_slug":"my-project","account_id":"user123"}
[DEBUG] Detecting provider...
[DEBUG] Found Hardhat config at: /home/user/project/hardhat.config.js
[DEBUG] Build directory: /home/user/project/artifacts
[DEBUG] Reading contracts from build directory...
[DEBUG] Found 3 contracts
[DEBUG] API Request: POST https://api.tenderly.co/api/v1/account/user123/project/my-project/contracts
[DEBUG] Request body: {"contracts":[...],"config":{...}}
[DEBUG] Response status: 200
[DEBUG] Response body: {"contracts":[{"id":"cnt_123",...}]}

Successfully pushed Smart Contracts for project my-project.

CI/CD Integration

Combine output modes and logging for effective CI/CD pipelines.

GitHub Actions Example

name: Deploy Contracts

on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Install Tenderly CLI
        run: curl https://raw.githubusercontent.com/Tenderly/tenderly-cli/master/scripts/install-linux.sh | sh
      
      - name: Login to Tenderly
        run: |
          tenderly login \
            --authentication-method access-key \
            --access-key ${{ secrets.TENDERLY_ACCESS_KEY }} \
            --force
      
      - name: Push contracts
        run: tenderly contracts push

Script Example

#!/bin/bash
set -e

# Configuration
OUTPUT_MODE="json"
DEBUG_FLAG="--debug"

# Login
echo "Logging in..."
tenderly $DEBUG_FLAG login \
  --authentication-method access-key \
  --access-key "$TENDERLY_ACCESS_KEY" \
  --force

# Get user info
echo "Getting user info..."
USER_INFO=$(tenderly --output $OUTPUT_MODE whoami)
USERNAME=$(echo $USER_INFO | jq -r '.username')
echo "Logged in as: $USERNAME"

# Push contracts
echo "Pushing contracts..."
if tenderly $DEBUG_FLAG contracts push; then
  echo "✓ Contracts pushed successfully"
  exit 0
else
  echo "✗ Failed to push contracts"
  exit 1
fi

Best Practices

Choose the Right Mode

  • Text mode for interactive terminal use
  • JSON mode for scripts and automation
  • Debug mode for troubleshooting

Error Handling

Always check exit codes in scripts:
if ! tenderly contracts push; then
  echo "Push failed"
  exit 1
fi
The CLI returns:
  • 0 on success
  • 1 on error

Parse JSON Safely

When using JSON output:
  • Validate JSON before parsing
  • Check for error fields
  • Handle missing fields gracefully
  • Use proper JSON parsers (jq, json.parse, etc.)

Capture Debug Logs

In CI/CD, consider saving debug output:
tenderly --debug contracts push 2>&1 | tee deploy.log

Build docs developers (and LLMs) love