A lightweight, high-performance NFT metadata server built with NestJS for the TON blockchain. This server provides comprehensive support for both standard NFTs and compressed NFTs (cNFTs) with Merkle tree validation.
- Compressed NFT (cNFT) Support: Advanced cNFT functionality with Merkle tree proofs
- High Performance: Built with NestJS and optimized for fast response times
- Database Integration: SQLite database with Prisma ORM for efficient data management
- Docker Ready: Containerized deployment with Docker and Docker Compose
- Node.js 18+
- npm or yarn
- Docker (optional, for containerized deployment)
- Clone the repository:
git clone https://github.com/isaev-the-poetry/nft-metadata-server
cd nft-metadata-server- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Set up the database:
npx prisma generate
npx prisma db push5.1. Create initial metadata:
edit scripts/seed.ts5.2. Seed the database (optional):
npm run seednpm run start:devnpm run build
npm run start:proddocker-compose up -dGET /metadata/collection/:id
GET /metadata/collection/:id.json
Returns collection metadata including name, description, and image.
Example Response:
{
"name": "Collection Name",
"description": "Collection Description",
"image": "https://example.com/image.png"
}GET /metadata/collection/:collectionId/token/:tokenId
GET /metadata/collection/:collectionId/token/:tokenId.json
Returns individual token metadata with attributes.
Example Response:
{
"name": "Token Name",
"description": "Token Description",
"image": "https://example.com/token.png",
"content_url": "https://example.com/content",
"attributes": [
{
"trait_type": "Rarity",
"value": "Common"
}
]
}GET /cnft/:collectionId/v1/items/:index
GET /compressed/:collectionId/v1/items/:index
Returns a specific cNFT item with Merkle proof for verification.
Example Response:
{
"item": {
"metadata": {
"owner": "0:abc123...",
"individual_content": "base64-encoded-content"
},
"data_cell": "base64-encoded-cell",
"index": "0"
},
"root": "merkle-root-hash",
"proof_cell": "base64-encoded-proof"
}GET /cnft/:collectionId/v1/items?offset=0&count=100
GET /compressed/:collectionId/v1/items?offset=0&count=100
Returns a paginated list of cNFT items (max 100 per request).
GET /cnft/:collectionId/v1/state
GET /compressed/:collectionId/v1/state
Returns the current state of the cNFT collection including Merkle tree information.
Example Response:
{
"depth": 10,
"capacity": "1024",
"last_index": "99",
"root": "merkle-root-hash",
"address": "0:collection-address"
}The server uses three main database models:
id: Auto-incremented collection IDname: Collection namedescription: Collection descriptionimage: Collection image URLaddress: TON blockchain address (optional)
id: Token ID within collectioncollection_id: Reference to collectionname: Token namedescription: Token descriptionimage: Token image URLcontent_url: Additional content URLattributes: JSON attributes
token_id: Reference to tokencollection_id: Reference to collectionowner: TON address of ownerindividual_content: Compressed content data
npm run start:dev- Start development server with hot reloadnpm run build- Build production versionnpm run start:prod- Start production servernpm run edit- Open Prisma Studio for database managementnpm run seed- Seed database with sample datanpm run db::purge- Clean database
Create a .env file with the following variables:
DATABASE_URL="file:./dev.db"
PORT=80
NODE_ENV=productionThe server uses Prisma ORM with SQLite. Key commands:
npx prisma generate- Generate Prisma clientnpx prisma db push- Push schema to databasenpx prisma studio- Open database GUInpx prisma migrate dev- Create and run migrations
- Framework: NestJS with TypeScript
- Database: SQLite with Prisma ORM
- Blockchain: TON integration with
@ton/core - Compression: Merkle tree implementation for cNFTs
- Logging: Built-in request logging middleware
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
© Igor Isaev 2025
For support and questions, please open an issue in the repository.