starknet_getClassHashAt
curl --request POST \
--url https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "starknet_getClassHashAt",
"params": [
{
"block_number": 385940
},
"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"
]
}
'import requests
url = "https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e"
payload = {
"id": 1,
"jsonrpc": "2.0",
"method": "starknet_getClassHashAt",
"params": [{ "block_number": 385940 }, "0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: 1,
jsonrpc: '2.0',
method: 'starknet_getClassHashAt',
params: [
{block_number: 385940},
'0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82'
]
})
};
fetch('https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'method' => 'starknet_getClassHashAt',
'params' => [
[
'block_number' => 385940
],
'0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e"
payload := strings.NewReader("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"starknet_getClassHashAt\",\n \"params\": [\n {\n \"block_number\": 385940\n },\n \"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82\"\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))
}HttpResponse<String> response = Unirest.post("https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e")
.header("Content-Type", "application/json")
.body("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"starknet_getClassHashAt\",\n \"params\": [\n {\n \"block_number\": 385940\n },\n \"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"starknet_getClassHashAt\",\n \"params\": [\n {\n \"block_number\": 385940\n },\n \"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82\"\n ]\n}"
response = http.request(request)
puts response.read_bodyStarknet node API
starknet_getClassHashAt | Starknet
Starknet API method that returns the hash of the class at a given address. It provides the hash of the class at the specified address.
POST
/
mt_c524ad9781ae5dccd9ac6f5b0370e
starknet_getClassHashAt
curl --request POST \
--url https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e \
--header 'Content-Type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "starknet_getClassHashAt",
"params": [
{
"block_number": 385940
},
"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"
]
}
'import requests
url = "https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e"
payload = {
"id": 1,
"jsonrpc": "2.0",
"method": "starknet_getClassHashAt",
"params": [{ "block_number": 385940 }, "0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: 1,
jsonrpc: '2.0',
method: 'starknet_getClassHashAt',
params: [
{block_number: 385940},
'0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82'
]
})
};
fetch('https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 1,
'jsonrpc' => '2.0',
'method' => 'starknet_getClassHashAt',
'params' => [
[
'block_number' => 385940
],
'0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e"
payload := strings.NewReader("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"starknet_getClassHashAt\",\n \"params\": [\n {\n \"block_number\": 385940\n },\n \"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82\"\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))
}HttpResponse<String> response = Unirest.post("https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e")
.header("Content-Type", "application/json")
.body("{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"starknet_getClassHashAt\",\n \"params\": [\n {\n \"block_number\": 385940\n },\n \"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://starknet-mainnet.core.chainstack.com/mt_c524ad9781ae5dccd9ac6f5b0370e")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 1,\n \"jsonrpc\": \"2.0\",\n \"method\": \"starknet_getClassHashAt\",\n \"params\": [\n {\n \"block_number\": 385940\n },\n \"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82\"\n ]\n}"
response = http.request(request)
puts response.read_bodyStarknet OpenRPC specFor the latest version of the publicly maintained OpenRPC spec, see the Starknet specs GitHub repo.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
-
block_id— the hash of the requested block, or number (height) of the requested block, or a block tag:latest— the latest Starknet block finalized by consensus on L2.pre_confirmed— the block that the block proposer is building at heightlatest+ 1.l1_accepted— the latest Starknet block included in a state update on L1 and finalized by consensus on L1.
safe,finalized, andearliestaren’t valid on Starknet. JSON-RPC API version 0.9 replaced thependingtag withpre_confirmed. -
contract_address— the address of the contract.
Response
result— the hash of the class at the given address, represented as a hexadecimal string.
Use case
A practical use case forstarknet_getClassHashAt is to verify the type of contract deployed at a given address. This can be useful for developers to ensure that the correct contract has been deployed at the expected address.Last modified on November 13, 2026
Was this page helpful?