# Starknet

### /getbalance

Get the balance or number of the given token in the requested public address.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/chain/getbalance`

#### Query Parameters

| Name                                      | Type   | Description                                                                          |
| ----------------------------------------- | ------ | ------------------------------------------------------------------------------------ |
| rpc                                       | String | Remote procedural call URL                                                           |
| chainId<mark style="color:red;">\*</mark> | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| chainSymbol                               | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| address<mark style="color:red;">\*</mark> | String | The public address to get the balance of.                                            |
| tokenAddress                              | String | The address of token to get the balance of.                                          |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/chain/getbalance/?address=0x002eb24d4fda7c0e4473c091da3bc0b2dfd1622d3d8334d0f5e921587aaeb01f&chainId=400
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "balance": "35689118110967661"
    }
}
```

{% endtab %}
{% endtabs %}

### /getblock

Get details of a block.

<mark style="color:blue;">`GET`</mark> `https://historicallp.api.expand.network/chain/getblock`

#### Query Parameters

| Name                                          | Type   | Description                                                                          |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------ |
| rpc                                           | String | Remote procedural call URL.                                                          |
| chainId<mark style="color:red;">\*</mark>     | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| chainSymbol                                   | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| blockNumber<mark style="color:red;">\*</mark> | String | The block number or block hash.                                                      |

{% tabs %}
{% tab title="Sample Request" %}

```
https://historicallp.api.expand.network/chain/getblock?chainId=400&blockNumber=164639
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "difficulty": null,
        "gasLimit": null,
        "gasUsed": null,
        "hash": "0x4ab1311e8211aac585ea106f54a38fda9d6d9f82df3c12d6768475bb47daa7a",
        "miner": null,
        "nonce": null,
        "number": "164639",
        "parentHash": "0x64ff22f43e22bee32e857b2dd59c389b6bd451cb53404b631602d2c8077cc03",
        "size": null,
        "timestamp": "1692600243",
        "totalDifficulty": null,
        "transactions": [
            {
                "calldata": [
                    "0x2",
                    "0x23c72abdf49dffc85ae3ede714f2168ad384cc67d08524732acea90df325",
                    "0x219209e083275171774dab1df80982e9df2096516f06319c5c6d71ae0a8480c",
                    "0x5d5495a5d59cdc0f45ca6dbefda525866910eb800530d47e75cc7a3b2becc87",
                    "0x64e5aa92"
                ],
                "max_fee": "0x29ceb1c7616e4",
                "nonce": "0x45",
                "sender_address": "0x5d5495a5d59cdc0f45ca6dbefda525866910eb800530d47e75cc7a3b2becc87",
                "signature": [
                    "0x65b5b3bf40d98a50c1c8419f731fc560ca91419e22cc817c79c581d6a8bd2a9",
                    "0x6a35a25f9e123029f8f8e235d9a1559dba46b358f71951615dda91de636cbc6"
                ],
                "transaction_hash": "0x5c750d63ca77fc87c8770e7c95d06feb6cf6518f2538804eb9d9328f71c2101",
                "type": "INVOKE",
                "version": "0x1"
            }            
        ],
        "transactionsRoot": null,
        "uncles": null
    }
}
```

{% endtab %}
{% endtabs %}

### /getstorage

Get data stored in the given slot.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/chain/getstorage`

#### Query Parameters

| Name                                      | Type   | Description                                                                          |
| ----------------------------------------- | ------ | ------------------------------------------------------------------------------------ |
| rpc                                       | String | Remote procedural call URL.                                                          |
| chainId<mark style="color:red;">\*</mark> | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| chainSymbol                               | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| address<mark style="color:red;">\*</mark> | String | Contract address whose storage is needed.                                            |
| index                                     | String | Slot index on the smart contract. By default,  it is taken as 0.                     |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/chain/getstorage?address=0x02d6150113d899d8c9de05990974c115dd532bc4dbc71bde85210410b9b30ae5&chainId=400
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "data": "0x0"
    }
}
```

{% endtab %}
{% endtabs %}

### /gettransaction

