# Smart Contract Proxy, Upgradeability & DeFi Risk Auditor (`trustlens_labs/smart-contract-proxy-risk-auditor`) Actor

Audit EVM smart contracts across 7 chains (Ethereum, Base, Arbitrum, Optimism, Polygon, BSC, Avalanche): detect EIP-1967/1167 proxies, resolve Gnosis Safe & Timelock admins, Sourcify verification, privileged ABI functions, opcode risks, and Upgrade Diff Alerts.

- **URL**: https://apify.com/trustlens_labs/smart-contract-proxy-risk-auditor.md
- **Developed by:** [TrustLens Labs](https://apify.com/trustlens_labs) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 evm smart contract proxy & risk audits

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## ChainLens — Multi-Chain Smart Contract Proxy, Upgradeability & DeFi Risk Auditor

> **Inspect any EVM smart contract across 7 chains in under 2 seconds: detect upgradeable proxies, resolve Gnosis Safe & Timelock admins, verify source on Sourcify v2, flag privileged ABI permissions, scan bytecode opcodes, and monitor live upgrades.**

Built by **TrustLens Labs**. Pure batched JSON-RPC + open Sourcify v2 & DefiLlama APIs — **zero API keys required**, **zero headless browsers**, ~128 MB RAM.

***

### Supported EVM Chains (7)

`ethereum` (1) · `base` (8453) · `arbitrum` (42161) · `optimism` (10) · `polygon` (137) · `bsc` (56) · `avalanche` (43114)

***

### What It Audits

1. **Multi-Standard Proxy & Implementation Detection**
   - Reads **EIP-1967** (`implementation`, `admin`, `beacon`), **OpenZeppelin legacy** (`org.zeppelinos.proxy.*`), **EIP-1822 UUPS** (`PROXIABLE`), Beacon `implementation()`, and **EIP-1167 Minimal Proxy Clone** bytecode.
2. **Deep Admin & Governance Classification**
   - Automatically distinguishes **`none_immutable`**, **`renounced`** (`0x0` / `0xdead`), **`eoa`** (critical single-key risk), **`gnosis_safe_multisig`** (extracts live `M-of-N` signer threshold and owner list), **`timelock`** (extracts `getMinDelay()` / `delay()` in seconds & hours), and smart contract controllers.
   - Automatically traverses **`ProxyAdmin -> owner()`** to uncover who truly controls upgrade authority!
3. **Sourcify v2 Source Verification & Privileged ABI Scanner**
   - Verifies implementation & proxy contracts via Sourcify v2 (`exact_match` / `match`), extracts compiler metadata, and scans non-view ABI functions for high-impact powers (`upgradeTo`, `mint`, `configureMinter`, `pause`, `blacklist`, `freeze`, `sweep`, `emergencyWithdraw`, `setFee`, `transferOwnership`).
4. **Defensive Bytecode Opcode Scanner**
   - Parses EVM bytecode while accurately skipping `PUSH1`–`PUSH32` immediates and Solidity CBOR metadata tails to flag `SELFDESTRUCT (0xFF)`, `DELEGATECALL (0xF4)`, and `CREATE2 (0xF5)` without false positives.
5. **Deterministic 0–100 Security & Decentralization Grade (`A+` to `F`) + Upgrade Diff Alerts**
   - Optional **Upgrade Diff Mode** compares against saved baselines and emits **`CRITICAL`** alerts whenever a proxy's implementation address or admin changes, plus **`HIGH`** alerts for Safe threshold changes, Timelock delay edits, or `paused()` flips.

***

### Use Cases

- **DeFi Risk Teams, Funds & Treasuries:** Monitor 100+ held protocol contracts hourly or daily for silent proxy upgrades or admin handoffs.
- **AI Trading & Wallet Safety Agents (via Apify MCP):** Pre-flight check any EVM token or DeFi vault before executing swaps or deposits.
- **Security Researchers & Auditors:** Triage protocol upgrade surfaces, multisig thresholds, and privileged ABI footprints across 7 chains in seconds.

***

### Transparent Pay-Per-Event Pricing

- **`contract-audit` ($0.02 / contract):** Charged only per successfully audited smart contract (never charged on invalid addresses or RPC failures).
- **`protocol-intel` ($0.01 / lookup):** Charged only when `protocolSlug` is provided and live DefiLlama TVL & audit data is enriched.

# Actor input Schema

## `contracts` (type: `array`):

List of EVM contracts formatted as 'chain:0xAddress' (e.g. 'ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 'base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913') or bare '0xAddress' using Default Chain.

## `defaultChain` (type: `string`):

Chain used when a contract entry omits the 'chain:' prefix.

## `includeSourcifyVerification` (type: `boolean`):

Query Sourcify v2 for contract verification status, compiler info, and privileged owner/admin ABI functions (mint, pause, upgradeTo, blacklist, setFee, withdraw).

## `protocolSlug` (type: `string`):

Optional DefiLlama slug (e.g. 'aave', 'uniswap', 'lido', 'compound') to attach live TVL, category, and audit links to the report.

## `enableUpgradeDiffMonitoring` (type: `boolean`):

Persist contract state baselines in a named Apify Key-Value Store and emit CRITICAL/HIGH alerts whenever implementation address, proxy admin, Safe threshold, Timelock delay, or paused state changes.

## `diffStoreName` (type: `string`):

Apify Key-Value Store name storing previous contract baselines when Upgrade Diff Mode is enabled.

## `concurrency` (type: `integer`):

Number of smart contracts audited in parallel (1-8).

## `timeoutMs` (type: `integer`):

Timeout in milliseconds for each public RPC and Sourcify HTTP request (3000-20000).

## Actor input object example

```json
{
  "contracts": [
    "ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  ],
  "defaultChain": "ethereum",
  "includeSourcifyVerification": true,
  "protocolSlug": "",
  "enableUpgradeDiffMonitoring": false,
  "diffStoreName": "chainlens-baselines",
  "concurrency": 3,
  "timeoutMs": 8000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "contracts": [
        "ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("trustlens_labs/smart-contract-proxy-risk-auditor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "contracts": [
        "ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("trustlens_labs/smart-contract-proxy-risk-auditor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "contracts": [
    "ethereum:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "base:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  ]
}' |
apify call trustlens_labs/smart-contract-proxy-risk-auditor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,trustlens_labs/smart-contract-proxy-risk-auditor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/enSEFhD3BEarT2IAq/builds/S8RAhmpDzTGbBP3ag/openapi.json
