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

# Get Metadata \[token.getMetadata]

Gets an ERC-20 token's declared metadata and fetches `totalSupply` plus any missing fields from the
contract.

## Usage

This example gets the metadata (`decimals`, `name`, `symbol`, `totalSupply`) of an ERC-20 token.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const metadata = await client.token.getMetadata({
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
})
// @log: {
//   decimals: 6,
//   name: 'USD Coin',
//   symbol: 'USDC',
//   totalSupply: 52_000_000_000_000_000n,
// }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'
import { usdc } from 'viem/tokens'

export const client = Client.create({
  chain: mainnet,
  tokens: [usdc],
  transport: http(),
}).extend(publicActions())
```
:::

### Standalone Action

Call `Actions.token.getMetadata` directly by passing the Client as the first argument.

:::code-group
```ts twoslash [example.ts]
import { Actions } from 'viem'
import { client } from './viem.config'

const metadata = await Actions.token.getMetadata(client, {
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
})
// @log: {
//   decimals: 6,
//   name: 'USD Coin',
//   symbol: 'USDC',
//   totalSupply: 52_000_000_000_000_000n,
// }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http } from 'viem'
import { mainnet } from 'viem/chains'
import { usdc } from 'viem/tokens'

export const client = Client.create({
  chain: mainnet,
  tokens: [usdc],
  transport: http(),
})
```
:::

## Recipes

### Read Historical Token Metadata

Use an undeclared token address with `blockNumber` to fetch every metadata field from historical contract state.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const metadata = await client.token.getMetadata({
  blockNumber: 20_000_000n, // [!code focus]
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

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

## Return Value

`{ decimals: number; name: string; symbol: string; totalSupply: bigint }`

The token metadata.

## Parameters

### blockNumber

* **Type:** `bigint`

Reads the metadata at a given block number.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const metadata = await Actions.token.getMetadata(client, {
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  blockNumber: 42069n, // [!code focus]
})
```

### blockOverrides

* **Type:** `BlockOverrides`

Overrides block fields for the contract reads without changing chain state.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const metadata = await Actions.token.getMetadata(client, {
  blockOverrides: { number: 42069n }, // [!code focus]
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
})
```

### blockTag

* **Type:** `'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'`
* **Default:** `'latest'`

Reads the metadata at a given block tag.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const metadata = await Actions.token.getMetadata(client, {
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  blockTag: 'safe', // [!code focus]
})
```

### stateOverride

* **Type:** `StateOverrides`

Overrides account state for the contract reads without changing chain state.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const metadata = await Actions.token.getMetadata(client, {
  stateOverride: { // [!code focus]
    '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': { balance: 1n }, // [!code focus]
  }, // [!code focus]
  token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
})
```

### token

* **Type:** `Address | string`

The token to read: a contract `address`, or a symbol declared on the client's [`tokens`](/docs/clients/create) array.

Declared name, symbol, and decimals are reused. Total supply is read from the contract.

```ts twoslash
// @noErrors
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'
import { usdc } from 'viem/tokens'

const client = Client.create({
  chain: mainnet,
  tokens: [usdc],
  transport: http(),
}).extend(publicActions())
// ---cut---
const metadata = await client.token.getMetadata({
  token: 'usdc', // [!code focus]
})
```

## Errors

| Error | Description |
| --- | --- |
| `ContractError.ContractFunctionExecutionError` | A `decimals`/`name`/`symbol`/`totalSupply` call could not be executed. |
