# StarkNet (STRK)

> GetBlock provides fast and reliable access to Starknet nodes via JSON-RPC API. Connect to the Starknet network without running your own infrastructure.

Starknet is a permissionless validity (ZK) rollup that settles to Ethereum, executing contracts on the Cairo VM and proving that execution with STARK proofs verified on Ethereum L1. It is not EVM-compatible: contracts are Cairo classes, values are felt252 field elements expressed as hex, and every account is itself a contract under Starknet's native account abstraction. Blocks are addressed by a `block_id` that is either an object (a block number or block hash) or a tag (`latest`, `pending`). The JSON-RPC surface is the standard `starknet_*` method set: block and state reads, transaction and receipt lookups, contract calls and class/storage reads, event queries, fee estimation, and the invoke/declare/deploy-account write methods.

### Key Features

* **Validity Rollup**: Execution is proven with STARK proofs and verified on Ethereum L1, inheriting L1 security
* **Cairo VM**: Contracts are Cairo classes compiled to Sierra, not EVM bytecode; values are felt252 field elements
* **Native Account Abstraction**: Every account is a contract; signature schemes and validation are programmable
* **block\_id Addressing**: Reads accept a block number, block hash, or the `latest` / `pending` tags
* **Dual Fee Tokens**: Fees are payable in ETH or STRK; fee amounts carry a unit (`WEI` or `FRI`)
* **Two-Stage Finality**: Transactions move from `ACCEPTED_ON_L2` to `ACCEPTED_ON_L1` once settled on Ethereum
* **Classes and Instances**: A class is declared once by hash, then deployed to many contract addresses

> **Info:** _TECHNICAL DISCLAIMER: AUTHORITATIVE JSON-RPC API SPECIFICATION._
> 
> _GetBlock's RPC API reference documentation is provided exclusively for informational purposes and to optimize the developer experience. The canonical and normative specification for the Starknet JSON-RPC interface is maintained and published by StarkWare and the Starknet community through the official documentation at_ [_docs.starknet.io_](https://docs.starknet.io/) _and the OpenRPC specification in the_ [_starknet-specs_](https://github.com/starkware-libs/starknet-specs) _repository. This resource constitutes the sole authoritative reference for the starknet\__ JSON-RPC methods.*

## Network Information

| Property | Value |
| --- | --- |
| Network Name | Starknet |
| Chain ID | 0x534e5f4d41494e (SN_MAIN) |
| Native Fee Tokens | ETH, STRK |
| Decimals | 18 |
| Virtual Machine | Cairo VM (felt252) |
| Settlement Layer | Ethereum L1 (STARK validity rollup) |
| Account Model | Native account abstraction |
| Finality | L1-backed after proof settlement |

## Base URL

#### Frankfurt, Germany

```bash
https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/
```

## Supported Networks

| Network | Chain ID | JSON-RPC | WSS | GraphQL | MEV protected (WebSocket) | MEV protected (JSON-RPC) | Frankfurt, Germany | New York, USA | Singapore, Singapore |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Mainnet | SN_MAIN | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |

## Quickstart

#### Javascript(Axios)

### Setup project

```bash
mkdir starknet-api-quickstart && cd starknet-api-quickstart && npm init --yes
```

### Install dependency

```bash
npm install axios
```

### Add code

#### index.js

```javascript
const axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
  jsonrpc: '2.0',
  method: 'starknet_blockNumber',
  params: [],
  id: 'getblock.io'
};

axios.post(url, payload, {
  headers: { 'Content-Type': 'application/json' }
})
.then(response => {
  console.log('Latest block:', response.data.result);
})
.catch(error => console.error(error));
```

### Run the script

```bash
node index.js
```

### Response

```bash
{
    "jsonrpc": "2.0",
    "result": 14293145,
    "id": "getblock.io"
}
```

#### Python(Request)

### Setup project

```bash
mkdir starknet-api-quickstart && cd starknet-api-quickstart
python -m venv venv && source venv/bin/activate
```

### Install dependency

```bash
pip install requests
```

### Add code

#### main.py

```python
import requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = json.dumps({
    "jsonrpc": "2.0",
    "method": "starknet_blockNumber",
    "params": [],
    "id": "getblock.io"
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)
```

### Run the script

```bash
python main.py
```

## Available API Methods

### Chain & Client Info

| Method | Description |
| --- | --- |
| starknet_specVersion | Version of the Starknet JSON-RPC spec served |
| starknet_chainId | Chain ID of the connected Starknet network |
| starknet_syncing | Sync status, or false when fully synced |
| starknet_blockNumber | Latest accepted block number |
| starknet_blockHashAndNumber | Latest block hash and number together |

### Blocks & State

| Method | Description |
| --- | --- |
| starknet_getBlockWithTxHashes | Block header plus transaction hashes |
| starknet_getBlockWithTxs | Block header plus full transaction bodies |
| starknet_getBlockWithReceipts | Block with transactions and their receipts |
| starknet_getBlockTransactionCount | Number of transactions in a block |
| starknet_getStateUpdate | State diff applied by a block |

### Transactions

| Method | Description |
| --- | --- |
| starknet_getTransactionByHash | Transaction body by hash |
| starknet_getTransactionByBlockIdAndIndex | Transaction by block and index |
| starknet_getTransactionStatus | Finality and execution status of a transaction |
| starknet_getTransactionReceipt | Execution receipt of a transaction |

### Contracts, Accounts & State

| Method | Description |
| --- | --- |
| starknet_call | Call a contract view function (no transaction) |
| starknet_getStorageAt | Raw storage value at a contract key |
| starknet_getNonce | Account nonce at a block |
| starknet_getClassHashAt | Class hash deployed at an address |
| starknet_getClass | Contract class definition by class hash |
| starknet_getClassAt | Contract class deployed at an address |
| starknet_getEvents | Filtered events with pagination |

### Fee Estimation

| Method | Description |
| --- | --- |
| starknet_estimateFee | Estimate the fee for transactions |
| starknet_estimateMessageFee | Estimate the fee for an L1-to-L2 message |

### Write API

| Method | Description |
| --- | --- |
| starknet_addInvokeTransaction | Submit a signed invoke transaction |
| starknet_addDeployAccountTransaction | Deploy a new account contract |
| starknet_addDeclareTransaction | Declare a new contract class |

## Support

For technical support and questions:

* Support: [support@getblock.io](mailto:support@getblock.io)

## See Also

* [Starknet Documentation](https://docs.starknet.io/)
* [Starknet JSON-RPC Spec (starknet-specs)](https://github.com/starkware-libs/starknet-specs)
* [Starknet Book](https://book.starknet.io/)
* [Starkscan Explorer](https://starkscan.co/)
* [Voyager Explorer](https://voyager.online/)
