midnight-compile-contract
Compile Compact contract code to validate syntax and semantics using a hosted compiler. Returns compiler errors or falls back to static analysis for reliability.
Instructions
🔧 REAL COMPILATION - Compile Compact code using the hosted compiler service.
Unlike static analysis tools, this ACTUALLY COMPILES the contract and returns real compiler errors.
Use this to: • Validate that generated code compiles before showing to users • Get actual compiler error messages with line numbers • Check if a contract is syntactically and semantically correct
Options: • skipZk=true (default): Fast syntax validation only (~1-2s) • fullCompile=true: Full compilation with ZK circuit generation (~10-30s)
FALLBACK BEHAVIOR: • If the compiler service is unavailable, automatically falls back to static analysis • Check 'validationType' in response: 'compiler' = real compilation, 'static-analysis-fallback' = fallback mode • Fallback provides structure/security analysis but may miss semantic errors
USAGE GUIDANCE: • Call after generating or modifying Compact code • Use skipZk=true for quick validation during development • Use fullCompile=true for final validation before deployment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Compact contract source code to compile | |
| skipZk | No | Skip ZK circuit generation for faster syntax-only validation (default: true) | |
| fullCompile | No | Perform full compilation including ZK generation (slower but complete) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | Yes | Whether compilation/validation succeeded | |
| message | Yes | Human-readable status message | |
| validationType | Yes | Type of validation performed - compiler (real) or static-analysis-fallback (when service unavailable) | |
| compilerVersion | No | Version of the Compact compiler used (if available) | |
| compilationMode | No | Type of compilation performed | |
| output | No | ||
| warnings | No | Compiler warnings or fallback warnings | |
| error | No | Error code if compilation failed | |
| location | No | Location of error if applicable | |
| hint | No | Helpful hint for resolving the issue | |
| serviceUrl | No | URL of the compiler service used | |
| serviceAvailable | No | Whether the compiler service is available | |
| fallbackReason | No | Reason for falling back to static analysis (if applicable) | |
| staticAnalysis | No | Static analysis results (only present when using fallback) |