starknet_getTransactionByBlockIdAndIndex
Get the details of a transaction by a given block id and index
Get the details of the transaction given by the identified block and index in that block. If no transaction is found, null is returned.
Parameters
Parameter | Type | Description |
---|---|---|
block_id | string | Block reference ("latest", "l1_accepted", block hash, or block number) |
index | integer | Transaction index in the block |
Request
{
"jsonrpc": "2.0",
"method": "starknet_getTransactionByBlockIdAndIndex",
"params": [
{
"block_hash": "0x05abbad1e5"
},
1
],
"id": 1
}
Returns
Transaction details at the specified index
Errors
Code | Message |
---|---|
24 | Block not found |
27 | Invalid transaction index in a block |
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_getTransactionByBlockIdAndIndex",
"params": [
{
"block_hash": "0x05abbad1e5"
},
1
],
"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_getTransactionByBlockIdAndIndex',
params: [
{
"block_hash": "0x05abbad1e5"
},
1
]
};
const result = await provider.fetchEndpoint(payload.method, payload.params);
console.log(result);