# Estimate Program Invocation Compute Units Solana

This endpoint estimates the number of compute units an arbitrary Solana program invocation would consume. You provide the program to call, the base64-encoded instruction data, and the list of accounts the instruction references; the transaction is built and simulated against the node (without being broadcast) and the simulated compute units consumed are returned. This is the Solana analogue of estimating contract-interaction gas on EVM chains. Use it to size a ComputeBudget instruction before submitting the transaction.

- **Endpoint:** `POST https://rest.cryptoapis.io/blockchain-fees/solana/{network}/estimate-program-invocation-compute-units`
- **Authentication:** `x-api-key` header
- **Credits cost:** 120 credits for 1 result by default; per blockchain: Solana: 120
- **Documentation page:** https://developers.cryptoapis.io/v-2.2024-12-12-175/RESTapis/blockchain-fees-solana/estimate-program-invocation-compute-units-solana/post

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `network` | string | yes | Represents the name of the blockchain network used; blockchain networks are usually identical as technology and software, but they differ in data, e.g. - "mainnet" is the live network with actual data while a network like "devnet" is a test network. Allowed values: `mainnet`, `devnet`. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `context` | string | no | In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user. |

## Request body (application/json)

```json
{
  "context": "yourExampleString",
  "data": {
    "item": {
      "sender": "5snoUseZG8s8CDFHrXY2ZHaCrJYsW457piktDmhyb5Jd",
      "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      "instructionData": "AgAAAAQAAAA=",
      "accounts": [
        {
          "pubkey": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
          "isSigner": false,
          "isWritable": true
        }
      ]
    }
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `context` | string | no | In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user. |
| `data` | object | yes |  |
| `data.item` | object | yes |  |
| `data.item.sender` | string | yes | Base58 string representation of the fee payer pubkey (the account that pays for and signs the transaction). |
| `data.item.programId` | string | yes | Base58 string representation of the program pubkey to invoke (the on-chain program the instruction calls). |
| `data.item.instructionData` | string | yes | Base64-encoded instruction data bytes passed to the program. May be an empty string for instructions that take no data. |
| `data.item.accounts` | array of object | no | Array of the accounts referenced by the instruction (Solana AccountMeta entries), in the order the program expects them. May be empty. |
| `data.item.accounts[].pubkey` | string | yes | Base58 string representation of the account pubkey referenced by the instruction. |
| `data.item.accounts[].isSigner` | boolean | yes | Whether this account must sign the transaction. |
| `data.item.accounts[].isWritable` | boolean | yes | Whether the instruction may modify this account's data or lamports. |

## Responses

| Status | Description |
| --- | --- |
| 200 | The request has been successful. |
| 400 | 400 |
| 401 | 401 |
| 402 | 402 |
| 403 | 403 |
| 409 | The data provided seems to be invalid. |
| 415 | The selected Media Type is unavailable. The Content-Type header should be 'application/json'. |
| 422 | Your request body for POST requests must have a structure of { data: { item: [...properties] } } |
| 429 | The request limit has been reached. There can be maximum {requests} requests per {seconds} second(s) made. Please contact our team via email if you need more or upgrade your plan. |
| 500 | An unexpected server error has occurred, we are working to fix this. Please try again later and in case it occurs again please report it to our team via email. |

### Example 200 response

```json
{
  "apiVersion": "2024-12-12",
  "requestId": "601c1710034ed6d407996b30",
  "context": "yourExampleString",
  "data": {
    "item": {
      "computeUnits": 4645
    }
  }
}
```

### 200 response fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `apiVersion` | string | yes | Specifies the version of the API that incorporates this endpoint. |
| `requestId` | string | yes | Defines the ID of the request. The `requestId` is generated by Crypto APIs and it's unique for every request. |
| `context` | string | no | In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. `context` is specified by the user. |
| `data` | object | yes |  |
| `data.item` | object | yes |  |
| `data.item.computeUnits` | integer | yes | String-encoded integer of the simulated compute units the program invocation would consume. |
