← Back to all products
$10
Access Gate Middleware
Backend middleware that checks NFT/token ownership before granting API or content access.
TypeScriptJSONMarkdownRedis
📁 File Structure 12 files
access-gate-middleware/
├── LICENSE
├── README.md
├── package.json
├── security-notes.md
├── src/
│ ├── abi/
│ │ └── contracts.ts
│ ├── index.ts
│ ├── middleware/
│ │ ├── expressGate.ts
│ │ └── nextGate.ts
│ └── utils/
│ ├── cache.ts
│ └── chainVerifier.ts
├── test/
│ └── accessGate.test.ts
└── tsconfig.json
📖 Documentation Preview README excerpt
Access Gate Middleware
Sub Protocol Product #3 — CryptoForge Store #5
Express and Next.js middleware for token-gated access control. Checks ERC-721, ERC-1155, or custom subscription contract ownership on-chain.
Features
- Express middleware for REST API gating
- Next.js middleware adapter for page/route gating
- ERC-721 and ERC-1155 ownership verification
- Custom membership contract support (Sub Protocol #1 compatible)
- Redis-compatible caching layer
- Rate limiting per wallet address
- Configurable grace period for expired subscriptions
- Full TypeScript with type definitions
Quick Start
npm install @cryptoforge/access-gate-middleware
Express
import express from "express";
import { createAccessGate } from "@cryptoforge/access-gate-middleware";
const app = express();
const gate = createAccessGate({
rpcUrl: "https://eth.llamarpc.com",
contractAddress: "0xYourMembershipNFT",
contractType: "membership",
minTierId: 1, // Silver or above
});
app.get("/api/premium", gate, (req, res) => {
res.json({ message: "Welcome, subscriber!" });
});
Next.js
import { createNextGate } from "@cryptoforge/access-gate-middleware";
import { NextResponse } from "next/server";
export const middleware = createNextGate({
rpcUrl: process.env.RPC_URL!,
contractAddress: process.env.NFT_CONTRACT!,
contractType: "erc721",
protectedPaths: ["/dashboard", "/api/premium"],
}, NextResponse);
License
MIT
... continues with setup instructions, usage examples, and more.
📄 Code Sample .ts preview
src/index.ts
/**
* ╔══════════════════════════════════════════════════════════════════════╗
* ║ ACCESS GATE MIDDLEWARE ║
* ║ NFT Ownership & Subscription Verification ║
* ║ Sub Protocol #3 — CryptoForge ║
* ╚══════════════════════════════════════════════════════════════════════╝
*/
export { createAccessGate, type AccessGateConfig } from "./middleware/expressGate";
export { createNextGate, type NextGateConfig } from "./middleware/nextGate";
export { ChainVerifier, type VerificationResult } from "./utils/chainVerifier";
export { CacheLayer, type CacheConfig } from "./utils/cache";
export {
ERC721_ABI,
ERC1155_ABI,
MEMBERSHIP_NFT_ABI,
} from "./abi/contracts";