Skip to content

namestonehq/TheOffchainGateway.js

Repository files navigation

TheOffchainGateway.js

Offchain CCIP-Read Gateway in JS powered by ezccip.js and TheOffchainResolver.sol

Instructions

Routers

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, and History 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)

Demos

The following are hosted under tog.raffy.eth using a MultiRouter

About

Multipurpose Offchain ENS CCIP-Read Gateway in JS

Resources

License

Stars

Watchers

Forks