> **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.

## `getDeployments`

### Signature

```solidity
function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);
```

### Description

Returns the addresses of every deployment of `contractName` on `chainId`, read from the [broadcast files](/forge/broadcast-files) that `forge script --broadcast` writes.

`contractName` is matched against the `contractName` key of each transaction. A deployment is a `CREATE` or `CREATE2` transaction, and only transactions with a receipt are returned.

The cheatcode reads every timestamped run file under the [`broadcast`](/config/reference/project#broadcast) directory, from any script, and skips `-latest` files. The result is sorted newest first: by run file timestamp, then by block number within a run. Transactions in the same block stay in the order the script sent them, oldest first.

### Parameters

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

### Returns

| Parameter           | Type        | Description                                  |
|---------------------|-------------|----------------------------------------------|
| `deployedAddresses` | `address[]` | The deployment addresses, most recent first  |

### 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.

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

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

### Gotchas

* Returns an empty array when no deployment matches. Unlike [`getDeployment`](/reference/cheatcodes/get-deployment), it does not revert, and run files without receipts, such as `dry-run` simulations, add nothing.
* Reverts with `broadcast dir does not exist or is not a directory` when the `broadcast` directory is missing.

### Related Cheatcodes

* [`getDeployment`](/reference/cheatcodes/get-deployment) - Returns the most recent deployment of a contract
* [`getDeploymentByLabel`](/reference/cheatcodes/get-deployment-by-label) - Returns a deployment by its `vm.label`
* [`getBroadcasts`](/reference/cheatcodes/get-broadcasts) - Returns every transaction for a contract

### See Also

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