# Revving Up Starknet

### TL;DR:

Learn how to deploy an OpenZeppelin account on Starknet Sepolia with Scarb 2.21 and starkli 0.4.2. Fix the Blast RPC 403 and the `pending` block-tag error, then confirm the transaction on Voyager.

who is it for?: Devs new to Starknet who already use Python or a CLI.

## What you are installing

| Tool | Job | Version that worked |
| --- | --- | --- |
| [Scarb](https://docs.swmansion.com/scarb/) | Compile Cairo to Sierra | 2.21.0 (Cairo 2.21.0) |
| [starknet.py](https://starknetpy.readthedocs.io/) | Python client for later calls | 0.30.0 |
| [starkli](https://book.starkli.rs/) | Keystore, account, declare, deploy | 0.4.2 (`77ff6b3`) |

`starkli 0.4.2` speaks JSON-RPC **v0.8** and pays fees in STRK. (remember to avoid the 2 errors below)

## 1\. Install

**Scarb.** Follow the [asdf or install script](https://docs.swmansion.com/scarb/download.html), then:

```bash
scarb --version
```

[**starknet.py**](http://starknet.py)**.** From the Python project (I used `uv`, Python `>=3.12`):

```bash
cd <your-python-project>
uv add starknet.py
```

That pins `starknet-py>=0.30.0`.

**starkli.** The installer script only drops `starkliup`. `starkliup --version` does not print a version. With no tag it errors `Version tag is missing`. No arguments installs the latest release:

```bash
curl https://get.starkli.sh | sh
"$HOME/.starkli/bin/starkliup"
echo '. "$HOME/.starkli/env"' >> ~/.zshrc
source ~/.starkli/env
starkli --version
```

If `curl | sh` says it cannot detect your shell, skip the script’s PATH edit and add only the `source` line above. Do not replace your existing `PATH`.

## 2\. Compile

`scarb build` needs a crate root. A missing `src/lib.cairo` fails before Cairo type-checks. On Cairo 2.21, interface signatures also need the address type imported at the top of the file:

```cairo
use starknet::ContractAddress;
```

`Scarb.toml` for your "&lt;name>.cairo" contract:

```toml
[package]
name = "contract_name"
version = "0.1.0"
edition = "2023_11"

[dependencies]
starknet = "2.8.5"

[[target.starknet-contract]]
sierra = true
```

```bash
scarb build
```

Sierra lands at `target/dev/spending_policy_SpendingPolicy.contract_class.json`. starkli compiles Sierra to CASM itself, so you do not need `casm = true` for declare.

## 3\. Create the deployer

Ready (or any browser wallet) does not export a CLI signer.

starkli creates a separate OpenZeppelin account. That account pays gas. Your Ready address is only a constructor argument later, so only Ready can register or revoke.

```bash
mkdir -p ~/.starkli/sepolia
starkli signer keystore new ~/.starkli/sepolia/keystore.json
export STARKNET_KEYSTORE=~/.starkli/sepolia/keystore.json
starkli account oz init ~/.starkli/sepolia/account.json
export STARKNET_ACCOUNT=~/.starkli/sepolia/account.json
```

Keep the keystore and password off git and off the command line. This run created:

`0x06be8842d0d8cd1660b029018e13cbba161b0db7cf7d687ee9ca36256a2b3d73`

**Error:** `starkli account oz init ... --network sepolia` → `unexpected argument '--network'`.

`oz init` only writes the account file. `--network` belongs on `deploy` and `declare`. `-- --network` does not fix it.

## 4\. Point at an RPC starkli can speak

```bash
export STARKNET_RPC=https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_8
starkli account deploy ~/.starkli/sepolia/account.json --network sepolia
```

`STARKNET_RPC` overrides `--network`. The warning is expected. See [starkli providers](https://book.starkli.rs/providers).

**Error 1.** First deploy, no `STARKNET_RPC`. starkli’s free Sepolia vendor is Blast (`~/.config/starkli/profiles.toml`, `vendor = "blast"`). Blast now returns HTTP 403: `Blast API is no longer available`. starkli surfaces that as `data did not match any variant of untagged enum JsonRpcResponse`.

**Error 2.** `export STARKNET_RPC=https://starknet-sepolia.drpc.org` reaches Sepolia (`chainId` `0x534e5f5345504f4c4941`, spec **0.10.3**) and then fails:

```text
JSON-RPC error: code=-32602, message="Invalid Params", data="unknown block tag 'pending'"
```

RPC 0.9+ renamed `pending` to `pre_confirmed`. starkli 0.4.2 is still the latest release and still sends `pending`. There is no newer starkli to upgrade to. Use a node that still serves v0.8.

Checked against live endpoints:

| URL | Spec | `pending` |
| --- | --- | --- |
| `https://starknet-sepolia.drpc.org` | 0.10.3 | rejected |
| `https://api.cartridge.gg/x/starknet/sepolia` | 0.9.0 | rejected |
| `https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_8` | 0.8.1 | accepted |

## 5\. Fund, then press Enter

starkli gives an estimated `{STRK}` for deploying the contract:

> Send that from a "funded Ready wallet"(install and setup through the [Chrome extension for Ready](https://chromewebstore.google.com/detail/ready-x-starknet-wallet/dlcobpjiigpikoobohmabehhmhfoodbb) ) to the deployer address.
>
> Faucet: <https://www.diadata.org/map/web3-builder-hub/starknet-faucets/>
>
> `STRK` has 18 decimals. Token address (confirm on [chain info](https://docs.starknet.io/resources/chain-info/)): `0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d`.

Press Enter only after the transfer is visible. `starkli` then sends the txn and prints confirmed with txn hash. If you interrupt the wait, run `starkli account fetch` so the account file records the deployment.

Explorer: [Voyager receipt](https://sepolia.voyager.online/tx/0x06c9deadd4bfcdd0db84e54bfe32f803ff841636a70144091dabf68db9232ccd).

## 6\. Declare and deploy the contract

Same RPC and account. Class hash comes from `starkli declare`. The only constructor argument is the Ready owner address.

```bash
export STARKNET_RPC=https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_8
export STARKNET_ACCOUNT=~/.starkli/sepolia/account.json
export STARKNET_KEYSTORE=~/.starkli/sepolia/keystore.json
starkli declare target/dev/spending_policy_SpendingPolicy.contract_class.json
starkli deploy <CLASS_HASH> <READY_ADDRESS>
```

voila! your openzepplin account is deployed and proof is on voyager. ( that was a hell lot of info to digest in one go, i agree.)

## Troubleshooting

| Symptom | Cause | Fix |
| --- | --- | --- |
| `starkli: command not found` | Installer added `starkliup` only, or the shell was opened before `~/.starkli/env` | Run `starkliup` with no args, then `source ~/.starkli/env` |
| `Version tag is missing` | `--version` means “install this tag” | Drop the flag |
| `src/lib.cairo not found` | Scarb crate root missing | `mod spending_policy;` in `src/lib.cairo` |
| `ContractAddress` not found | Cairo 2.21 needs the import | `use starknet::ContractAddress;` |
| `unexpected argument '--network'` on `oz init` | Flag is not valid there | `starkli account oz init <file>` |
| `JsonRpcResponse` enum error | Blast free RPC is shut down | Set `STARKNET_RPC` |
| `unknown block tag 'pending'` | Endpoint is RPC 0.9+ | Use Cartridge `/rpc/v0_8` |

## References

- [starkli book: providers](https://book.starkli.rs/providers)
- [starkli releases](https://github.com/xJonathanLEI/starkli/releases) (v0.4.2 is current; v0.4.0 moved to JSON-RPC 0.8 and STRK fees)
- [Scarb download](https://docs.swmansion.com/scarb/download.html)
- [Starknet chain info](https://docs.starknet.io/resources/chain-info/)
- [Voyager Sepolia](https://sepolia.voyager.online/)
- [Ready session keys](https://docs.ready.co/aa-use-cases/session-keys/implement-session-keys)
- [AVNU gasless paymaster](https://docs.avnu.fi/docs/paymaster/gasfree) (Sepolia sponsorship is separate from this self-paid account deploy)
