CCIP Gateway
The CCIP Gateway implements ERC-3668 (CCIP-Read) to enable off-chain ENS resolution for subnames.
Overview​
CCIP-Read allows ENS names to resolve to data stored off-chain (in our database) while maintaining the trustless verification properties of on-chain ENS. This enables:
- Instant registration — No gas fees or blockchain transactions needed
- Cheap subnames — Storage costs are minimal vs on-chain
- Full ENS compatibility — Works with all ENS-aware applications
How It Works​
1. User queries alice.aboutme.eth via ENS
2. ENS resolver returns CCIP-Read URL pointing to our gateway
3. Client fetches signed data from gateway
4. Client verifies signature and uses the data
Gateway URL​
https://api.web3identity.com/ccip/\{sender\}/\{data\}.json
Endpoints​
| Method | Path | Description |
|---|---|---|
GET | /ccip/\{sender\}/\{data\}.json | CCIP-Read resolver (ERC-3668) |
POST | /ccip | CCIP-Read resolver (alternative) |
GET | /ccip/health | Gateway health check |
GET /ccip/{sender}/{data}.json​
ERC-3668 compliant CCIP-Read endpoint. Called automatically by ENS-aware clients.
Parameters​
| Parameter | Type | Location | Description |
|---|---|---|---|
sender | string | path | Contract address making the request |
data | string | path | Hex-encoded calldata |
Response​
{
"data": "0x...",
"signature": "0x...",
"validUntil": 1707580800
}
Example​
# This endpoint is typically called automatically by viem/ethers
curl "https://api.web3identity.com/ccip/0x1234.../0xabcd....json"
POST /ccip​
Alternative CCIP endpoint that accepts parameters in the body.
Request Body​
{
"sender": "0x1234567890abcdef1234567890abcdef12345678",
"data": "0xabcdef..."
}
Response​
Same as GET endpoint.
GET /ccip/health​
Check the health status of the CCIP gateway.
Response​
{
"status": "healthy",
"recordCount": 156,
"dbPath": "/path/to/database.db",
"timestamp": "2024-02-10T14:30:00.000Z"
}
Example​
curl "https://api.web3identity.com/ccip/health"
Client Integration​
viem (Recommended)​
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
import { normalize } from 'viem/ens';
const client = createPublicClient({
chain: mainnet,
transport: http(),
});
// CCIP-Read is handled automatically
const address = await client.getEnsAddress({
name: normalize('alice.aboutme.eth'),
});
console.log(address); // 0x701B4937e6c943789ffA74CC8601813b2D87B454
ethers.js​
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider(
'https://eth.llamarpc.com',
{ name: 'mainnet', chainId: 1, ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' }
);
// CCIP-Read handled automatically
const address = await provider.resolveName('alice.aboutme.eth');
console.log(address);
Direct API (No ENS)​
If you don't need ENS integration, use our direct API:
// Get subname data directly
const response = await fetch(
'https://api.web3identity.com/api/subnames/aboutme.eth/alice'
);
const data = await response.json();
console.log(data.owner); // 0x701B4937e6c943789ffA74CC8601813b2D87B454
Supported Records​
The CCIP gateway supports these ENS record types:
| Type | Function | Description |
|---|---|---|
| Address | addr(bytes32) | Ethereum address |
| Text | text(bytes32,string) | Text records (description, url, etc.) |
| Contenthash | contenthash(bytes32) | IPFS/IPNS content |
Security​
- Signed responses — All data is cryptographically signed
- Validity period — Signatures expire to prevent replay attacks
- On-chain verification — Clients verify signatures against the resolver
Error Responses​
| Status | Code | Description |
|---|---|---|
| 400 | CCIP_ERROR | Invalid request or data |
| 400 | INVALID_REQUEST | Missing sender or data |
| 500 | CCIP_ERROR | Internal gateway error |
| 500 | CCIP_HEALTH_ERROR | Health check failed |
Related​
- ERC-3668 Specification
- ENS Documentation
- Subnames API — Direct subname management