A Go-based RPC hook service that intercepts Ethereum transactions, performs trace analysis, and screens them through the Forta Firewall API before forwarding to the sequencer.
This service acts as a middleware between Ethereum clients and the sequencer, providing an additional layer of security by:
- Intercepting
eth_sendRawTransactionRPC calls - Performing transaction trace analysis
- Screening transactions through the Forta Firewall API
- Forwarding approved transactions to the sequencer
The service is configured through environment variables or a .env file. The following configuration options are available:
| Variable | Description | Required | Default |
|---|---|---|---|
PORT |
Port to listen on | No | 8080 |
SEQUENCER_RPC_URL |
URL of the sequencer RPC endpoint | Yes | - |
TRACE_RPC_URL |
URL of the RPC endpoint for trace calls | No | Uses SEQUENCER_RPC_URL |
FIREWALL_API_URL |
URL of the Forta Firewall API | Yes | - |
TIMEOUT |
Request timeout duration | No | 30s |
LOG_LEVEL |
Logging level (debug, info, warn, error) | No | info |
- Create a
.envfile with your configuration:
PORT=8080
SEQUENCER_RPC_URL=https://your-sequencer-url
TRACE_RPC_URL=https://your-trace-url
FIREWALL_API_URL=https://your-fortafirewall-url
TIMEOUT=30s
LOG_LEVEL=info- Build and run the service:
go run main.go- The service will start listening on the configured port and begin intercepting RPC calls.
-
When an
eth_sendRawTransactionRPC call is received:- The transaction is decoded and validated
- A trace analysis is performed using
debug_traceCall - The transaction and trace data are sent to the Forta Firewall API for screening
-
If the Firewall API approves the transaction:
- The original RPC call is forwarded to the sequencer
- The sequencer's response is returned to the client
-
If the Firewall API rejects the transaction:
- The transaction is blocked
- A 403 Forbidden response is returned to the client
-
For all other RPC methods:
- The request is forwarded directly to the sequencer
- The sequencer's response is returned to the client