- Install Rust
- Setup Rust:
rustup override set stable && rustup update
Ensure rust was installed correctly by running the following from the root project directory:
cargo test
cargo build
cargo run
The API runs on http://localhost:8080
and provides the following endpoints:
- Endpoint:
/compile
- Method: POST
- Content-Type: application/json
- Request Body:
{
"code": "YOUR_CAIRO_CODE",
"file_name": "YOUR_CAIRO_FILE_NAME"
}
- Response: JSON object with compilation results
{
"cairo_sierra": {
"contract": ...,
"program": {...},
"sierra_cairo_info_mapping": {...}
},
"casm_sierra": {
"casm_sierra_mapping_instruction": {
"casm_instructions": [...],
"casm_sierra_mapping": {...}
},
"casm": ...
}
}
- Endpoint:
/compile_contract
- Method: POST
- Content-Type: application/json
- Request Body:
{
"code": "YOUR_CAIRO_CODE",
"file_name": "YOUR_CAIRO_FILE_NAME"
}
- Response: JSON object with compilation results
{
"cairo_sierra": {
"contract": ...,
"sierra_contract_class": {...},
"sierra_cairo_info_mapping": {...}
},
"casm_sierra": {
"casm_sierra_mapping_instruction": {
"casm_instructions": [...],
"casm_sierra_mapping": {...}
},
"casm_contract_class": {...}
}
}
This returns the execution trace of a given transaction. NOTE: Current implementation only works for failing transactions.
- Endpoint:
/trace_error
- Method: POST
- Content-Type: application/json
- Request Body:
{
"args": ["arg1", "arg2"],
"casm_contract_class": "Serialized CasmContractClass JSON string",
"entrypoint_offset": 0
}
- Response: JSON object with execution trace
{
"retdata": ...,
"trace": [{
"pc": ...,
"ap": ...,
"fp": ...
},
...],
}