getBlockTransactionsTraces
Action for getting Starknet block transaction traces.
Import
import { getBlockTransactionsTraces } from "starkweb/core";
Usage
index.ts
import { getBlockTransactionsTraces } from "starkweb/core";
import { config } from "./config";
const traces = await getBlockTransactionsTraces(config, {
blockIdentifier: "latest",
});
Parameters
import { type GetBlockTransactionsTracesParameters } from "starkweb/core";
blockIdentifier
BlockIdentifier
The block identifier (number, hash, or 'latest').
index.ts
import { getBlockTransactionsTraces } from "starkweb/core";
import { config } from "./config";
const traces = await getBlockTransactionsTraces(config, {
blockIdentifier: "latest",
});
chainId (optional)
Hex | undefined
The chain ID to get the traces from. If not provided, uses the current chain.
index.ts
import { getBlockTransactionsTraces } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
const traces = await getBlockTransactionsTraces(config, {
blockIdentifier: "latest",
chainId: mainnet.chain_id,
});
Return Type
import { type GetBlockTransactionsTracesReturnType } from "starkweb/core";
Returns the block transaction traces information including:
chainId
Hex
The chain ID of the network.
traces
TransactionTrace[]
Array of transaction traces in the block.
Example
example.ts
import { getBlockTransactionsTraces } from "starkweb/core";
import { mainnet } from "starkweb/chains";
import { config } from "./config";
// Get traces from latest block
const traces = await getBlockTransactionsTraces(config, {
blockIdentifier: "latest",
});
console.log("Number of traces:", traces.traces.length);
// Get traces from specific block on mainnet
const mainnetTraces = await getBlockTransactionsTraces(config, {
blockIdentifier: 123456n,
chainId: mainnet.chain_id,
});
Error
import { type GetBlockTransactionsTracesErrorType } from "starkweb/core";