Offchain CCIP-Read Gateway in JS powered by ezccip.js and TheOffchainResolver.sol
npm i
- Create
.env
from.env.example
- By default,
config.js
includes many demo routers- Enabled with env
DEMO=1
(default)
- Enabled with env
- Start server:
npm run start
- Configuration available at
http://localhost:$PORT/
- Configuration available at
- Setup TOR
type Router {
// endpoint path component
slug: string;
// called during server start
init?(ezccip: EZCCIP): Promise<void>;
// ENS request handler
resolve?(
name: string, // "raffy.eth"
context: Context,
history: History // current history object
): Promise<Record | undefined>;
}
type Context = {
sender: string; // address of calling contract (TOR or wrapper)
resolver: string; // address of receiving contract (TOR)
calldata: string; // calldata of request
router: Router; // the current router
routers: Map<string, Router>; // available routers
history: History; // root history object
ip: string; // ip address of client
}
POST
Endpoints:http://localhost:$PORT/fixed
→ router with slug"fixed"
and uses Mainnet TOR (default)http://localhost:$PORT/fixed/s
uses Sepolia TOR — see config.js
- see
EZCCIP
,CallContext
, andHistory
from resolverworks/ezccip - see
Record
,Profile
,Node
from resolverworks/enson - TOR-invoked ENSIP-10 requests are handled by
resolve()
- Arbitrary EIP-3668 requests can be registered during
init()
- You may host multiple independent routers simultaneously.
- MultiRouter dispatches requests to another router where
subdomain = slug
- Example:
/multi
+"a.b.flat.c.d"
→/flat
+"a.b"
- Enabled with env
MULTI=1
(default)
- Example:
The following are hosted under tog.raffy.eth
using a MultiRouter
- Fixed Record for ALL Names
- Random Address
- Simple {name: address} Database → simple.json
- Mainnet On-chain ".eth" Mirror via
MirrorRouter
- Coinbase Exchange Rates — lookup crypto price, icon, name, etc.
- Wikipedia — lookup any Wikipedia article
- Farcaster — fname ↔ fid
- Github — host namespace from a personal or project repo
- Teamnick — teamnick.xyz resolver
- XCTENS Example via
XCTENSRouter
- Cross-chain ERC-721 Subdomain Resolver + Contract → resolverworks/XCTENS.sol
- Unicode — lookup any Unicode codepoint
- Emoji — lookup any base-single emoji
- ENS Registrations — latest registrations by index
- Airtable via
AirtableRouter.js
→ demo table- Requires airtable.com account
- Supports any record type (using resolverworks/enson.js notation for column name)
moo.airtable.tog.raffy.eth
chonk.raffy.xyz
- Namespace via
createNamespace()
— describe a namespace in JS-object notation - Tree via
NodeRouter
→tree.json
tree.tog.raffy.eth
💎️.tree.tog.raffy.eth
adraffy.alice.tree.tog.raffy.eth
- Supports
_
-index:_.tree.tog.raffy.eth
- Supports reverse:
51050ec063d393217b436747617ad1c2285aeeee.addr.reverse.tree.tog.raffy.eth
- Automatic reload after modification
- Automatic JSON API
- Supports multiple basenames
- Flat via NodeRouter.js →
flat.json
- Same as Tree except uses a flat data structure
raffy.flat.tog.raffy.eth
- Offchain Tunnel for
fetchFlatJSON()
— an example of resolverworks/OffchainTunnel.sol- Demo (view source)