Resolve with ENS
Resolve swop.id names with any ENS library. The verified path to use before money moves.
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).
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.
Resolve a name to an address
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 nullCCIP 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
The resolver serves selected public profile text records. Read the avatar the standard ENS way:
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 is simpler.
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.
- Normalize the name first (
normalize()in viem; ethers and web3.py do it for you). - Resolve through ENS on Ethereum mainnet with CCIP Read enabled.
- Show the payer the resolved address and the network before they confirm.
- Re-resolve right before you create the payment. Don't reuse an address you resolved minutes ago.
- Fail closed. If resolution fails, or returns a zero or invalid address, don't send.
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.