Configuration
Complete reference for the railguard.toml configuration file.
Railguard is configured via a TOML file, typically named railguard.toml. The file supports environment variable expansion using ${VAR_NAME} syntax.
Full Example
Server Configuration
| Field | Type | Default | Description |
|---|---|---|---|
port | u16 | 8545 | Port for the local proxy server |
max_request_size | usize | 1048576 | Maximum JSON-RPC request size in bytes |
request_timeout_ms | u64 | 30000 | Timeout for upstream requests |
Upstream Configuration
| Field | Type | Required | Description |
|---|---|---|---|
url | String | Yes | Upstream RPC endpoint URL |
Environment Variable Expansion
Use ${VAR_NAME} to inject environment variables:
Firewall Configuration
| Field | Type | Default | Description |
|---|---|---|---|
mode | String | "strict" | "strict" blocks violations, "monitor" logs only |
fail_on_decode_error | bool | true | Block if ABI decoding fails (fail closed) |
Modes
strict— Block transactions that violate policy (default)monitor— Log violations but allow transactions through
Monitor mode is useful for:
- Testing your policy before enforcing
- Auditing transaction patterns
- Gradual rollout
Global Limits
| Field | Type | Description |
|---|---|---|
max_value | U256 | Maximum ETH value per transaction (in wei) |
max_gas_price | U256 | Max gas price for legacy transactions |
max_fee_per_gas | U256 | Max fee per gas for EIP-1559 transactions |
max_priority_fee_per_gas | U256 | Max priority fee for EIP-1559 transactions |
All values are strings representing U256 integers. Use quotes: "10000000000000000000".
Contract Rules
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Human-readable rule name |
contract | Address | Yes | Contract address (checksummed) |
allow_methods | String[] | Yes | Allowed function signatures |
arg_constraints | ArgConstraint[] | No | Argument value limits |
Method Signatures
Specify methods in canonical Solidity format:
Important:
- No spaces after commas
- No parameter names
- Use canonical types (
uint256notuint)
Railguard pre-computes the 4-byte selector at startup for fast matching.
Argument Constraints
Limit numeric argument values:
| Field | Type | Description |
|---|---|---|
index | usize | Zero-based argument index |
max | U256 | Maximum allowed value |
Arguments are decoded using ABI encoding rules. Only uint types are currently supported for constraints.
Contract Creation
To allow contract creation (transactions with no to address):
Setting contract to the zero address matches transactions with no destination.
ETH Transfers
Simple ETH transfers (no calldata) are checked against the destination allowlist. If the to address matches any rule's contract, the transfer is allowed.
Multiple Rules
Rules are evaluated in order. A transaction must match at least one rule to be allowed:
CLI Override
Override config file values via CLI:
Next Steps
- Policy Engine — How inspection works under the hood
- CLI Reference — All command-line options