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

# Creating a Contract Instance

## Overview

Use [`Contract.from`](#contractfrom) to create a type-safe contract interface bound to an ABI, address, and [Client](/docs/clients).

Construction is synchronous and makes no RPC request. It does not verify that the address is deployed or that its bytecode matches the ABI.

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })

const contract = Contract.from({
  abi: Abis.erc20,
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  client,
})
```

## Recipes

### Bind Contract Details

Bind an ABI, address, and Client once when your application calls the same contract repeatedly.

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })

const contract = Contract.from({ // [!code focus]
  abi: Abis.erc20, // [!code focus]
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // [!code focus]
  client, // [!code focus]
}) // [!code focus]
```

### Call a Bound Method

Call a function by its ABI name. The instance supplies the ABI, contract address, and function name.

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })
const contract = Contract.from({
  abi: Abis.erc20,
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  client,
})

const balance = await contract.read.balanceOf([ // [!code focus]
  '0x0000000000000000000000000000000000000000', // [!code focus]
]) // [!code focus]
```

## `Contract.from`

Creates a type-safe contract interface bound to an ABI, address, and Client.

### Usage

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })

const contract = Contract.from({
  abi: Abis.erc20,
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  client,
})
```

### Parameters

#### options.abi

* **Type:** `Abi | readonly unknown[]`

The contract's ABI. Method names and argument types are derived from it, so pass a literal ABI such as `Abis.erc20` to preserve inference.

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const contract = Contract.from({
  abi: Abis.erc20, // [!code focus]
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  client,
})
```

#### options.address

* **Type:** `Address`

The address of the contract.

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const contract = Contract.from({
  abi: Abis.erc20,
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // [!code focus]
  client,
})
```

#### options.client

* **Type:** `Client`

The Client used to execute the contract's actions.

The [`write`](/docs/contract/instances/write) group requires an [Account](/docs/accounts) on the Client or per call.

```ts twoslash
import { Client, Contract, http } from 'viem'
import { mainnet } from 'viem/chains'
import { Abis } from 'viem/utils'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const contract = Contract.from({
  abi: Abis.erc20,
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  client, // [!code focus]
})
```

### Return Value

`Contract`

The contract instance contains `{ abi, address }` and method groups derived from the ABI.

Functions appear under `read`, `estimateGas`, `simulate`, and `write`. Events appear under `createEventFilter`, `getLogs`, and `watchEvent`.

Groups without matching ABI items are omitted. Clients without an Account require a per-call `account` option for `write` methods.
