This standalone CRE project implements a confidential pre-execution security firewall for smart contract interactions.
Description
The workflow screens proposed transactions before they are allowed to proceed. It fetches and validates contract intelligence, runs confidential reasoning to classify risk, and then enforces a firewall decision path. Scanner and model credentials remain protected inside confidential execution throughout the process.
Target Customer
- Professional retail traders
- Developer shops
- Founders building trading products
Structure
project.yaml: project-level target settingssecrets.yaml: secret ID mappings used by the workflowmock-server.js: local deterministic API serverai-audit-firewall-ts/: TypeScript workflow implementationai-audit-firewall-go/: Go workflow implementation
Private Inputs
The following inputs are handled as confidential:
- Chain scanner API credentials used for contract metadata retrieval and verification checks.
- LLM reasoning API credentials used for independent audit analysis.
Workflow Notes
- Monitor and ingest the proposed interaction. The workflow receives candidate transaction context, including token and protocol contract addresses.
- Fetch and validate contract data confidentially. It retrieves source and ABI artifacts through the scanner and verifies scanner credential permissions before trusting fetched data.
- Run smart contract audit analysis.
The workflow submits context to multiple reasoning models and classifies behavior into structured risk signals:
obfuscatedTaxprivilegeEscalationexternalCallRisklogicBomb
- Enforce firewall action and record outcomes. Based on aggregate risk, the workflow allows execution, blocks malicious interactions, or routes the attempt for manual review while preserving audit and action logs.
Note: Any reasoning stage can be replaced with deterministic rule-based logic if a purely policy-engine implementation is preferred.
Required Environment Variables
Copy .env.example to .env and provide values for:
CRE_ETH_PRIVATE_KEY(optional for local simulate, required for real chain writes)MOCK_PORTMOCK_SCANNER_API_KEYMOCK_PRIMARY_LLM_API_KEYMOCK_SECONDARY_LLM_API_KEY
The local mock server for this project only exposes routes under /audit-firewall/*.
Quick navigation:
TypeScript Quick Start
- Install dependencies
bun install
- Create environment file
cp .env.example .env
- Start mock server
bun run mock:server
- In another terminal, run checks
bun run typecheck
bun run test
- Simulate workflow
cre workflow simulate ./ai-audit-firewall-ts --target=staging-settings
Go Quick Start
- Create environment file (at the shared project root)
cp ../.env.example ../.env
- Start the mock server (requires Node or Bun)
bun mock-server.js
- In another terminal, run checks
go vet ./...
go test ./...
- Simulate workflow
cd .. && cre workflow simulate ./ai-audit-firewall-go --target=staging-settings
CREATED BY CHAINLINK LABS