A complete implementation of a token minting dApp on Base, integrating the novel x402 payment verification model for secure and automated transactions.
x402-mint is an early-stage TypeScript project in the AI payments / x402 ecosystem, focused on base, crypto, dapp, mint. It currently has 0 GitHub stars and 1 forks, and sits alongside related tools like gold-402, cryptopaykit, x402, extensions, base, middleware-hono.
A full-stack token minting system on Base implementing the x402 payment verification pattern.
完整的 Base 网络代币铸造全栈脚手架,实现 x402 支付校验模式。

LICODE x402 is a full-stack token minting system built on the Base network. It implements an x402 payment verification pattern, where users pay in USDC and receive LICODE tokens, with the whole process secured end-to-end by smart contracts and a verification backend.
1 USDC = 5,000 LICODETransfer event scanningdistribute()# Clone
git clone <repository-url>
cd x402-mint
# Root deps (contracts and tooling)
pnpm install
# Backend
cd backend
pnpm install
# Frontend
cd ../frontend
pnpm install
Root .env:
cp .env.example .env
# Edit .env to point to your Base testnet RPC and deployment keys.
Backend backend/.env:
cd backend
cp .env.example .env
# Edit backend/.env with contract addresses and RPC settings.
Frontend frontend/.env.local:
cd ../frontend
cp .env.example .env.local
# Edit frontend/.env.local with chain id and contract addresses.
pnpm build
# Deploy to Base Sepolia
pnpm run deploySepolia
Copy the emitted token address into backend/.env and frontend/.env.local.
cd backend
pnpm run dev
# http://localhost:3001
cd ../frontend
pnpm run dev
# http://localhost:3000
Full guide: docs/deployment/contract-deployment.md.
cp .env.example .env
# Edit .env with:
# - DEPLOYER_PRIVATE_KEY (with gas on Base)
# - OWNER_ADDRESS
# - DISTRIBUTOR_ADDRESS
# - Token parameters (optional; defaults are provided)
pnpm build
# Testnet
pnpm run deploySepolia
# Mainnet
pnpm run deploy
# Optional: verify
TOKEN_ADDRESS=0x... pnpm run verify
| Env var | Description | Default |
|---|---|---|
DEPLOYER_PRIVATE_KEY |
Deployer private key (needs gas) | - |
OWNER_ADDRESS |
Contract owner | - |
DISTRIBUTOR_ADDRESS |
Distributor EOA (backend signer) | - |
TOTAL_SUPPLY_18 |
Token total supply (18 decimals) | 1000000000 |
TOKENS_PER_USDC_18 |
Exchange rate (18 decimals) | 5000 |
TOTAL_USDC_CAP_6 |
Global USDC cap (6 decimals) | 100000000000 |
PER_WALLET_USDC_CAP_6 |
Per-wallet USDC cap (6 decimals) | 10000000 (10 USD) |
Full guide: docs/deployment/backend-deployment.md.
cd backend
cp .env.example .env
Edit backend/.env:
RPC_URL_BASE="https://mainnet.base.org"
TOKEN_ADDRESS="0xYourToken" # from step 1
USDC_ADDRESS="0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" # Base mainnet USDC
TREASURY_ADDRESS="0xTreasury" # receives user USDC
DISTRIBUTOR_PRIVATE_KEY="0x..." # must match DISTRIBUTOR_ADDRESS
MINT_USDC_6="1000000" # 1 USDC
CHAIN_ID="8453" # Base mainnet
# Security (production)
REDIS_URL="redis://localhost:6379"
ENABLE_CORS="true"
ENABLE_RATE_LIMIT="true"
FRONTEND_URL="https://your-domain.com"
Development:
pnpm run dev
Production with PM2:
pnpm run build
pnpm install -g pm2
pm2 start dist/server.js --name licode-backend
Or Docker:
docker build -t licode-backend .
docker run -d -p 3001:3001 --env-file .env licode-backend
Full guide: docs/deployment/frontend-deployment.md.
cd frontend
cp .env.example .env.local
Edit frontend/.env.local:
NEXT_PUBLIC_CHAIN_ID=8453
NEXT_PUBLIC_TOKEN_ADDRESS="0xYourToken"
NEXT_PUBLIC_USDC_ADDRESS="0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
NEXT_PUBLIC_TREASURY_ADDRESS="0xTreasury"
NEXT_PUBLIC_MINT_USDC="1"
Vercel (recommended):
pnpm install -g vercel
vercel --prod
Node server:
pnpm run build
pnpm start
# or
pm2 start npm --name licode-frontend -- start
x402-mint/
├── contracts/ # Solidity contracts
│ └── LicodeToken.sol # Main token contract
├── scripts/ # Hardhat scripts
│ ├── deploy.ts
│ ├── verify.ts
│ └── withdraw.ts
├── backend/ # Backend service
│ ├── src/
│ │ └── server.ts # Express server
│ ├── package.json
│ └── .env.example
├── frontend/ # Frontend app
│ ├── app/
│ │ ├── page.tsx
│ │ ├── providers.tsx
│ │ └── layout.tsx
│ ├── package.json
│ └── .env.example
├── docs/ # Documentation
│ ├── deployment/
│ ├── security/
│ ├── architecture/
│ └── guides/
├── images/
│ └── image.png # Demo screenshot
├── .env.example
├── hardhat.config.ts
├── package.json
└── README.md
User mint flow:
sequenceDiagram
participant User
participant Frontend
participant Backend
participant Base RPC
participant Contract
User->>Frontend: 1. Request mint
Frontend->>Backend: 2. GET /api/mint
Backend-->>Frontend: 3. 402 + payment instructions
Frontend-->>User: 4. Show address and amount
User->>Base RPC: 5. Send USDC to Treasury
Base RPC-->>User: 6. Return tx hash
User->>Frontend: 7. Submit tx hash
Frontend->>Backend: 8. POST /api/verify
Backend->>Base RPC: 9. Fetch receipt
Base RPC-->>Backend: 10. Tx details
Backend->>Backend: 11. Validate USDC Transfer event
Backend->>Contract: 12. Call distribute()
Contract-->>Backend: 13. Mint or transfer LICODE
Backend-->>Frontend: 14. Success response
Frontend-->>User: 15. Show success message
| Network | Chain ID | RPC URL | USDC address |
|---|---|---|---|
| Base Mainnet | 8453 | https://mainnet.base.org | 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 |
| Base Sepolia | 84532 | https://sepolia.base.org | 0x036CbD53842c5426634e7929541eC2318f3dCF7e |
DEPLOYER_ADDRESS – deploys contracts, pays gasOWNER_ADDRESS – can call ownerWithdraw() and setDistributor()DISTRIBUTOR_ADDRESS – backend EOA that calls distribute()TREASURY_ADDRESS – receives user USDC paymentstokens = (usdcAmount6 * tokensPerUsdc) / 1e6docs/deployment/contract-deployment.md – contract deploymentdocs/deployment/backend-deployment.md – backend deploymentdocs/deployment/frontend-deployment.md – frontend deploymentdocs/deployment/部署验证指南.md – post-deployment checksdocs/security/安全加固部署指南.md – production security hardeningdocs/security/安全校验分析.md – security analysisdocs/security/权限配置指南.md – roles and permissionsdocs/architecture/licode_x_402_mint_prd_full_stack_scaffold.md – architecturedocs/guides/功能完整性检查.md – functional test checklistnpx hardhat console --network base
const token = await ethers.getContractAt("LicodeToken", "0xToken")
await token.setDistributor("0xNewDistributor") # owner only
Then update DISTRIBUTOR_PRIVATE_KEY in backend/.env and restart the backend.
# In root .env
WITHDRAW_TO_ADDRESS=0xTarget
WITHDRAW_AMOUNT_18=1000000
TOKEN_ADDRESS=0xToken
npx hardhat run scripts/withdraw.ts --network base
Health:
curl http://localhost:3001/health
Output includes Redis status, RPC status, current block height, and distributor balance.
Logs:
pm2 logs licode-backend
# or
docker logs -f <container-id>
Keys
Backend
ENABLE_RATE_LIMIT=true).FRONTEND_URL).Contracts
Monitoring
docs/.Development helpers:
pnpm test # tests
pnpm format # formatting
pnpm typecheck # type checking
MIT – see LICENSE.
下面是简体中文版本的简介和使用说明,内容与英文版保持一致,便于中文用户快速上手。
LICODE x402 是一个部署在 Base 区块链上的代币铸造全栈系统,实现了 x402 支付校验模式。用户通过支付 USDC 获得 LICODE 代币,整个流程由智能合约和后端服务共同保证安全与合规。
核心机制:
1 USDC = 5,000 LICODEdistribute() 分发智能合约
后端服务
Transfer 事件扫描前端应用
git clone <repository-url>
cd x402-mint
pnpm install
cd backend && pnpm install
cd ../frontend && pnpm install
cp .env.example .env # 根目录
cd backend && cp .env.example .env
cd ../frontend && cp .env.example .env.local
根据实际 RPC、合约地址等修改三个环境变量文件。
pnpm build
pnpm run deploySepolia # 部署到 Base Sepolia
将部署输出的合约地址写入 backend/.env 与 frontend/.env.local。
cd backend && pnpm run dev # http://localhost:3001
cd ../frontend && pnpm run dev # http://localhost:3000
https://mainnet.base.org0x833589fcd6edb6e08f4c7c32d4f71b54bda02913https://sepolia.base.org0x036CbD53842c5426634e7929541eC2318f3dCF7e重要地址说明:
DEPLOYER_ADDRESS:部署合约地址,需要支付 gasOWNER_ADDRESS:Owner 地址,可调用 ownerWithdraw() 和 setDistributor()DISTRIBUTOR_ADDRESS:后端使用的 EOA,负责调用 distribute()TREASURY_ADDRESS:接收用户 USDC 的地址tokens = (usdcAmount6 * tokensPerUsdc) / 1e6更多细节请参考仓库 docs/ 目录中的部署、安全和架构文档。
如果这个项目对你有帮助,欢迎 Star 支持。
⚡ The gold standard for x402 resources. 300+ projects, SDKs, tools, facilitators, and ecosystem data for the HTTP 402 Payment Required protocol. Curated by 24K Labs.
x402 crypto payment integration toolkit for Next.js — accept USDC on Base
Full-stack x402 SDK - add paid API monetization to any endpoint. Express middleware, React hooks, Access Pass, dynamic pricing. Solana, Base, Polygon, Arbitrum, Optimism, Avalanche, SKALE.
Armory x402 SDK — Protocol extensions for x402 payments. Add SIWX, payment ID, Bazaar discovery, and custom extensions.
Armory x402 SDK — Core protocol types, EIP-712 signing, encoding, network configs, and token registry. 100% compatible with Coinbase x402 SDKs.
Armory x402 SDK — Payment middleware for Hono. Accept x402 payments from any client in your Hono app. 100% compatible with Coinbase x402 SDKs.
Client SDK, Claude plugin and skill framework for the Pinion protocol. x402 micropayments on Base.
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Turn any API or MCP server into a paid service with x402
Public adapters and discovery catalog for Triptych OS (Agent OS): agent frameworks, MCP/A2A/x402 protocols, workflows, wallets, SDKs, and examples for execute-first routing, governed handoffs, and receipt-aware agent commerce.
A wallet for agents. Make payments via x402, use stablecoins, swap assets, earn yield with defi and buy tokenized stocks across the most popular chains.