Get details of a transaction.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/chain/gettransaction`

#### Query Parameters

| Name                                              | Type   | Description                                                                          |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------ |
| rpc                                               | String | Remote procedural call URL.                                                          |
| chainId<mark style="color:red;">\*</mark>         | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| chainSymbol                                       | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| transactionHash<mark style="color:red;">\*</mark> | String | The transaction hash.                                                                |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/chain/gettransaction?transactionHash=0x03916ca8924008be74ccdaebf8214704ebec30b2ca433dd29a4a7ebe91ab9243&chainId=400
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "hash": "0x03916ca8924008be74ccdaebf8214704ebec30b2ca433dd29a4a7ebe91ab9243",
        "transactionStatus": "ACCEPTED_ON_L2",
        "blockNumber": 164636,
        "timestamp": null,
        "from": "0x7b1c654512354ef5447f8646ac20af60111f015612a57b1bfac21dee33b4907",
        "to": null,
        "value": null,
        "transactionFees": "182195480376306",
        "gas": "274000000000000",
        "gasPrice": null,
        "input": null,
        "nonce": "26",
        "network": null
    }
}
```

{% endtab %}
{% endtabs %}

### **/sendtransaction**

Send transaction on the chain.

<mark style="color:green;">`POST`</mark> `https://api.expand.network/chain/sendtransaction`

#### Request Body

| Name                                             | Type   | Description                                                                          |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------------------------ |
| rpc                                              | String | Remote procedural call URL.                                                          |
| chainId<mark style="color:red;">\*</mark>        | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| chainSymbol                                      | String | Refer to the [Chain ID ](https://docs.expand.network/ids/chain-ids)page for details. |
| rawTransaction<mark style="color:red;">\*</mark> | String | The encoded transaction, obtained from the signed transaction.                       |

{% tabs %}
{% tab title="Sample Request" %}

```json
{
    "chainId": "400",
    "rawTransaction": "eyJpbnZva2VfdHJhbnNhY3Rpb24iOnsic2VuZGVyX2FkZHJlc3MiOiIweDAyNzM1ZTYwZjAzNDZhODgyNzYzNjI5MDIyMGU5OTUxMTdjYzE0MjgwNTQzZDVjZDVjOGQ1NDRkNzMzNGJlZjgiLCJjYWxsZGF0YSI6WyIweDEiLCIweDQ5ZDM2NTcwZDRlNDZmNDhlOTk2NzRiZDNmY2M4NDY0NGRkZDZiOTZmN2M3NDFiMTU2MmI4MmY5ZTAwNGRjNyIsIjB4ODNhZmQzZjRjYWVkYzZlZWJmNDQyNDZmZTU0ZTM4Yzk1ZTMxNzlhNWVjOWVhODE3NDBlY2E1YjQ4MmQxMmUiLCIweDAiLCIweDMiLCIweDMiLCIweDQ3ZGU0YTBhNjg1NTdmMzhiNzU0ZTZkODc1YWNkNDk3MmNiZDJiMjIyZGU5YmEzMmY0Y2UwOTAyYTMwODlmZiIsIjB4MjA4NTcxIiwiMHgwIl0sInR5cGUiOiJJTlZPS0UiLCJtYXhfZmVlIjoiMHg1MWViODViOWFiNSIsInZlcnNpb24iOiIweDEiLCJzaWduYXR1cmUiOlsiMHg0NTc4MjhmYzU5NTBiY2NkNWYwMjhjNjU5ZjI0ODZlZWU0ZDZkMmQ5NDcxMGI0NTZhNjYyYzBkZGJmZjkwOWIiLCIweDk1NjQxMDYzMWM3ZGVkOWZmNTIwNGE3ODVhNWY0NjhiMDNjYTQ5YjU1ZTgxMzZiMGNkNDFhNmRkYjExNzdmIl0sIm5vbmNlIjoiMHgyYSJ9fQ=="
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "400",
        "transactionHash": "0x8375c5eedd17609292cecc051c18e180fa970b32a77011c48d3725e45e46e7b3" 
    }
}
```

{% endtab %}
{% endtabs %}
