> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.getfoundry.sh/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

## `getBroadcast`

### Signature

```solidity
enum BroadcastTxType {
    Call,
    Create,
    Create2
}

struct BroadcastTxSummary {
    bytes32 txHash;
    BroadcastTxType txType;
    address contractAddress;
    uint64 blockNumber;
    bool success;
}

function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);
```

### Description

Returns the most recent transaction of type `txType` for `contractName` on `chainId`, read from the [broadcast files](/forge/broadcast-files) that `forge script --broadcast` writes. Pass `Create` or `Create2` to get the most recent deployment, or `Call` to get the most recent call to the contract.

`contractName` is matched against the `contractName` key of each transaction. For a call, this is the contract that was called. Only transactions with a receipt count.

The cheatcode reads every timestamped run file under the [`broadcast`](/config/reference/project#broadcast) directory, from any script, and skips `-latest` files. It picks the newest run file on that chain with a matching transaction, then returns the one in the highest block. If several share that block, it returns the one the script sent first.

### Parameters

| Parameter      | Type              | Description                                          |
|----------------|-------------------|------------------------------------------------------|
| `contractName` | `string`          | The contract name, as recorded in the broadcast file |
| `chainId`      | `uint64`          | The chain to look up                                 |
| `txType`       | `BroadcastTxType` | `Call`, `Create` or `Create2`                        |

### Returns

A `BroadcastTxSummary` with these fields:

| Field             | Type              | Description                                                          |
|-------------------|-------------------|----------------------------------------------------------------------|
| `txHash`          | `bytes32`         | The transaction hash                                                 |
| `txType`          | `BroadcastTxType` | `Call`, `Create` or `Create2`                                        |
| `contractAddress` | `address`         | The contract that was called, or the contract that was created       |
| `blockNumber`     | `uint64`          | The block the transaction landed in                                  |
| `success`         | `bool`            | The status from the transaction receipt                              |

### Examples

`script/Deploy.s.sol` deploys two `Counter` contracts and then calls `increment()` on the first one. Broadcasting it to a local Anvil node (chain ID 31337) wrote `broadcast/Deploy.s.sol/31337/run-<timestamp>.json`, which the test below reads. With forge-std, the enum and struct are declared in `VmSafe`, so you write `VmSafe.BroadcastTxType.Call`. The snippet project declares its own `BroadcastVm` interface instead.

:::code-group
```solidity [test/BroadcastLookup.t.sol]
// [!include ~/snippets/projects/broadcast_lookup/test/BroadcastLookup.t.sol:get-broadcast]
```

```solidity [script/Deploy.s.sol]
// [!include ~/snippets/projects/broadcast_lookup/script/Deploy.s.sol]
```
:::

### Gotchas

* Reverts with `No broadcasts found` when no run file on that chain has a matching transaction, and with `broadcast dir does not exist or is not a directory` when the `broadcast` directory is missing.
* The newest matching run file wins even if none of its transactions has a receipt. A later simulation without `--broadcast` writes `dry-run/run-<timestamp>.json` with no receipts, and `getBroadcast` then reverts with `no deployment found for <contractName> on chain <chainId>`, even for `Call`.

### Related Cheatcodes

* [`getBroadcasts`](/reference/cheatcodes/get-broadcasts) - Returns every transaction for a contract
* [`getDeployment`](/reference/cheatcodes/get-deployment) - Returns the most recent deployment address

### See Also

* [Broadcast files](/forge/broadcast-files)
