Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nethermindeth/starknet-simulator
https://github.com/nethermindeth/starknet-simulator
nubia
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nethermindeth/starknet-simulator
- Owner: NethermindEth
- License: apache-2.0
- Created: 2024-04-23T16:30:52.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-14T11:22:44.000Z (3 months ago)
- Last Synced: 2024-11-24T20:36:43.592Z (about 1 month ago)
- Topics: nubia
- Language: Cairo
- Size: 224 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Starknet Transaction Simulator API
## Getting Started
### Prerequisites
- Install [Rust](https://www.rust-lang.org/tools/install)
- Setup Rust:```bash
rustup override set stable && rustup update
```Ensure rust was installed correctly by running the following from the root project directory:
```bash
cargo test
```### Running the project
```bash
cargo build
cargo run
```## API Usage Guide
The API runs on `http://localhost:8080` and provides the following endpoints:
### 1. Compile Cairo Code
- **Endpoint:** `/compile`
- **Method:** POST
- **Content-Type:** application/json
- **Request Body:**```json
{
"code": "YOUR_CAIRO_CODE",
"file_name": "YOUR_CAIRO_FILE_NAME"
}
```- **Response:** JSON object with compilation results
```json
{
"cairo_sierra": {
"contract": ...,
"program": {...},
"sierra_cairo_info_mapping": {...}
},
"casm_sierra": {
"casm_sierra_mapping_instruction": {
"casm_instructions": [...],
"casm_sierra_mapping": {...}
},
"casm": ...
}
}
```### 2. Compile Cairo Contract
- **Endpoint:** `/compile_contract`
- **Method:** POST
- **Content-Type:** application/json
- **Request Body:**```json
{
"code": "YOUR_CAIRO_CODE",
"file_name": "YOUR_CAIRO_FILE_NAME"
}
```- **Response:** JSON object with compilation results
```json
{
"cairo_sierra": {
"contract": ...,
"sierra_contract_class": {...},
"sierra_cairo_info_mapping": {...}
},
"casm_sierra": {
"casm_sierra_mapping_instruction": {
"casm_instructions": [...],
"casm_sierra_mapping": {...}
},
"casm_contract_class": {...}
}
}
```### 3. Trace Error
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:**```json
{
"args": ["arg1", "arg2"],
"casm_contract_class": "Serialized CasmContractClass JSON string",
"entrypoint_offset": 0
}
```- **Response:** JSON object with execution trace
```json
{
"retdata": ...,
"trace": [{
"pc": ...,
"ap": ...,
"fp": ...
},
...],
}
```