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

## `getDeploymentByLabel`

:::note
Not in v1.10.1; available in nightly builds since November 28, 2026 ([foundry#18790](https://github.com/foundry-rs/foundry/pull/18790)). forge-std does not declare it yet, so the example uses its own interface.
:::

### Signature

```solidity
function getDeploymentByLabel(string calldata label) external view returns (address deployedAddress);
function getDeploymentByLabel(string calldata label, uint64 chainId) external view returns (address deployedAddress);
```

### Description

Returns the address of the deployment whose [`vm.label`](/reference/cheatcodes/label) is `label` on `chainId`, read from the [broadcast files](/forge/broadcast-files) that `forge script --broadcast` writes. Without `chainId`, the current `block.chainid` is used.

Forge records a deployed contract's label in the broadcast file when the script labels its address. This tells apart several deployments of the same contract, which [`getDeployment`](/reference/cheatcodes/get-deployment) cannot do.

The cheatcode looks in the most recent run on that chain, from any script, that has a confirmed deployment with that label. Deployments include `CREATE` and `CREATE2` transactions and contracts created during any confirmed transaction, such as by a factory call, which the broadcast file lists under `additionalContracts`. A later run without a receipt for the label, such as an interrupted redeploy or a `dry-run` simulation, is skipped, so the previous deployment is returned.

### Parameters

| Parameter | Type     | Description                                            |
|-----------|----------|--------------------------------------------------------|
| `label`   | `string` | The label the script gave the deployed address         |
| `chainId` | `uint64` | The chain to look up. Defaults to the current chain ID |

### Returns

| Parameter         | Type      | Description                                |
|-------------------|-----------|--------------------------------------------|
| `deployedAddress` | `address` | The address of the labeled deployment      |

### Examples

`script/Deploy.s.sol` deploys two `Counter` contracts and labels them `first-counter` and `second-counter`. 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/DeploymentByLabel.t.sol]
// [!include ~/snippets/projects/broadcast_lookup/test/DeploymentByLabel.t.sol:get-deployment-by-label]
```

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

### Gotchas

* Reverts with `no deployment labeled "<label>" on chain <chainId>; use getDeployment for contract names` when no deployment has the label.
* Reverts when several deployments in that run share the label, and the error lists their addresses. Give each deployment its own label.

### Related Cheatcodes

* [`getDeployment`](/reference/cheatcodes/get-deployment) - Returns the most recent deployment of a contract by name
* [`getDeployments`](/reference/cheatcodes/get-deployments) - Returns every deployment of a contract
* [`label`](/reference/cheatcodes/label) - Sets a label for an address

### See Also

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