> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# ContractAddress

:::info
`ContractAddress` is a re-export of ox's [`ContractAddress`](https://oxlib.sh/api/ContractAddress). Refer to the ox documentation for the full reference.
:::

Utility functions for computing Contract Addresses.

## Examples

Below are some examples demonstrating common usages of the `ContractAddress` module:

* [Computing Contract Addresses (CREATE)](#computing-contract-addresses-\(create\))

* [Computing Contract Addresses (CREATE2)](#computing-contract-addresses-\(create2\))

### Computing Contract Addresses (CREATE)

A Contract Address that was instantiated using the `CREATE` opcode can be computed using [`ContractAddress.fromCreate`](/docs/utilities/contractaddress/fromCreate):

```ts twoslash
// @noErrors
import { ContractAddress } from 'viem/utils'

ContractAddress.fromCreate({
  from: '0x1a1e021a302c237453d3d45c7b82b19ceeb7e2e6',
  nonce: 0n
})
// @log: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2'
```

### Computing Contract Addresses (CREATE2)

A Contract Address that was instantiated using the `CREATE2` opcode can be computed using [`ContractAddress.fromCreate2`](/docs/utilities/contractaddress/fromCreate2):

```ts twoslash
// @noErrors
import { Bytes, ContractAddress, Hex } from 'viem/utils'

ContractAddress.fromCreate2({
  from: '0x1a1e021a302c237453d3d45c7b82b19ceeb7e2e6',
  bytecode: Bytes.from(
    '0x6394198df16000526103ff60206004601c335afa6040516060f3'
  ),
  salt: Hex.fromString('hello world')
})
// @log: '0x59fbB593ABe27Cb193b6ee5C5DC7bbde312290aB'
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`ContractAddress.from`](/docs/utilities/contractaddress/from) | Computes Contract Address generated by the [CREATE](https://ethereum.stackexchange.com/questions/68943/create-opcode-what-does-it-really-do/68945#68945) or [CREATE2](https://eips.ethereum.org/EIPS/eip-1014) opcode. |
| [`ContractAddress.fromCreate`](/docs/utilities/contractaddress/fromCreate) | Computes contract address via [CREATE](https://ethereum.stackexchange.com/questions/68943/create-opcode-what-does-it-really-do/68945#68945) opcode. |
| [`ContractAddress.fromCreate2`](/docs/utilities/contractaddress/fromCreate2) | Computes contract address via [CREATE2](https://eips.ethereum.org/EIPS/eip-1014) opcode. |
