# Resolve with ENS (/docs/identity/resolve-with-ens)

Every swop.id is a real ENS name, so you resolve it the same way you'd resolve `vitalik.eth`: with an ENS-aware library and an Ethereum mainnet RPC. The library handles CCIP Read for you (see [how it works](/docs/identity#how-it-works-in-plain-words)).

<Callout title="You need an Ethereum mainnet RPC">
ENS lives on Ethereum mainnet, even if you're paying on Base or Polygon. Use any mainnet RPC you trust. The examples use a placeholder `https://YOUR_MAINNET_RPC`.
</Callout>

## Resolve a name to an address [#resolve-a-name-to-an-address]

<Tabs items={['viem', 'ethers', 'Python']}>
<Tab value="viem">
```ts
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
import { normalize } from 'viem/ens';

const client = createPublicClient({
  chain: mainnet,
  transport: http('https://YOUR_MAINNET_RPC'),
});

const address = await client.getEnsAddress({ name: normalize('maya.swop.id') });
// '0x…' or null
```
</Tab>
<Tab value="ethers">
```ts
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://YOUR_MAINNET_RPC');
const address = await provider.resolveName('maya.swop.id');
// '0x…' or null
```
</Tab>
<Tab value="Python">
```python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider("https://YOUR_MAINNET_RPC"))
address = w3.ens.address("maya.swop.id")
# '0x…' or None
```
</Tab>
</Tabs>

CCIP Read is on by default in all three libraries. If you've turned it off (for example `ccipRead: false` in viem), swop.id names won't resolve.

## Read the avatar [#read-the-avatar]

The resolver serves selected public profile text records. Read the avatar the standard ENS way:

```ts
const avatar = await client.getEnsAvatar({ name: normalize('maya.swop.id') });
```

If a text record isn't set you get `null`. For the display name and Solana address, the [Identity API](/docs/identity/identity-api) is simpler.

## Rules for paying a name [#rules-for-paying-a-name]

If your app sends money to a swop.id, follow these five rules. They're the same ones the Swop apps use.

1. **Normalize** the name first (`normalize()` in viem; ethers and web3.py do it for you).
2. **Resolve through ENS** on Ethereum mainnet with CCIP Read enabled.
3. **Show the payer the resolved address and the network** before they confirm.
4. **Re-resolve right before you create the payment.** Don't reuse an address you resolved minutes ago.
5. **Fail closed.** If resolution fails, or returns a zero or invalid address, don't send.

## Contract addresses [#contract-addresses]

| | Address (Ethereum mainnet) |
|---|---|
| ENS registry | `0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e` |
| `swop.id` resolver | `0xd75e9aDBf10A058548dA74C67c0A299424A6d989` |

Your ENS library finds the resolver for you. You only need these to verify things yourself, for example in a block explorer.
