# starknet_getCompiledCasm

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://starknet-mainnet.g.alchemy.com/v2/{apiKey}

Get the Cairo assembly (CASM) compiled contract class for the given class hash

Reference: https://www.alchemy.com/docs/chains/starknet/starknet-api-endpoints/starknet-get-compiled-casm

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| class_hash | string | Yes | The Sierra class hash whose compiled CASM will be returned |

## Result

**result** (object): The compiled contract class in CASM format

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://starknet-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "starknet_getCompiledCasm",
  "params": [
    "string"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'starknet_getCompiledCasm', params: ['string']})
};

fetch('https://starknet-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://starknet-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "starknet_getCompiledCasm",
    "params": ["string"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://starknet-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"starknet_getCompiledCasm\",\n  \"params\": [\n    \"string\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://starknet-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"starknet_getCompiledCasm\",\n  \"params\": [\n    \"string\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://starknet-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"starknet_getCompiledCasm\",\n  \"params\": [\n    \"string\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: starknet_getCompiledCasm
description: Get the Cairo assembly (CASM) compiled contract class for the given class hash
paramStructure: by-name
params:
  - name: class_hash
    description: The Sierra class hash whose compiled CASM will be returned
    required: true
    schema:
      title: Field element
      description: A field element. Represented by at most 63 hex digits
      type: string
      pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
result:
  name: result
  description: The compiled contract class in CASM format
  schema:
    title: CASM compiled contract class
    type: object
    required:
      - sierra_program_hash
      - bytecode
      - entry_points_by_type
    properties:
      sierra_program_hash:
        title: Sierra program hash
        description: The hash of the Sierra program from which this CASM was compiled
        type: string
        pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
      bytecode:
        title: CASM bytecode
        description: CASM program bytecode encoded as field elements
        type: array
        items:
          title: Field element
          description: A field element. Represented by at most 63 hex digits
          type: string
          pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
      entry_points_by_type:
        title: Entry points by type
        type: object
        required:
          - EXTERNAL
          - L1_HANDLER
          - CONSTRUCTOR
        properties:
          EXTERNAL:
            type: array
            items:
              type: object
              required:
                - selector
                - offset
              properties:
                selector:
                  title: Field element
                  description: A field element. Represented by at most 63 hex digits
                  type: string
                  pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
                offset:
                  type: integer
                  minimum: 0
          L1_HANDLER:
            type: array
            items:
              type: object
              required:
                - selector
                - offset
              properties:
                selector:
                  title: Field element
                  description: A field element. Represented by at most 63 hex digits
                  type: string
                  pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
                offset:
                  type: integer
                  minimum: 0
          CONSTRUCTOR:
            type: array
            items:
              type: object
              required:
                - selector
                - offset
              properties:
                selector:
                  title: Field element
                  description: A field element. Represented by at most 63 hex digits
                  type: string
                  pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
                offset:
                  type: integer
                  minimum: 0
      compiler_version:
        title: Compiler version
        description: Version string of the Cairo compiler used to produce this CASM
        type: string
```
