starknet_getClassAt
Get the contract class definition in the given block at the given address
Parameters
Parameter | Type | Description |
---|---|---|
block_id | string | Block reference ("latest", "l1_accepted", block hash, or block number) |
contract_address | felt252 | Contract address |
Request
{
"jsonrpc": "2.0",
"method": "starknet_getClassAt",
"params": [
{
"block_hash": "0x05abbad1e5"
},
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
],
"id": 1
}
Returns
The contract class
Contract class definition with Sierra program, entry points, and ABI
Errors
Code | Message |
---|---|
24 | Block not found |
20 | Contract not found |
Examples
- cURL
- JavaScript
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "starknet_getClassAt",
"params": [
{
"block_hash": "0x05abbad1e5"
},
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
],
"id": 1
}'
import { RpcProvider } from 'starknet';
const provider = new RpcProvider({
nodeUrl: 'https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY',
});
const payload = {
method: 'starknet_getClassAt',
params: [
{
"block_hash": "0x05abbad1e5"
},
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
]
};
const result = await provider.fetchEndpoint(payload.method, payload.params);
console.log(result);