GET /contract/{contract_address}
This endpoint retrieves a SmartMuv analysis summary for a specified smart contract. If the analysis is already present in the database, it is fetched and returned. Otherwise, the input is validated, and a new analysis task is provided.
Status of the contract then can be checked by querying again.
(Optional) The task status can also be tracked using the returned task ID using get task status.
GET
Parameter | Type | Required | Description |
---|---|---|---|
contract_address |
string |
Yes | The smart contract's address to analyze. Must be a valid Ethereum address. |
If the contract analysis is already present in the database or the analysis is successfully completed, the response contains a summary of the contract analysis.
- Status Code:
200 OK
- Format:
application/json
- Sample:
{
"success": true,
"status": "ok",
"message": "ok",
"data": {
"total_mapping": 0,
"total_variables": 0,
"total_key_sources": 0,
"complexity_score": 6.1875
}
}
Field | Type | Description |
---|---|---|
total_mapping |
integer |
Total number of mappings in the contract. |
total_variables |
integer |
Total number of variables in the contract. |
total_key_sources |
integer |
Total number of mapping variable's key sources in the contract. |
complexity_score |
float |
Calculated complexity score of the contract. |
-
Task Created for Analysis
-
Status Code:
202 Accepted
-
Sample:
{ "success": true, "status": "accepted", "message": "Task is being processed. Please check later for results.", "task_id": "abc12345" }
-
-
Task is in Queue
- Status Code:
202 OK
- Format:
application/json
- Sample:
{
"success": true,
"status": "queued",
"message": "Task is already queued and being processed.",
}
-
Invalid Contract Address
-
Status Code:
400 Bad Request
-
Sample:
{ "success": false, "status": "error", "message": "Invalid contract address format. A contract address must be 42 characters long, start with '0x', and contain only hexadecimal characters." }
-
-
Internal Server Error
-
Status Code:
500 Internal Server Error
-
Sample:
{ "success": false, "status": "error", "message": "An error occurred during contract analysis. Please try again later." }
-
- The complexity score is computed based on predefined metrics of the contract's structure and behavior.
- Results may take additional time to process if not already in the database.
GET /task_status/{task-id}
This endpoint retrieves the status of a task created for contract analysis. If the task is completed, it provides the analysis results.
GET
Parameter | Type | Required | Description |
---|---|---|---|
task_id |
string |
Yes | The unique identifier of the task. |
-
Task in Progress
-
Status Code:
200 OK
-
Format:
application/json
-
Sample:
{ "success": true, "status": "Processing", "message": "Task is still being processed.", "task_id": "abc12345" }
-
-
Task Completed Successfully
-
Status Code:
200 OK
-
Format:
application/json
-
Sample:
{ "success": true, "status": "Completed", "message": "Task completed successfully.", "data": { "total_mapping": 0, "total_variables": 0, "total_key_sources": 0, "complexity_score": 6.1875 } }
-
-
Task Failed
-
Status Code:
404 OK
-
Format:
application/json
-
Sample:
{ "success": false, "status": "Results Not Found", "message": "No results found for the provided contract address." }
-
-
Internal Server Error
-
Status Code:
500 Internal Server Error
-
Sample:
{ "success": false, "status": "Error", "message": "An unexpected error occurred. Please try again later." }
-
- This endpoint is designed to handle asynchronous tasks in a scalable manner.
- The
task_id
is required to identify and track the status of specific tasks. - If
"status": "Completed"
, the returned data structure is the same as the one for/contract/{contract_address}
.